37 lines
994 B
TypeScript
37 lines
994 B
TypeScript
import { DateTime } from "ts-luxon";
|
|
import { services } from "../services";
|
|
import type { Call, Result, Route } from "../types";
|
|
import { html, render } from "../request/util";
|
|
import { loginRoute } from "./login";
|
|
import { logoutRoute } from "./logout";
|
|
|
|
const routes: Record<string, Route> = {
|
|
hello: {
|
|
path: "/hello",
|
|
methods: ["GET"],
|
|
handler: async (_call: Call): Promise<Result> => {
|
|
const now = DateTime.now();
|
|
const c = await render("basic/hello", { now });
|
|
|
|
return html(c);
|
|
},
|
|
},
|
|
home: {
|
|
path: "/",
|
|
methods: ["GET"],
|
|
handler: async (_call: Call): Promise<Result> => {
|
|
const auth = services.auth;
|
|
const me = services.session.getUser();
|
|
|
|
const email = me.toString();
|
|
const c = await render("basic/home", { email });
|
|
|
|
return html(c);
|
|
},
|
|
},
|
|
login: loginRoute,
|
|
logout: logoutRoute,
|
|
};
|
|
|
|
export { routes };
|