Skip to content

Commit

Permalink
feat(server): simplify not found route handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jun 2, 2016
1 parent 3b7d69f commit 5961701
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const express = require('express');
const compression = require('compression');
const responseTime = require('response-time');
const corsHeaders = require('@starefossen/express-cors');
const HttpError = require('@starefossen/http-error');

const app = module.exports = express();
const pg = require('./lib/pg');
Expand All @@ -26,9 +27,6 @@ app.use(compression());
app.use(responseTime());
app.use(corsHeaders.middleware);

app.use((req, res, next) => {
next();
});
app.all('/CloudHealthCheck', (req, res) => {
res.status(200);

Expand All @@ -42,12 +40,7 @@ app.all('/CloudHealthCheck', (req, res) => {
});

app.use('/api/v1', require('./controllers/n50'));

app.use((req, res) => {
res.status(404).json({
message: 'Not Found',
});
});
app.use((req, res, next) => next(new HttpError('Not Found', 404)));

app.use(raven.middleware.express.requestHandler(sentry));
app.use(raven.middleware.express.errorHandler(sentry));
Expand Down

0 comments on commit 5961701

Please sign in to comment.