Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-api-common

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-api-common - npm Package Compare versions

Comparing version 4.1.5 to 4.2.0

5

dist/devErrorHandler.js

@@ -6,4 +6,5 @@ "use strict";

});
exports.default = _default;
exports.default = function (err, req, res, next) {
function _default(err, req, res, next) {
res.status(err.status || 500);

@@ -14,2 +15,2 @@ res.json({

});
};
}

13

dist/expressServer.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,11 +6,10 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _express = require('express');
var _express = _interopRequireDefault(require("express"));
var _express2 = _interopRequireDefault(_express);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const server = (0, _express2.default)();
exports.default = server;
const server = (0, _express.default)();
var _default = server;
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,9 +6,12 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
exports.default = env => {
var _default = env => {
if (env === 'development') {
return require('./devErrorHandler').default;
return require("./devErrorHandler").default;
} else {
return require('./prodErrorHandler').default;
return require("./prodErrorHandler").default;
}
};
};
exports.default = _default;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = _default;
exports.default = function (req, res, next) {
function _default(req, res, next) {
res.status(404);
res.end('not found');
};
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = _default;
exports.default = function (log = console.log) {
function _default(log = console.log) {
return function (req, res, next) {

@@ -20,4 +21,5 @@ const method = req.method;

}
next();
};
};
}

@@ -6,4 +6,5 @@ "use strict";

});
exports.default = _default;
exports.default = function (err, req, res, next) {
function _default(err, req, res, next) {
res.status(err.status || 500);

@@ -14,2 +15,2 @@ res.json({

});
};
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,66 +6,65 @@ Object.defineProperty(exports, "__esModule", {

});
exports.makeServer = undefined;
exports.makeServer = void 0;
var _expressServer = require('./expressServer');
var _expressServer = _interopRequireDefault(require("./expressServer"));
var _expressServer2 = _interopRequireDefault(_expressServer);
var _bodyParser = _interopRequireDefault(require("body-parser"));
var _bodyParser = require('body-parser');
var _getErrorHandler = _interopRequireDefault(require("./getErrorHandler"));
var _bodyParser2 = _interopRequireDefault(_bodyParser);
var _logRequests = _interopRequireDefault(require("./logRequests"));
var _getErrorHandler = require('./getErrorHandler');
var _handleNotFound = _interopRequireDefault(require("./handleNotFound"));
var _getErrorHandler2 = _interopRequireDefault(_getErrorHandler);
var _debug = _interopRequireDefault(require("debug"));
var _logRequests = require('./logRequests');
var _expressMiddleware = _interopRequireDefault(require("@servicebus/express-middleware"));
var _logRequests2 = _interopRequireDefault(_logRequests);
var _expressPromBundle = _interopRequireDefault(require("express-prom-bundle"));
var _handleNotFound = require('./handleNotFound');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _handleNotFound2 = _interopRequireDefault(_handleNotFound);
const log = (0, _debug.default)('express-api-common');
var _debug = require('debug');
const makeServer = options => {
log('creating express server');
const {
logger,
notFoundHandler,
bus
} = options;
const metricsMiddleware = (0, _expressPromBundle.default)({
includeMethod: true
}); // we do not want to include healthcheck in metrics
// so use the metrics middleware below health
var _debug2 = _interopRequireDefault(_debug);
log('setting up prometheus metrics at /metrics');
var _expressServicebus = require('express-servicebus');
_expressServer.default.use(metricsMiddleware);
var _expressServicebus2 = _interopRequireDefault(_expressServicebus);
_expressServer.default.use((0, _expressMiddleware.default)(bus));
var _expressPromBundle = require('express-prom-bundle');
log('using middleware - logRequests and bodyParser');
var _expressPromBundle2 = _interopRequireDefault(_expressPromBundle);
_expressServer.default.use((0, _logRequests.default)(logger));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_expressServer.default.use(_bodyParser.default.json());
const log = (0, _debug2.default)('express-api-common');
_expressServer.default.use(_bodyParser.default.urlencoded({
extended: false
}));
const makeServer = exports.makeServer = options => {
log('creating express server');
const { logger, notFoundHandler, bus } = options;
const metricsMiddleware = (0, _expressPromBundle2.default)({ includeMethod: true });
log('setting up error handler');
// we do not want to include healthcheck in metrics
// so use the metrics middleware below health
log('setting up prometheus metrics at /metrics');
_expressServer2.default.use(metricsMiddleware);
_expressServer.default.use((0, _getErrorHandler.default)(process.env.NODE_ENV));
_expressServer2.default.use((0, _expressServicebus2.default)(bus));
_expressServer.default.start = _expressServer.default.startServer = (port, onListen) => {
_expressServer.default.use(notFoundHandler || _handleNotFound.default);
log('using middleware - logRequests and bodyParser');
_expressServer2.default.use((0, _logRequests2.default)(logger));
_expressServer2.default.use(_bodyParser2.default.json());
_expressServer2.default.use(_bodyParser2.default.urlencoded({ extended: false }));
_expressServer.default.listen(port, onListen);
};
log('setting up error handler');
_expressServer2.default.use((0, _getErrorHandler2.default)(process.env.NODE_ENV));
return _expressServer.default;
};
_expressServer2.default.start = _expressServer2.default.startServer = (port, onListen) => {
_expressServer2.default.use(notFoundHandler || _handleNotFound2.default);
_expressServer2.default.listen(port, onListen);
};
return _expressServer2.default;
};
exports.makeServer = makeServer;
{
"name": "express-api-common",
"version": "4.1.5",
"version": "4.2.0",
"description": "express api configured with logging, healthcheck, prometheus metrics, and other things I commonly use",

@@ -26,2 +26,3 @@ "scripts": {

"dependencies": {
"@servicebus/express-middleware": "^1.0.1",
"body-parser": "^1.19.0",

@@ -31,14 +32,13 @@ "debug": "^4.1.1",

"express-prom-bundle": "^6.0.0",
"express-servicebus": "^1.0.2",
"prom-client": "^12.0.0"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-core": "6.26.3",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/register": "^7.9.0",
"babel-eslint": "10.1.0",
"babel-jest": "26.0.1",
"babel-plugin-module-resolver": "4.0.0",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-register": "6.26.0",
"commitizen": "4.1.2",

@@ -45,0 +45,0 @@ "cz-conventional-changelog": "3.2.0",

# express-api-common
[![Build Status](https://travis-ci.org/patrickleet/express-api-common.svg?branch=master)](https://travis-ci.org/patrickleet/express-api-common)
[![codecov](https://codecov.io/gh/patrickleet/express-api-common/branch/master/graph/badge.svg)](https://codecov.io/gh/patrickleet/express-api-common)
[![Greenkeeper badge](https://badges.greenkeeper.io/patrickleet/express-api-common.svg)](https://greenkeeper.io/)
express api configured with commonly used middleware
express server configured with servicebus middleware, and prometheus exporters, and request (leveled optional) logging

@@ -8,0 +7,0 @@ ## Usage

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc