Skip to content

Commit

Permalink
[Task] #41 skip tests in rateLimiting
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-Style committed Feb 13, 2024
1 parent f40a710 commit 0dbadbb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Start server
run: |
sudo npm start &
sleep 6 # Give server some time to start
sleep 8 # Give server some time to start
- name: Check if server is running
run: |
curl --fail http://localhost:80 || exit 1
Expand Down
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ app.use(function (req, res, next) { // limit request size limit when recieving d

// routes
app.get('/', (req, res) => {
console.log(req.ip + " - " + res.locals.ip);
res.send('Hello World, via TypeScript and Node.js! ' + res.locals.ip);
});

Expand Down
2 changes: 1 addition & 1 deletion src/middleware/limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import logger from '@src/scripts/logger';

const baseOptions: Partial<rateLimiterOptions & slowDownOptions> = {
windowMs: 30 * 60 * 1000,
skip: (req, res) => (res.locals.ip == process.env.LOCALHOST)
skip: (req, res) => (res.locals.ip == "127.0.0.1" || res.locals.ip == "::1")

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
}

const baseSlowDownOptions: Partial<slowDownOptions> = {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe("GET /write", () => {

expect(entry.time.created).toBeGreaterThan(date.getTime());
expect(entry.time.diff).toBeGreaterThan(3.5);
expect(entry.time.diff).toBeLessThan(4);
expect(entry.time.diff).toBeLessThan(4.6);


const germanDayPattern = "(Montag|Dienstag|Mittwoch|Donnerstag|Freitag|Samstag|Sonntag)";
Expand Down

0 comments on commit 0dbadbb

Please sign in to comment.