owltide/server/api/schedule.ts
Hornwitser 251e83f640
All checks were successful
/ build (push) Successful in 1m12s
/ deploy (push) Successful in 16s
Rename AcountSession to ServerSession
Start the work of clearly distingushing client side types, server side
types and types shared over the API by renaming "AccountSession" and
"Session" names used on the server to "ServerSession".
2025-06-09 16:51:05 +02:00

14 lines
546 B
TypeScript

import { readAccounts, readSchedule } from "~/server/database";
import { Account } from "~/shared/types/account";
import { canSeeCrew } from "../utils/schedule";
export default defineEventHandler(async (event) => {
const session = await getServerSession(event);
let account: Account | undefined;
if (session) {
const accounts = await readAccounts()
account = accounts.find(account => account.id === session.accountId);
}
const schedule = await readSchedule();
return canSeeCrew(account?.type) ? schedule : filterSchedule(schedule);
})