2025-01-02 15:33:37 +11:00
|
|
|
import { Hono } from 'hono';
|
2025-02-17 22:46:36 +11:00
|
|
|
import superjson from 'superjson';
|
2025-01-02 15:33:37 +11:00
|
|
|
|
|
|
|
|
import type { SessionValidationResult } from '../lib/session/session';
|
2025-02-16 00:44:01 +11:00
|
|
|
import { getOptionalSession } from '../lib/utils/get-session';
|
2025-01-02 15:33:37 +11:00
|
|
|
|
2025-02-17 22:46:36 +11:00
|
|
|
export const sessionRoute = new Hono()
|
|
|
|
|
.get('/session', async (c) => {
|
|
|
|
|
const session: SessionValidationResult = await getOptionalSession(c);
|
2025-01-02 15:33:37 +11:00
|
|
|
|
2025-02-17 22:46:36 +11:00
|
|
|
return c.json(session);
|
|
|
|
|
})
|
|
|
|
|
.get('/session-json', async (c) => {
|
|
|
|
|
const session: SessionValidationResult = await getOptionalSession(c);
|
|
|
|
|
|
|
|
|
|
return c.json(superjson.serialize(session));
|
|
|
|
|
});
|