Fix formatting
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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'],
|
||||
path: "/",
|
||||
methods: ["GET"],
|
||||
handler: async (_call: Call): Promise<Result> => {
|
||||
const auth = services.auth
|
||||
const me = services.session.getUser()
|
||||
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,
|
||||
};
|
||||
|
||||
@@ -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)");
|
||||
|
||||
@@ -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> => {
|
||||
|
||||
Reference in New Issue
Block a user