chore: seminarhof customer project

This commit is contained in:
e2e
2026-07-10 23:12:46 +02:00
commit 50a4d93100
188 changed files with 20779 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { pikkuMiddleware } from '@pikku/core'
import type { SingletonServices } from '../application-types.d.js'
export const SESSION_COOKIE = 'sh_session'
export const sessionCookieMiddleware = pikkuMiddleware<SingletonServices>(
async ({ kysely }, { http, setSession, session }, next) => {
if (!http?.request || !setSession || session) {
return next()
}
const token = http.request.cookie(SESSION_COOKIE)
if (token) {
const row = await kysely
.selectFrom('bookingSession')
.innerJoin('user', 'user.id', 'bookingSession.userId')
.where('bookingSession.sessionId', '=', token)
.where('bookingSession.expiresAt', '>', new Date().toISOString())
.select(['user.id as userId', 'user.role'])
.executeTakeFirst()
if (row) {
setSession({ userId: row.userId, role: row.role as string })
}
}
await next()
},
)