hydra-express
Advanced tools
Comparing version 1.4.19 to 1.4.20-experimental
71
index.js
@@ -436,41 +436,44 @@ /** | ||
this.server.listen(this.config.hydra.servicePort, () => { | ||
this.registerRoutesCallback && this.registerRoutesCallback(); | ||
Promise.resolve(this.registerRoutesCallback && this.registerRoutesCallback()) | ||
.then(routesRegistered => this._postRouteSetup()); | ||
}); | ||
} | ||
app.use('/*', (req, res) => { | ||
res.sendFile(path.resolve(this.config.appPath + '/index.html')); | ||
}); | ||
_postRouteSetup() { | ||
app.use('/*', (req, res) => { | ||
res.sendFile(path.resolve(this.config.appPath + '/index.html')); | ||
}); | ||
/** | ||
* Post middleware init. Make sure to do this last. | ||
*/ | ||
/** | ||
* Post middleware init. Make sure to do this last. | ||
*/ | ||
/** | ||
* @param {object} req - express request object | ||
* @param {object} res - express response object | ||
* @param {function} next - express next handler | ||
*/ | ||
app.use((req, res, next) => { | ||
let err = new Error('Not Found'); | ||
err.status = ServerResponse.HTTP_NOT_FOUND; | ||
next(err); | ||
}); | ||
/** | ||
* @param {object} req - express request object | ||
* @param {object} res - express response object | ||
* @param {function} next - express next handler | ||
*/ | ||
app.use((req, res, next) => { | ||
let err = new Error('Not Found'); | ||
err.status = ServerResponse.HTTP_NOT_FOUND; | ||
next(err); | ||
}); | ||
/** | ||
* @param {object} err - express err object | ||
* @param {object} req - express request object | ||
* @param {object} res - express response object | ||
* @param {function} _next - express next handler | ||
*/ | ||
app.use((err, req, res, _next) => { | ||
let errCode = err.status || ServerResponse.HTTP_SERVER_ERROR; | ||
if (err.status !== ServerResponse.HTTP_NOT_FOUND) { | ||
this.appLogger.fatal({ | ||
event: 'error', | ||
error: err.name, | ||
stack: err.stack | ||
}); | ||
} | ||
res.status(errCode).json({ | ||
code: errCode | ||
/** | ||
* @param {object} err - express err object | ||
* @param {object} req - express request object | ||
* @param {object} res - express response object | ||
* @param {function} _next - express next handler | ||
*/ | ||
app.use((err, req, res, _next) => { | ||
let errCode = err.status || ServerResponse.HTTP_SERVER_ERROR; | ||
if (err.status !== ServerResponse.HTTP_NOT_FOUND) { | ||
this.appLogger.fatal({ | ||
event: 'error', | ||
error: err.name, | ||
stack: err.stack | ||
}); | ||
} | ||
res.status(errCode).json({ | ||
code: errCode | ||
}); | ||
@@ -477,0 +480,0 @@ }); |
{ | ||
"name": "hydra-express", | ||
"version": "1.4.19", | ||
"version": "1.4.20-experimental", | ||
"description": "A module which wraps Hydra and ExpressJS to provide an out of the box microservice which can support API routes and handlers.", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
900687
749
1