Set limit of 500mb for request body size and add API key validation
This commit is contained in:
11
index.js
11
index.js
@@ -7,6 +7,8 @@ app.use(express.json({
|
|||||||
limit: '500mb'
|
limit: '500mb'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const API_KEY = process.env.API_KEY || "silly!"
|
||||||
|
|
||||||
const RETRY_ERROR_CODES = [408, 500, 502, 503, 504, 522, 524, 599];
|
const RETRY_ERROR_CODES = [408, 500, 502, 503, 504, 522, 524, 599];
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -95,6 +97,15 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.post('/:instanceId', async (req, res) => {
|
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;
|
const instanceId = req.params.instanceId;
|
||||||
//console.log(`Instance ID: ${instanceId}`);
|
//console.log(`Instance ID: ${instanceId}`);
|
||||||
const body = req.body;
|
const body = req.body;
|
||||||
|
|||||||
Reference in New Issue
Block a user