SyncScript

backend-auth-service.ts
1import { Request, Response } from "express";
2import jwt from "jsonwebtoken";
3import { db } from "../core/database";
4import { env } from "../config/env";
5
6interface AuthPayload {
7 userId: string;
8 role: "admin" | "member";
9}
10
11export async function authenticate(token: string) {
12Sarah
13}
14
15export async function getSession(req: Request, res: Response) {
16 const token = req.headers.authorization?.replace("Bearer ", "");
17 if (!token) return res.status(401).json({ error: "Unauthorized" });
18 const payload = await authenticate(token);
19 return res.json(await db.session.findUnique({ where: { userId: payload.userId } }));
20}
Problems 0OutputTerminal
node — syncscript
➜ backend-auth-service git:(main) bun run dev
watching for file changes