Skip to content

Commit

Permalink
feat: add logger and static cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Oct 29, 2023
1 parent b383969 commit 926a37d
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 1 deletion.
193 changes: 193 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@linaria/webpack-loader": "^4.5.4",
"@types/koa": "^2.13.7",
"@types/koa__router": "^12.0.0",
"@types/koa-logger": "^3.1.4",
"@types/koa-static": "^4.0.2",
"@types/koa-useragent": "^2.1.2",
"@types/node": "^20.4.5",
Expand Down Expand Up @@ -49,6 +50,7 @@
"dayjs": "^1.11.9",
"dotenv": "^16.3.1",
"koa": "^2.14.2",
"koa-logger": "^3.2.1",
"koa-static": "^5.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import koa from 'koa';
import serve from 'koa-static';
import logger from 'koa-logger';
import { userAgent } from 'koa-useragent';
import { configDotenv } from 'dotenv';
import viewRouter, { fallback } from './server/route/viewRoute';
Expand All @@ -11,9 +12,15 @@ const HOST = process.env.HOST;

const app = new koa();

app.use(logger());

app.use(userAgent);
app.use(viewRouter.routes()).use(viewRouter.allowedMethods());
app.use(serve(__dirname + '/public'));
app.use(
serve(__dirname + '/public', {
maxAge: 24 * 60 * 60,
}),
);

app.use(fallback);

Expand Down

0 comments on commit 926a37d

Please sign in to comment.