Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb88e7b038 | |||
| e719e5129f | |||
| 08894730a3 |
+1
-3
@@ -6,8 +6,6 @@ await load({ envPath: "./.env", export: true });
|
||||
await ensureDatabases();
|
||||
export default defineConfig({
|
||||
server: {
|
||||
cert: await Deno.readTextFile("certs/cert.pem"),
|
||||
key: await Deno.readTextFile("certs/key.pem"),
|
||||
port: 443,
|
||||
port: 80,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -43,6 +43,28 @@ export function getKey(user: string): string {
|
||||
}
|
||||
|
||||
export const handler: MiddlewareHandler<State>[] = [
|
||||
async function logRequest(
|
||||
request: Request,
|
||||
context: FreshContext<State>,
|
||||
): Promise<Response> {
|
||||
const url = new URL(request.url);
|
||||
const start = performance.now();
|
||||
console.log(`--> ${request.method} ${url.pathname}${url.search}`);
|
||||
|
||||
try {
|
||||
const response = await context.next();
|
||||
|
||||
const duration = (performance.now() - start).toFixed(1);
|
||||
console.log(`<-- ${request.method} ${url.pathname} ${response.status} (${duration}ms)`);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
const duration = (performance.now() - start).toFixed(1);
|
||||
console.error(`<-- ${request.method} ${url.pathname} ERROR (${duration}ms)`);
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Check if user is authenticated and add session to context accordingly.
|
||||
* @param request The HTTP incomming request.
|
||||
|
||||
Reference in New Issue
Block a user