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

syncano-middleware

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syncano-middleware

Middleware provide a convenient mechanism for filtering HTTP requests entering your socket.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

XO code style CircleCI codecov

Syncano Middleware

Syncano middleware provide a convenient mechanism for filtering HTTP requests entering your socket. For example validate passed parameters, check if user is authenticated, assign default parameter values and many more.

For full list of middlewares check NPM.

Getting started

Installing from NPM

npm install syncano-middleware --save

Usage

import middleware from 'syncano-middleware';

// Example middlewares.
const steps = {
  auth: () => new Promise((resolve, reject) => {
    // Your user authentication logic...
    resolve(user)
  }),
  validate: () => new Promise((resolve, reject) => {
    // Your validation logic...
    resolve(formFields)
  })
}

middleware([ steps.auth, steps.validate ])
  .then(data => {
    // All middlewares passed.
    // Now you have an authenticated user and validated form.

    const [ user, fields ] = data
  })
  .const(err => {
    // An error occurred in one of middlewares.
    // You can handle that here.
  })


Custom middlewares

Middleware must be a function that returns a Promise:

  function MyAwesomeMiddleware() {
    return new Promise((resolve, reject) => {
      // Your awesome middleware implmentation...
      // ...
      // resolve(data)
      // or
      // reject('An error message or data')
    })
  }

Keywords

FAQs

Package last updated on 11 Feb 2017

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