Skip to content

Commit

Permalink
feat: set readonly header
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Mar 1, 2022
1 parent be4126d commit 946aa44
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ app.use(express.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(fileUpload());

// Add optional API key if set in .env file
app.use(function (req, res, next) {
if (process.env.API_KEY) {
const apikey = req.header('x-api-key');
Expand All @@ -30,6 +31,15 @@ app.use(function (req, res, next) {
}
});

// Add readonly header if set in .env file
app.use(function (req, res, next) {
if (process.env.READ_ONLY) {
res.setHeader('cw-read-only', process.env.READ_ONLY);
}

next();
});

app.use('/v1', V1Router);

sequelize.authenticate().then(() => console.log('Connected to database'));
Expand Down

0 comments on commit 946aa44

Please sign in to comment.