Fix formatting
This commit is contained in:
@@ -76,9 +76,8 @@ routes.forEach((route: Route, _idx: number, _allRoutes: Route[]) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const retval = await runWithContext(
|
const retval = await runWithContext({ user: auth.user }, () =>
|
||||||
{ user: auth.user },
|
route.handler(req),
|
||||||
() => route.handler(req),
|
|
||||||
);
|
);
|
||||||
return retval;
|
return retval;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -117,7 +116,12 @@ async function handler(
|
|||||||
const method = await methodParser.parseAsync(req.method);
|
const method = await methodParser.parseAsync(req.method);
|
||||||
|
|
||||||
const byMethod = processedRoutes[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()) {
|
for (const [_idx, pr] of byMethod.entries()) {
|
||||||
const match = pr.matcher(req.path);
|
const match = pr.matcher(req.path);
|
||||||
console.log("DEBUG: trying pattern, match result =", match);
|
console.log("DEBUG: trying pattern, match result =", match);
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { DateTime } from "ts-luxon";
|
import { DateTime } from "ts-luxon";
|
||||||
|
import { services } from "../services";
|
||||||
import type { Call, Result, Route } from "../types";
|
import type { Call, Result, Route } from "../types";
|
||||||
import { html, render } from "../util";
|
import { html, render } from "../util";
|
||||||
import { loginRoute } from "./login";
|
import { loginRoute } from "./login";
|
||||||
|
|
||||||
import { services } from '../services';
|
|
||||||
|
|
||||||
|
|
||||||
const routes: Record<string, Route> = {
|
const routes: Record<string, Route> = {
|
||||||
hello: {
|
hello: {
|
||||||
path: "/hello",
|
path: "/hello",
|
||||||
@@ -18,17 +16,17 @@ const routes: Record<string, Route> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
home: {
|
home: {
|
||||||
path:'/',
|
path: "/",
|
||||||
methods:['GET'],
|
methods: ["GET"],
|
||||||
handler: async (_call: Call): Promise<Result> => {
|
handler: async (_call: Call): Promise<Result> => {
|
||||||
const auth = services.auth
|
const auth = services.auth;
|
||||||
const me = services.session.getUser()
|
const me = services.session.getUser();
|
||||||
|
|
||||||
const email = me.toString()
|
const email = me.toString();
|
||||||
const c = await render('basic/home',{email})
|
const c = await render("basic/home", { email });
|
||||||
|
|
||||||
return html(c)
|
return html(c);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
login: loginRoute,
|
login: loginRoute,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// add-user.ts
|
// add-user.ts
|
||||||
// Management command to create users from the command line
|
// Management command to create users from the command line
|
||||||
|
|
||||||
import { pool, PostgresAuthStore } from "../database";
|
|
||||||
import { hashPassword } from "../auth/password";
|
import { hashPassword } from "../auth/password";
|
||||||
|
import { PostgresAuthStore, pool } from "../database";
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
@@ -51,7 +51,9 @@ async function main(): Promise<void> {
|
|||||||
// Optionally activate user immediately
|
// Optionally activate user immediately
|
||||||
if (makeActive) {
|
if (makeActive) {
|
||||||
await store.updateUserEmailVerified(user.id);
|
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 {
|
} else {
|
||||||
console.log(`Created user: ${user.email} (${user.id})`);
|
console.log(`Created user: ${user.email} (${user.id})`);
|
||||||
console.log(" Status: pending (use --active to create as active)");
|
console.log(" Status: pending (use --active to create as active)");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import nunjucks from "nunjucks";
|
|||||||
import { contentTypes } from "./content-types";
|
import { contentTypes } from "./content-types";
|
||||||
import { executionContext } from "./execution-context";
|
import { executionContext } from "./execution-context";
|
||||||
import { httpCodes } from "./http-codes";
|
import { httpCodes } from "./http-codes";
|
||||||
import type { Result, RedirectResult } from "./types";
|
import type { RedirectResult, Result } from "./types";
|
||||||
|
|
||||||
// FIXME: Handle the error here
|
// FIXME: Handle the error here
|
||||||
const loadFile = async (path: string): Promise<string> => {
|
const loadFile = async (path: string): Promise<string> => {
|
||||||
|
|||||||
Reference in New Issue
Block a user