Skip to content

Commit b13d43a

Browse files
committed
feat(config): Integrate environment-based view caching with app configuration
1 parent 8253ff3 commit b13d43a

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
@@ -12,6 +12,7 @@ import path from 'node:path';
1212
import express from 'express';
1313
import flash from 'connect-flash';
1414
import { router } from './router';
15+
import { appConfig } from './config';
1516
import compression from 'compression';
1617
import expressLayouts from 'express-ejs-layouts';
1718

@@ -39,10 +40,10 @@ app.use(express.static(path.resolve(path.join(process.cwd(), 'public')), { maxAg
3940

4041
app.engine('html', ejs.renderFile);
4142

42-
app.set('view cache', true);
43-
4443
app.set('view engine', 'html');
4544

45+
app.set('view cache', appConfig.env === 'production');
46+
4647
app.set('views', path.resolve(path.join(process.cwd(), 'src', 'views', 'pages')));
4748

4849
app.set('layout', path.resolve(path.join(process.cwd(), 'src', 'views', 'layouts', 'public.html')));

0 commit comments

Comments
 (0)