Skip to content

Commit

Permalink
fix(template): change middleware order and add missing request logger…
Browse files Browse the repository at this point in the history
… middleware
  • Loading branch information
DASPRiD committed Oct 10, 2024
1 parent 636f086 commit 7442a85
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
10 changes: 5 additions & 5 deletions skeleton/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"type": "module",
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@commitlint/cli": "^19.4.1",
"@commitlint/config-conventional": "^19.4.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"esbuild": "^0.23.1",
"lefthook": "^1.7.14",
"tsx": "^4.19.0",
"typescript": "^5.5.4"
"lefthook": "^1.7.18",
"tsx": "^4.19.1",
"typescript": "^5.6.3"
},
"scripts": {
"start": "pnpm --filter api start",
Expand Down
8 changes: 4 additions & 4 deletions skeleton/base/packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"@types/koa-cache-control": "^2.0.5",
"@types/koa-compress": "^4.0.6",
"@types/koa__cors": "^5.0.0",
"@types/node": "^20.16.2"
"@types/node": "^20.16.11"
},
"dependencies": {
"@koa/cors": "^5.0.0",
"body-parser": "^1.20.2",
"body-parser": "^1.20.3",
"compression": "^1.7.4",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand All @@ -26,9 +26,9 @@
"koa-bodyparser": "^4.4.1",
"koa-cache-control": "^2.0.0",
"koa-compress": "^5.1.1",
"koa-jsonapi-zod": "^3.2.3",
"koa-jsonapi-zod": "^3.2.4",
"koa-tree-router": "^0.12.1",
"logforth": "^1.1.4",
"logforth": "^1.2.2",
"nanoid": "^5.0.7",
"zod": "^3.23.8",
"zod-joda": "^1.1.3"
Expand Down
8 changes: 4 additions & 4 deletions skeleton/base/packages/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.2",
"@types/node": "^20.11.4",
"aws-cdk": "^2.121.1"
"@tsconfig/node20": "^20.1.4",
"@types/node": "^20.16.11",
"aws-cdk": "^2.161.1"
},
"dependencies": {
"aws-cdk-lib": "^2.121.1",
"aws-cdk-lib": "^2.161.1",
"constructs": "^10.3.0",
"undent": "^0.1.0"
}
Expand Down
18 changes: 10 additions & 8 deletions skeleton/templates/packages/api/src/index.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ if (appConfigStartResult.error) {

const app = new Koa();

app.use(async (context, next) => {
if (context.url === "/health") {
context.body = { status: "alive" };
return;
}

return next();
});

app.use(requestLoggerMiddleware);
app.use(cacheControl({ noStore: true }));
app.use(
compress({
Expand All @@ -49,14 +59,6 @@ app.use(
);
app.use(bodyParser());

app.use(async (context, next) => {
if (context.url === "/health") {
context.body = { status: "alive" };
return;
}

return next();
});
{{#if (has features "postgres")}}

app.use(requestContextMiddleware);
Expand Down

0 comments on commit 7442a85

Please sign in to comment.