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

node-api-message

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-api-message

node-api-message

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

##node-api-message

Please Share on Twitter if you like #NodeAPIMessage

##Description Node-API-Message is an ExpressJS extension that allows you to create API messages that are consistent across your application. These messages are stored in a MongoDB using Mongoose so that you can track all API messages within your application.

##Installation npm install node-api-message --save

##Usage

####Initialization After initializing node-api-message you will have a new method available on your express response objects.

var mongoose  = require('mongoose').createConnection('mongodb://localhost:3001/TestingDB');
var apiMessage = require('node-api-message').initialize(mongoose);
//Tell express to use apiMessage
express.use(apiMessage);

####apiMessage

var Status = require('node-api-message').Status;
app.get('/something', function(req, res){
    res.apiMessage(Status.OK, 'some message here', { data: 'data'});
});

Status: A valid HTTP Status code.

Message: A message to be returned with the response object. This Message is used as the key for uniqueness in MongoDB.

Data: Optional data to be sent with the response. This data is not saved in MongoDB.

The output from the above message would look like this.

{
    data: { data: 'data' },
    code: 2000000,
    status: 200,
    message: 'some message here',
    href: '/apimessages/2000000',
    type: 'apimessage'
}

##Contributing

  1. Fork the git repository
  2. Add some awesome code
  3. Add some awesome tests
  4. Run the tests and jshint using the grunt command
  5. Create a Pull Request

##ChangeList ####0.0.2 Added Documentation to README.md file ####0.0.1 Initial Commit

Please Share on Twitter if you like #NodeAPIMessage

Keywords

FAQs

Package last updated on 19 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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