Skip to content

Commit

Permalink
branding
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Mar 18, 2024
1 parent e699f72 commit 6eccdcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/def/internal-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ export type U2I<U> = (U extends any ? (k: U) => void : never) extends (k: infer
? I
: never

export type Tag<T, Tag extends string> = T & { __tag: Tag }

// eslint-disable-next-line @typescript-eslint/ban-types
export type Brand<T> = T & {}
7 changes: 4 additions & 3 deletions src/server/trpc/middleware/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { publicProcedure } from '../trpc'
import { Constant } from '~/server/common/constants'
import { haveSession } from '~/server/middleware/0.session'
import { sessions } from '~/server/singleton/service'
import { type Session } from '$base/server/session'

const config = {
httpOnly: true,
}

export const sessionProcedure = publicProcedure
.use(async ({ ctx, next }) => {
if (!ctx.session.id) {
Expand Down Expand Up @@ -71,12 +71,13 @@ export const sessionProcedure = publicProcedure
return await next({
ctx: Object.assign(ctx, {
session: Object.assign(ctx.session, {
async getBinding<Additional extends Record<string, unknown>>() {
async getBinding() {
if (!ctx.session.id) {
return undefined
}
return (await sessions.get(ctx.session.id)) as Awaited<ReturnType<typeof sessions['get']>> & Partial<Additional>
return (await sessions.get(ctx.session.id)) as Awaited<ReturnType<typeof sessions['get']>>
},
update: (data: Partial<Session>) => sessions.update(ctx.session.id, data),
}),
}),
})
Expand Down

0 comments on commit 6eccdcb

Please sign in to comment.