Skip to content

Commit 3b0415f

Browse files
committed
Update example
1 parent 4ed11ac commit 3b0415f

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

deno.jsonc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"tasks": {
33
// Builds the application.
4-
"build": "deno run -A --config=deno.jsonc jsr:@udibo/react-app@0.21/build",
4+
"build": "deno run -A --config=deno.jsonc jsr:@udibo/react-app@0.22/build",
55
// Builds the application in development mode.
66
"build-dev": "export APP_ENV=development NODE_ENV=development && deno task build",
77
// Builds the application in production mode.
88
"build-prod": "export APP_ENV=production NODE_ENV=production && deno task build",
99
// Builds and runs the application in development mode, with hot reloading.
10-
"dev": "export APP_ENV=development NODE_ENV=development && deno run -A --config=deno.jsonc jsr:@udibo/react-app@0.21/dev",
10+
"dev": "export APP_ENV=development NODE_ENV=development && deno run -A --config=deno.jsonc jsr:@udibo/react-app@0.22/dev",
1111
// Runs the application. Requires the application to be built first.
1212
"run": "deno run -A ./main.ts",
1313
// Runs the application in development mode. Requires the application to be built first.
@@ -37,7 +37,7 @@
3737
},
3838
"imports": {
3939
"@udibo/http-error": "jsr:@udibo/http-error@0",
40-
"@udibo/react-app": "jsr:@udibo/react-app@0.20.3",
40+
"@udibo/react-app": "jsr:@udibo/react-app@0.22",
4141
"@luca/esbuild-deno-loader": "jsr:@luca/[email protected]",
4242
"@oak/oak": "jsr:@oak/oak@16",
4343
"@std/assert": "jsr:@std/assert@1",

deno.lock

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

log.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import * as log from "@std/log";
2+
import { isDevelopment, logFormatter } from "@udibo/react-app";
23

4+
const level = isDevelopment() ? "DEBUG" : "INFO";
35
log.setup({
6+
handlers: {
7+
default: new log.ConsoleHandler(level, {
8+
formatter: logFormatter,
9+
}),
10+
},
411
loggers: {
5-
"react-app": {
6-
level: "INFO",
7-
handlers: ["default"],
8-
},
12+
"react-app": { level, handlers: ["default"] },
913
},
1014
});

routes/main.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Router } from "@udibo/react-app/server";
2+
import * as log from "@std/log";
23

34
import type { AppState } from "../state.ts";
45

@@ -9,13 +10,11 @@ export default new Router<AppState>()
910
try {
1011
await next();
1112
} finally {
12-
const dt = Date.now() - start;
13-
response.headers.set("X-Response-Time", `${dt}ms`);
14-
console.log({
15-
status: response.status,
16-
method: request.method,
17-
href: request.url.href,
18-
responseTime: dt,
19-
});
13+
const responseTime = Date.now() - start;
14+
response.headers.set("X-Response-Time", `${responseTime}ms`);
15+
log.info(
16+
`${request.method} ${request.url.href}`,
17+
{ status: response.status, responseTime },
18+
);
2019
}
2120
});

0 commit comments

Comments
 (0)