Skip to content

Commit

Permalink
remove prisma deprecation warning, add "normal" priv depreaction warning
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Apr 7, 2024
1 parent c7c22d6 commit 3d461a5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/server/backend/bancho.py/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BanchoPyPrivilege } from '~/server/backend/bancho.py/enums'

const eAll = ExpandedBitwiseEnumArray.fromTSBitwiseEnum(BanchoPyPrivilege)
/** @deprecated use drizzle sql instead! */
export const normal = eAll.and(BanchoPyPrivilege.Normal).and(BanchoPyPrivilege.Verified)
3 changes: 0 additions & 3 deletions src/server/backend/bancho.py/server/rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ export class DatabaseRankProvider implements Base<Id> {
static readonly stringToId = stringToId
static readonly idToString = idToString

/**
* @deprecated prisma will be replaced by drizzle
*/
prisma = prismaClient
drizzle = drizzle
config = config
Expand Down
3 changes: 0 additions & 3 deletions src/server/backend/bancho.py/server/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ export class ScoreProvider implements Base<bigint, Id> {
static readonly stringToScoreId = stringToScoreId
static readonly scoreIdToString = scoreIdToString

/**
* @deprecated prisma will be replaced by drizzle
*/
prima = prismaClient
drizzle = drizzle
config = config
Expand Down
3 changes: 0 additions & 3 deletions src/server/backend/bancho.py/server/source/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ if (process.dev) {
log.push('query')
}

/**
* @deprecated prisma will be replaced by drizzle
*/
export const prismaClient = new PrismaClient({
log,
})
4 changes: 1 addition & 3 deletions src/server/backend/bancho.py/server/user-relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const config = _config()
export class UserRelationProvider implements Base<Id> {
static readonly stringToId = stringToId
static readonly idToString = idToString
/**
* @deprecated prisma will be replaced by drizzle
*/

prisma = prismaClient
config = config

Expand Down
4 changes: 1 addition & 3 deletions src/server/backend/bancho.py/server/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ export const enum FilterType {
class DBUserProvider extends Base<Id, ScoreId> implements Base<Id, ScoreId> {
static readonly stringToId = stringToId
static readonly idToString = idToString
/**
* @deprecated prisma will be replaced by drizzle
*/

prisma = prismaClient
drizzle = drizzle
relationships = new UserRelationProvider()
Expand Down
9 changes: 1 addition & 8 deletions src/server/backend/bancho.py/transforms/beatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export function toBeatmapSourcePrisma(source: Source['server']) {
? BeatmapSource.PrivateServer
: BeatmapSource.Unknown
}
/**
* @deprecated Prisma will be replaced by drizzle
*/

export function toBeatmapsetPrisma(beatmapset: Source, luckyOneBeatmapInBeatmapset: DBMap) {
return toBeatmapsetReal(
beatmapset,
Expand Down Expand Up @@ -144,11 +142,6 @@ export function toBeatmapCompact<Source extends BeatmapSource>(beatmap: {
}
}

// toGucchoBeatmapSource(input: )

/**
* @deprecated Prisma will be replaced by drizzle
*/
export function toBeatmapWithBeatmapsetPrisma(
beatmap: DBMap & {
source: Source
Expand Down
11 changes: 5 additions & 6 deletions src/server/trpc/middleware/optional-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import { UserProvider } from '~/server/singleton/service'

const userProvider = new UserProvider()
export const optionalUserProcedure = sessionProcedure.use(async ({ ctx, next }) => {
const merge: { user?: UserCompact<unknown> } = {}
const returnCtx = Object.assign(ctx, merge)
type ReturnCTX = typeof ctx & { user?: UserCompact<unknown> }
const session = await ctx.session.getBinding()
if (!session) {
return await next({ ctx: returnCtx })
return await next<ReturnCTX>(undefined as any)
}
if (!session.userId) {
return await next({ ctx: returnCtx })
return await next<ReturnCTX>(undefined as any)
}
const user = await userProvider.getCompactById({ id: UserProvider.stringToId(session.userId) }).catch(noop<undefined>)
returnCtx.user = user
return await next({ ctx: returnCtx })
;(ctx as ReturnCTX).user = user
return await next<ReturnCTX>({ ctx })
})

0 comments on commit 3d461a5

Please sign in to comment.