Merge branch 'master' into issue-33
This commit is contained in:
commit
7042165ff2
7 changed files with 464 additions and 15 deletions
|
@ -7,9 +7,14 @@ const helmet = require('helmet');
|
|||
const bytes = require('bytes');
|
||||
const conf = require('./config.js');
|
||||
const storage = require('./storage.js');
|
||||
const Raven = require('raven');
|
||||
|
||||
const notLocalHost = conf.notLocalHost;
|
||||
|
||||
if (notLocalHost) {
|
||||
Raven.config(conf.sentry_dsn).install();
|
||||
}
|
||||
|
||||
const mozlog = require('./log.js');
|
||||
|
||||
const log = mozlog('portal.server');
|
||||
|
@ -18,10 +23,13 @@ const STATIC_PATH = path.join(__dirname, '../public');
|
|||
|
||||
const app = express();
|
||||
|
||||
app.engine('handlebars', exphbs({
|
||||
defaultLayout: 'main',
|
||||
partialsDir: 'views/partials/'
|
||||
}));
|
||||
app.engine(
|
||||
'handlebars',
|
||||
exphbs({
|
||||
defaultLayout: 'main',
|
||||
partialsDir: 'views/partials/'
|
||||
})
|
||||
);
|
||||
app.set('view engine', 'handlebars');
|
||||
|
||||
app.use(helmet());
|
||||
|
@ -39,9 +47,9 @@ app.get('/', (req, res) => {
|
|||
|
||||
app.get('/exists/:id', (req, res) => {
|
||||
const id = req.params.id;
|
||||
storage.exists(id).then(doesExist => {
|
||||
res.sendStatus(doesExist ? 200 : 404);
|
||||
});
|
||||
storage.exists(id).then(() => {
|
||||
res.sendStatus(200);
|
||||
}).catch(err => res.sendStatus(404));
|
||||
});
|
||||
|
||||
app.get('/download/:id', (req, res) => {
|
||||
|
@ -151,6 +159,10 @@ app.get('/__lbheartbeat__', (req, res) => {
|
|||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
app.get('/__heartbeat__', (req, res) => {
|
||||
storage.ping().then(() => res.sendStatus(200), () => res.sendStatus(500));
|
||||
});
|
||||
|
||||
app.get('/__version__', (req, res) => {
|
||||
res.sendFile(path.join(STATIC_PATH, 'version.json'));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue