Fix formatting

This commit is contained in:
2026-01-11 15:17:58 -06:00
parent 7399cbe785
commit 4a4dc11aa4
4 changed files with 25 additions and 21 deletions

View File

@@ -76,9 +76,8 @@ routes.forEach((route: Route, _idx: number, _allRoutes: Route[]) => {
};
try {
const retval = await runWithContext(
{ user: auth.user },
() => route.handler(req),
const retval = await runWithContext({ user: auth.user }, () =>
route.handler(req),
);
return retval;
} catch (error) {
@@ -117,7 +116,12 @@ async function handler(
const method = await methodParser.parseAsync(req.method);
const byMethod = processedRoutes[method];
console.log("DEBUG: req.path =", JSON.stringify(req.path), "method =", method);
console.log(
"DEBUG: req.path =",
JSON.stringify(req.path),
"method =",
method,
);
for (const [_idx, pr] of byMethod.entries()) {
const match = pr.matcher(req.path);
console.log("DEBUG: trying pattern, match result =", match);

View File

@@ -1,11 +1,9 @@
import { DateTime } from "ts-luxon";
import { services } from "../services";
import type { Call, Result, Route } from "../types";
import { html, render } from "../util";
import { loginRoute } from "./login";
import { services } from '../services';
const routes: Record<string, Route> = {
hello: {
path: "/hello",
@@ -18,17 +16,17 @@ const routes: Record<string, Route> = {
},
},
home: {
path:'/',
methods:['GET'],
handler:async(_call:Call): Promise<Result> => {
const auth = services.auth
const me = services.session.getUser()
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})
const email = me.toString();
const c = await render("basic/home", { email });
return html(c)
}
return html(c);
},
},
login: loginRoute,
};

View File

@@ -1,8 +1,8 @@
// add-user.ts
// Management command to create users from the command line
import { pool, PostgresAuthStore } from "../database";
import { hashPassword } from "../auth/password";
import { PostgresAuthStore, pool } from "../database";
async function main(): Promise<void> {
const args = process.argv.slice(2);
@@ -51,7 +51,9 @@ async function main(): Promise<void> {
// Optionally activate user immediately
if (makeActive) {
await store.updateUserEmailVerified(user.id);
console.log(`Created and activated user: ${user.email} (${user.id})`);
console.log(
`Created and activated user: ${user.email} (${user.id})`,
);
} else {
console.log(`Created user: ${user.email} (${user.id})`);
console.log(" Status: pending (use --active to create as active)");

View File

@@ -3,7 +3,7 @@ import nunjucks from "nunjucks";
import { contentTypes } from "./content-types";
import { executionContext } from "./execution-context";
import { httpCodes } from "./http-codes";
import type { Result, RedirectResult } from "./types";
import type { RedirectResult, Result } from "./types";
// FIXME: Handle the error here
const loadFile = async (path: string): Promise<string> => {
@@ -18,7 +18,7 @@ const render = async (path: string, ctx?: object): Promise<string> => {
const template = await loadFile(fullPath);
const c = ctx===undefined ? {} : ctx;
const c = ctx === undefined ? {} : ctx;
const retval = nunjucks.renderString(template, c);