0.0.6 • Published 6 years ago

get-auth-token-middleware v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Get auth token middleware

This is middleware handler for Express.js applications. It can authenticate application against third party service. Authentication result will be saved in context.result field for later usage.

// Initialize middleware
const http = require('http');
const GetAuthTokenMiddleware = require('get-auth-token-middleware');
const context = {
  endpoint: {
      hostname: 'localhost',
      port: 80,
      path: '/api/users/login',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      }
  },
  body: {
      login: 'root',
      password: 'P@ssw0rd'
  },
  result: {}
};
const middleware = new GetAuthTokenMiddleware(context, http);
const handler = middleware.handle.bind(middleware);

// Bind to Express.js app 
app.use(handler);

Returned response content will be attached to context.result.

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago