Set limit of 500mb for request body size and add API key validation

This commit is contained in:
Aaro Varis
2024-09-29 18:23:16 +03:00
parent 8dbfcdf8c0
commit eb05e8aa0e

View File

@@ -7,6 +7,8 @@ app.use(express.json({
limit: '500mb'
}));
const API_KEY = process.env.API_KEY || "silly!"
const RETRY_ERROR_CODES = [408, 500, 502, 503, 504, 522, 524, 599];
async function main() {
@@ -95,6 +97,15 @@ async function main() {
}
app.post('/:instanceId', async (req, res) => {
const apikey = req.headers['X-BatchHttp-Api-Key'];
if (apikey !== API_KEY) {
res.status(401).send({
error: "Invalid API Key"
});
return;
}
const instanceId = req.params.instanceId;
//console.log(`Instance ID: ${instanceId}`);
const body = req.body;