Skip to content

Commit 6c7f3e5

Browse files
committed
feat: add dev mode
1 parent d1da91a commit 6c7f3e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { z } from 'zod'
1111
import { Data, Service } from './service.js'
1212

1313
const __dirname = dirname(fileURLToPath(import.meta.url))
14+
const isProduction = process.env['NODE_ENV'] === 'production'
1415

1516
export type AppOptions = {
1617
logger?: boolean
@@ -19,7 +20,7 @@ export type AppOptions = {
1920

2021
const eta = new Eta({
2122
views: join(__dirname, '../views'),
22-
cache: true
23+
cache: isProduction
2324
})
2425

2526
function dataHandler(req, res, next) {
@@ -47,7 +48,7 @@ export function createApp(db: Low<Data>, options: AppOptions = {}) {
4748
options
4849
.static
4950
?.map((path) => isAbsolute(path) ? path : join(process.cwd(), path))
50-
.forEach((dir) => app.use(sirv(dir)))
51+
.forEach((dir) => app.use(sirv(dir, { dev: !isProduction })))
5152

5253
app.get('/', (_req, res) => res.send(eta.render('index.html', { data: db.data })))
5354

0 commit comments

Comments
 (0)