New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

express-dumb-api-handler

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

express-dumb-api-handler

A really dumb API response handler.

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

express-api-handler

A really dumb API handler to make your responses consistent.

Example

(click here for the full example)


// ....

function succeedAtWork() {
  return new rsvp.Promise(function succeed(resolve) {
    var withSomeData = {
      'i': 'am',
      'successful': 'data'
    };

    resolve(withSomeData);
  });
}

function failAtWork() {
  return new rsvp.Promise(function succeed(resolve) {
    var withAnErrorMessage = 'You failed';

    reject(withAnErrorMessage); // This could be an object; whatever, doesn't matter.
  });
}

myApp.get('/success', function success(request, response) {
  var dumbAPI = new DumbAPI(response);

  // See, now it's simple when your function resolves or rejects the thing
  // you want your API to return
  succeedAtWork().then(dumbAPI.sendSuccess, dumbAPI.sendError);
});

myApp.get('/failure', function failure(request, response) {
  var dumbAPI = new DumbAPI(response);
  failAtWork().then(dumbAPI.sendSuccess, dumbAPI.sendFailure);
});


// ...

Keywords

express

FAQs

Package last updated on 11 Aug 2015

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