aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.ts
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-02-09 20:55:44 -0600
committerMatt Strapp <matt@mattstrapp.net>2022-02-09 20:55:44 -0600
commit7e80a49ab88f818e5e57238a25ee9c2d72252934 (patch)
tree369cc5ad64001c227d1d75af36a5c5f5b39baacf /src/index.ts
parentAdd a super basic README (diff)
downloadee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.tar
ee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.tar.gz
ee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.tar.bz2
ee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.tar.lz
ee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.tar.xz
ee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.tar.zst
ee4511w-web-7e80a49ab88f818e5e57238a25ee9c2d72252934.zip
configure CRSF properly
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/index.ts b/src/index.ts
index e6e083b..e396151 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -13,6 +13,15 @@ const app = express();
const port: string = env.PORT || '2000';
const csrf = csurf({ cookie: false });
+app.use(session({
+ secret: 'keyboard cat',
+ resave: false,
+ saveUninitialized: true,
+ cookie: {
+ secure: false,
+ maxAge: 1000 * 60 * 60 * 24 * 7,
+ },
+}));
const rateLimiter = rateLimit({
windowMs: 1 * 60 * 1000, // 1 minute
max: 30, // Limit each IP to 100 requests per `window` (here, per 15 minutes)
@@ -38,10 +47,8 @@ app.use(helmet());
// Add ejs as view engine
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views/pages'));
-
app.use('/public', express.static(path.join(__dirname, 'public')));
-
app.get('/', csrf, (req: Request, res: Response) => {
res.render('index', {
errors: [],