Skip to content

Commit

Permalink
Merge pull request #331 from Chia-Network/readonly-header
Browse files Browse the repository at this point in the history
feat: set readonly header
  • Loading branch information
MichaelTaylor3D authored Mar 1, 2022
2 parents be4126d + 946aa44 commit cc604b1
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 cc604b1

Please sign in to comment.