Socket
Book a DemoInstallSign in
Socket

api-endpoint

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-endpoint

EndPoint is a schema-validated waterfall.

1.0.11
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

EndPoint

EndPoint is a schema-validated waterfall.

What does an endpoint look like?

var EndPoint = require('api-endpoint'),
    Joi = EndPoint.Joi;

var myEndpoint = EndPoint.create({
    headers: Joi.object(), // Headers validator

    payload: Joi.object(), // Payload validator

    query: Joi.object(), // Query string validator

    params: Joi.object(), // URL string validator

    response: Joi.object(), // Response validator

    validateOptions: { // optional JOI validation options
        abortEarly: false,
        stripUnknown: true
    },

    filters: [ // An array of work to perform
        function findUser(data, next) {
            next(err || null, data);
        },
        function createTask(data, next) {
            next(err || null, data);
        }
    ]
});

module.exports = endpoint;

How do I run my endpoint?

myEndpoint.run(data, function(err, data) {
    console.log(err, data); // `data` is the final object scoped to the outgoing schema
})

How do I deal with errors?

Your endpoint is a waterfall. If any of your filters error, your endpoint will run its callback function with the error you provide (data will be null).

Keywords

endpoint

FAQs

Package last updated on 24 May 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.