Skip to content

Commit

Permalink
sharex
Browse files Browse the repository at this point in the history
  • Loading branch information
sefinek committed Feb 14, 2024
1 parent 3becaf5 commit ae9a124
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 68 deletions.
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require('dotenv').config();

const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
const path = require('node:path');
const timeout = require('./middlewares/timeout.js');
const logger = require('./middlewares/morgan.js');
const limiter = require('./middlewares/ratelimit.js');
Expand All @@ -18,7 +16,6 @@ app.set('trust proxy', 1);


// Use
app.use(cors());
app.use(helmet({ crossOriginEmbedderPolicy: false, crossOriginResourcePolicy: false }));
app.use(logger);
app.use(limiter);
Expand All @@ -35,10 +32,10 @@ app.get('/', (req, res) =>
version,
worker: process.pid,
contact: '[email protected]',
domain: {
domains: {
main: 'https://sefinek.net',
api: 'https://api.sefinek.net',
cdn: 'https://screenshots.sefinek.net',
cdn: 'https://cdn.sefinek.net',
},
}, null, 3)),
);
Expand Down
23 changes: 0 additions & 23 deletions middlewares/modules/favicon.js

This file was deleted.

16 changes: 2 additions & 14 deletions middlewares/morgan.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
const morgan = require('morgan');

const userAgents = new Set([
'Better Uptime Bot Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
]);
morgan.token('body', req => JSON.stringify(req.body));

const skipUserAgent = req => userAgents.has(req.headers['user-agent']);

const normalizeBody = ({ body }) => {
if (!(body && typeof body === 'object' && Object.keys(body).length)) return null;

return JSON.stringify(body);
};

morgan.token('body', normalizeBody);

module.exports = morgan('[:status :method :response-time ms] :url :user-agent ":referrer" :body', { skip: skipUserAgent });
module.exports = morgan('[:status :method :response-time ms] :url :user-agent ":referrer" :body');
2 changes: 1 addition & 1 deletion middlewares/ratelimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { rateLimited } = require('../middlewares/other/errors.js');

module.exports = rateLimit({
windowMs: 5 * 60 * 1000,
limit: 500,
limit: 12,
standardHeaders: 'draft-7',
legacyHeaders: false,

Expand Down
2 changes: 1 addition & 1 deletion middlewares/timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const timeout = require('express-timeout-handler');
const { onTimeout } = require('./other/errors.js');

module.exports = () => timeout.handler({
timeout: 8000,
timeout: 6000,
onTimeout,
disable: ['write', 'setHeaders', 'send', 'json', 'end'],
});
21 changes: 0 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"up": "ncu -u && npm install && npm update && npm audit fix",
"sync": "git pull --recurse-submodules",
"usm": "git submodule update --remote",
"mon": "nodemon index.js"
},
"repository": {
Expand All @@ -21,7 +19,6 @@
},
"homepage": "https://github.com/sefinek24/screenshots.sefinek.net#readme",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.4",
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
Expand Down

0 comments on commit ae9a124

Please sign in to comment.