File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
1818import { meteorPath } from "meteorproxy"
1919import wisp from "wisp-server-node" ;
2020import { createBareServer } from "@tomphttp/bare-server-node"
21- //wahts the library i forgot
21+ import RateLimit from "express-rate-limit" ;
2222import net from "node:net"
2323import { hostname } from "node:os"
2424const __filename = fileURLToPath ( import . meta. url ) ;
@@ -294,6 +294,15 @@ function startServer() {
294294 console . log ( chalk . green ( "Serving" , chalk . yellow ( "Daylight's" ) , chalk . green ( "files" ) ) ) ;
295295 console . log ( chalk . green ( "All necessary files served. Setting up server." ) )
296296
297+ // set up rate limiter: maximum of 100 requests per 15 minutes
298+ const limiter = RateLimit ( {
299+ windowMs : 15 * 60 * 1000 , // 15 minutes
300+ max : 100 , // max 100 requests per windowMs
301+ } ) ;
302+
303+ // apply rate limiter to all requests
304+ app . use ( limiter ) ;
305+
297306 app . get ( "/" , ( req , res ) => {
298307 res . sendFile ( path . join ( __dirname , "dist/index.html" ) ) ;
299308 } ) ;
Original file line number Diff line number Diff line change 9797 "vite-plugin-static-copy" : " ^1.0.6" ,
9898 "vite-plugin-vsharp" : " ^1.8.1" ,
9999 "wisp-server-node" : " ^1.1.3" ,
100- "zod" : " ^3.23.8"
100+ "zod" : " ^3.23.8" ,
101+ "express-rate-limit" : " ^7.5.0"
101102 },
102103 "devDependencies" : {
103104 "@babel/core" : " ^7.24.9" ,
You can’t perform that action at this time.
0 commit comments