refactor authentication middleware and clean up config comments
This commit is contained in:
parent
65d4779083
commit
a19070c767
7
index.js
7
index.js
@ -6,15 +6,20 @@ const app = express();
|
||||
const port = 3000;
|
||||
|
||||
const uploadPath = process.env.UPLOAD_PATH || '/tmp';
|
||||
const config = process.env.config || '{ "uploadGroups": [{ "matcher": "^test.*\.txt$", "groupSize": 3}] }';
|
||||
// const config = process.env.CONFIG || "{ \"uploadGroups\": [] }";
|
||||
//const config = process.env.CONFIG || "{ \"uploadGroups\": [{ \"matcher\": \"^mmkb-android-.*-test\\.apk$\", \"groupSize\": 3},{ \"matcher\": \"^mmkb-android-.*-int\\.apk$\", \"groupSize\": 3},{ \"matcher\": \"^mmkb-android-.*-prod\\.apk$\", \"groupSize\": 3}] }";
|
||||
|
||||
|
||||
|
||||
app.use(fileUpload());
|
||||
|
||||
app.use((req, res, next) => {
|
||||
if (process.env.API_KEY) {
|
||||
const authenticated = req.get('Authorization') === 'Bearer ' + process.env.API_KEY;
|
||||
if (!authenticated) {
|
||||
return res.status(401).send('Unauthorized');
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user