New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

restful-goose

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restful-goose - npm Package Compare versions

Comparing version 2.2.3 to 2.2.4

coverage/coverage-final.json

15

lib/app.js

@@ -9,3 +9,5 @@ var express = require('express');

/**
* @module restful-goose/app
*/
module.exports = (function() {

@@ -62,3 +64,9 @@ 'use strict';

api.all('*', function(req, res, next) {
api.all('*', function (req, res, next) {
// If database is disconnected, abort request
if (mongoose.readyState !== 1) {
res.status(500).send();
throw new Error('DB connection not ready');
}
log.debug('Setting rg response variables...');

@@ -102,6 +110,3 @@ _.set(res, 'rg.mongoose', mongoose);

/**
* @exports
*/
return RGFactory;
}());

@@ -0,1 +1,6 @@

/**
* RouteMap
* @module restful-goose/route-map
*/
var helpers = require('./helpers');

@@ -8,3 +13,32 @@ var ERR = require('./error-handler');

/**
* @class RouteMap
* @external express
* @see {@link https://expressjs.com/en/4x/api.html}
*/
/**
* @external mongoose
* @see {@link http://www.mongoosejs.com}
*/
/**
* @callback requestCallback
* @param {Error} - Request error (if any)
* @param {any} - Request result
*/
/**
* @typedef RGRequest
* @extends external:express#Request
*
* @property {any} model - The current data model
* @property {RGHash} rg - The rg variables, used for storing state and convenience functions
*/
/**
* @typedef RGHash
* @property mongoose - Mongoose connection used by restful-goose
*/
/**
* @class RouteMap
* @description Interfaces with a Mongoose model to handle API requests for a single object or a collection of objects

@@ -25,7 +59,5 @@ */

/**
* Returns a fresh copy of RouteMap with your provided hash of functions. Use this to replace the default event handlers with your own.
* @memberof RouteMap
* @method extend
* @param {object} properties - A hash of functions with handlers for various events, called during invocation
* @returns {RouteMap} routeMap - New route map
* Extends the base RouteMap prototype, overriding default methods with those provided to the function. Use this to replace the default event handlers with your own.
* @param {RouteMap} properties - A hash of functions with handlers for various events, called during invocation
* @returns {RouteMap} routeMap - New route map instance
*/

@@ -56,7 +88,6 @@ RouteMap.prototype.extend = function(properties) {

* Function responsible for binding internal variables to the req/res object for use in future events
* @method
* @private
* @param {express.Request} req
* @param {express.Response} res
* @param {function} next - Callback function for when routing is complete
* @param {external:express#Request} req
* @param {external:express#Response} res
* @param {requestCallback} next - Callback function for when routing is complete
* @returns {void}
*/

@@ -88,8 +119,5 @@ RouteMap.prototype.init = function(req, res, next) {

* Middleware called before model is populated. Overwrite this using [RouteMap.extend()]{@link RouteMap.extend} to apply your own handler.
* @public
* @memberof RouteMap
* @method
* @param {ExpressRequestObject} req - The request passed from the Express application
* @param {ExpressResponseObject} res - The response passed from the Express application
* @param {CallbackFunction} next - The request callback function. This MUST be called, or else the request will stall.
* @param {external:express#Request} req - The request passed from the Express application
* @param {external:express#Response} res - The response passed from the Express application
* @param {requestCallback} next - The request callback function. This MUST be called, or else the request will stall.
* @returns {void}

@@ -125,2 +153,3 @@ */

RouteMap.prototype.findOne.methods = [];
RouteMap.prototype.findOne.isPrivate = true;

@@ -160,3 +189,11 @@ RouteMap.prototype.findRelationship = function(req, res, next) {

RouteMap.prototype.findRelationship.methods = [];
RouteMap.prototype.findRelationship.isPrivate = true;
/**
* Performs find query, assigning an array of results to res.model
* @private
* @param req
* @param res
* @param next
*/
RouteMap.prototype.find = function(req, res, next) {

@@ -171,2 +208,3 @@ res.rg.log.debug('find() invoked');

RouteMap.prototype.find.methods = [];
RouteMap.prototype.find.isPrivate = true;

@@ -205,8 +243,5 @@ /**

* Middleware called on GET, PATCH, DELETE requests after the model has been retrieved from the database. The model is accessible in the response object under res.model, and can be modified as required. Overwrite this method with [RouteMap.extend()]{@link RouteMap.extend}
* @public
* @memberof RouteMap
* @method
* @param {ExpressRequestObject} req - The request passed from the Express application
* @param {ExpressResponseObject} res - The response passed from the Express application
* @param {CallbackFunction} next - The request callback function. This MUST be called, or else the request will stall.
* @param {external:express#Request} req - The request passed from the Express application
* @param {external:express#Response} res - The response passed from the Express application
* @param {requestCallback} next - The request callback function. This MUST be called, or else the request will stall.
* @returns {void}

@@ -317,2 +352,9 @@ */

if ((!res.hasParent && !res.model) || (res.hasParent && !res.parentModel)) {
res.rg.log.debug('No model. Skipping update and returning 404.');
res.errors.push(res.rg.ERR.NOT_FOUND());
return next();
}
if (res.hasParent) {

@@ -329,2 +371,3 @@ _updateRelationship(next);

* Hook called on DELETE requests. Removes the model from the database. Cannot be overwritten with RouteMap.prototype.extend()
* @private
* @param req

@@ -377,2 +420,8 @@ * @param res

if ((!res.hasParent && !res.model) || (res.hasParent && !res.parentModel)) {
res.rg.log.debug('No model. Skipping remove and returning 404.');
res.errors.push(res.rg.ERR.NOT_FOUND());
return next();
}
if (res.hasParent) {

@@ -389,8 +438,5 @@ _deleteRelationship(next);

* Middleware called after the model has been removed in a DELETE request. Can be overwritten with [RouteMap.extend()]{@link RouteMap.extend}
* @public
* @memberof RouteMap
* @method
* @param {ExpressRequestObject} req - The request passed from the Express application
* @param {ExpressResponseObject} res - The response passed from the Express application
* @param {CallbackFunction} next - The request callback function. This MUST be called, or else the request will stall.
* @param {external:express#Request} req - The request passed from the Express application
* @param {external:express#Response} res - The response passed from the Express application
* @param {requestCallback} next - The request callback function. This MUST be called, or else the request will stall.
* @returns {void}

@@ -405,8 +451,5 @@ */

* Middleware called on after a new model has been created in a POST request. The new document can be found under `res.model`. Overwrite this method with [RouteMap.extend()]{@link RouteMap.extend}
* @public
* @memberof RouteMap
* @method
* @param {ExpressRequestObject} req - The request passed from the Express application
* @param {ExpressResponseObject} res - The response passed from the Express application
* @param {CallbackFunction} next - The request callback function. This MUST be called, or else the request will stall.
* @param {external:express#Request} req - The request passed from the Express application
* @param {external:express#Response} res - The response passed from the Express application
* @param {requestCallback} next - The request callback function. This MUST be called, or else the request will stall.
* @returns {void}

@@ -421,8 +464,5 @@ */

* Middleware called on PATCH requests after a model has been updated. The updated model can be found under `res.model`. Overwrite this with [RouteMap.extend()]{@link RouteMap.extend}
* @public
* @memberof RouteMap
* @method
* @param {ExpressRequestObject} req - The request passed from the Express application
* @param {ExpressResponseObject} res - The response passed from the Express application
* @param {CallbackFunction} next - The request callback function. This MUST be called, or else the request will stall.
* @param {external:express#Request} req - The request passed from the Express application
* @param {external:express#Response} res - The response passed from the Express application
* @param {requestCallback} next - The request callback function. This MUST be called, or else the request will stall.
* @returns {void}

@@ -504,5 +544,2 @@ */

// TODO Get includes working properly
//return next();
if (!req.query.include) {

@@ -520,3 +557,2 @@ return next();

res.model = items;
next();

@@ -540,6 +576,6 @@ });

* @private
* @param req
* @param res
* @param next
* @returns {*}
* @param {external:express#Request} req
* @param {external:express#Response} res
* @param {requestCallback} next
* @returns {void}
*/

@@ -583,7 +619,7 @@ RouteMap.prototype.setupResponse = function(req, res, next) {

* @public
* @memberof RouteMap
* @memberof module:restful-goose/route-map
* @method
* @param {ExpressRequestObject} req - The request passed from the Express application
* @param {ExpressResponseObject} res - The response passed from the Express application
* @param {CallbackFunction} next - The request callback function. This MUST be called, or else the request will stall.
* @param {external:express#Request} req - The request passed from the Express application
* @param {external:express#Response} res - The response passed from the Express application
* @param {requestCallback} next - The request callback function. This MUST be called, or else the request will stall.
* @returns {void}

@@ -598,2 +634,3 @@ */

* Private middleware that sends the actual response, but only if the res.errors array is empty. Otherwise exits out of the event loop. This method cannot be overwritten with RouteMap.extend()
* @memberof module:restful-goose/route-map
* @private

@@ -619,2 +656,3 @@ * @param req

/** RouteMap */
module.exports = Object.create(RouteMap.prototype);
{
"name": "restful-goose",
"version": "2.2.3",
"description": "A new improved version of your favorite API framework for mongoose/MongoDB",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/mocha test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/joeyfromspace/restful-goose.git"
},
"keywords": [
"api",
"rest",
"mongoose",
"mongodb",
"microservice",
"route",
"mvc",
"model"
],
"author": "Joey Lappin <joey@joeyfromspace.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/joeyfromspace/restful-goose/issues"
},
"homepage": "https://github.com/joeyfromspace/restful-goose#readme",
"dependencies": {
"async": "2.1.5",
"body-parser": "1.16.1",
"express": "4.14.1",
"lodash": "4.17.4",
"moment": "2.17.1",
"pluralize": "3.0.0",
"winston": "2.3.1"
},
"devDependencies": {
"chai": "3.5.0",
"chai-http": "3.0.0",
"debug": "2.2.0",
"faker": "3.1.0",
"istanbul": "^0.4.5",
"jsdoc": "3.4.0",
"mocha": "3.0.1",
"mongoose": "4.8.5"
}
}
"name": "restful-goose",
"version": "2.2.4",
"description": "A new improved version of your favorite API framework for mongoose/MongoDB",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/mocha test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/joeyfromspace/restful-goose.git"
},
"keywords": [
"api",
"rest",
"mongoose",
"mongodb",
"microservice",
"route",
"mvc",
"model"
],
"author": "Joey Lappin <joey@joeyfromspace.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/joeyfromspace/restful-goose/issues"
},
"homepage": "https://github.com/joeyfromspace/restful-goose#readme",
"dependencies": {
"async": "2.1.5",
"body-parser": "1.16.1",
"express": "4.14.1",
"lodash": "4.17.4",
"moment": "2.17.1",
"pluralize": "3.0.0",
"winston": "2.3.1"
},
"devDependencies": {
"chai": "3.5.0",
"chai-http": "3.0.0",
"debug": "2.2.0",
"del": "^2.2.2",
"faker": "3.1.0",
"gulp": "^3.9.1",
"gulp-bump": "^2.7.0",
"gulp-istanbul": "^1.1.1",
"gulp-jsdoc3": "^1.0.1",
"gulp-mocha": "3.0.1",
"gulp-util": "^3.0.8",
"gulp-version-number": "^0.1.6",
"istanbul": "^0.4.5",
"jsdoc": "3.4.0",
"mocha": "3.0.1",
"mongoose": "4.8.5",
"semver": "^5.3.0",
"yargs": "^7.1.0"
}
}

@@ -5,3 +5,3 @@ # RESTful Goose

Version: 2.2.22
Version: ${VERSION}

@@ -11,2 +11,6 @@ ![TravisCI](https://travis-ci.org/joeyfromspace/restful-goose.svg?branch=master)

## What's New
### 2.2.3
- Fixed include bug where the dependent documents were not being returned in the response
- Fixed crashing when trying to DELETE or UPDATE a non-existent model
### 2.2.22

@@ -13,0 +17,0 @@ - Removed morgan middleware on api sub-app

@@ -16,2 +16,10 @@ /* globals describe, before, after, it */

after(function (done) {
connection.db.dropDatabase(function () {
connection.close(function () {
done();
});
});
});
describe('define route', function() {

@@ -18,0 +26,0 @@ 'use strict';

@@ -13,2 +13,10 @@ /* globals describe, before, after, it */

after(function (done) {
connection.db.dropDatabase(function () {
connection.close(function () {
done();
});
});
});
describe('error handling', function() {

@@ -122,2 +130,13 @@ 'use strict';

});
it('should return a 500 error when db is disconnected on /error-tests GET', function (done) {
connection.close(function () {
chai.request(app)
.get('/error-tests')
.end(function (err, res) {
expect(res.status).to.equal(500);
done();
});
});
});
});

@@ -12,2 +12,10 @@ var helpers = require('../lib/helpers');

after(function (done) {
connection.db.dropDatabase(function () {
connection.close(function () {
done();
});
});
});
describe('helper.serialize()', function() {

@@ -14,0 +22,0 @@ 'use strict';

@@ -7,2 +7,10 @@ /* globals describe, before, after, it */

after(function (done) {
connection.db.dropDatabase(function () {
connection.close(function () {
done();
});
});
});
describe('initialization tests', function() {

@@ -9,0 +17,0 @@ 'use strict';

@@ -18,2 +18,10 @@ /* globals describe, before, after, it */

after(function (done) {
connection.db.dropDatabase(function () {
connection.close(function () {
done();
});
});
});
describe('router', function() {

@@ -143,2 +151,3 @@ 'use strict';

expect(res.body).to.have.property('included');
expect(res.body).to.have.property('data');
expect(res.body.included).to.be.a('array');

@@ -145,0 +154,0 @@ expect(res.body.included.length).to.equal(sampleItem.subs.length);

Sorry, the diff of this file is not supported yet

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