Socket
Book a DemoInstallSign in
Socket

ghost-express-router

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ghost-express-router

nodejs express router to handle authorization and permissioning for ghost express apps

latest
Source
npmnpm
Version
1.4.0
Version published
Weekly downloads
2
-33.33%
Maintainers
2
Weekly downloads
 
Created
Source

ghost-express-router

Code Climate Downloads

Router for ghost-express-server.

Install

$ npm install ghost-express-router

Usage

const Config = require('config');
const Joi = require('joi');
const GhostExpressServer = require('ghost-express-server');
const GhostExpressRouter = require('ghost-express-router');
const GhostRouteController = require('ghost-route-controller');
const Router = new GhostExpressRouter();

Router.configure([
  {
    method: 'GET',
    path: '/:id',
    auth: {
      plugin: 'bearerJwt',
      permissions: ['addressSelfFullAccess', 'addressAllFullAccess']
    },
    handler: GhostRouteController.get,
    validate: {
      params: { id: Joi.number().integer() }
    }
  }, {
    method: 'POST',
    path: '/',
    auth: {
      plugin: 'bearerJwt',
      permissions: ['addressSelfFullAccess', 'addressAllFullAccess']
    },
    handler: GhostRouteController.create,
    validate: {
      body: {
        name: Joi.string().required(),
        line1: Joi.string().required(),
        line2: Joi.string(),
        city: Joi.string().required(),
        state: Joi.string().required(),
        zip: Joi.string().regex(/^\d{5}(?:[-\s]\d{4})?$/).required(),
        phone: Joi.string(),
        allerganId: Joi.string()
      }
    }
  }, {
    method: 'PUT',
    path: '/:id',
    auth: {
      plugin: 'bearerJwt',
      permissions: ['addressSelfFullAccess', 'addressAllFullAccess']
    },
    handler: GhostRouteController.update,
    validate: {
      params: { id: Joi.number().integer().required() },
      body: {
        doc: {
          name: Joi.string().required(),
          line1: Joi.string().required(),
          line2: Joi.string(),
          city: Joi.string().required(),
          state: Joi.string().required(),
          zip: Joi.string().regex(/^\d{5}(?:[-\s]\d{4})?$/).required(),
          phone: Joi.string(),
          allerganId: Joi.string(),
          profileId: Joi.number().integer().required()
        }
      }
    }
  }, {
    method: 'DELETE',
    path: '/:id',
    auth: {
      plugin: 'bearerJwt',
      permissions: ['addressSelfFullAccess', 'addressAllFullAccess']
    },
    handler: GhostRouteController.delete,
    validate: {
      params: { id: Joi.number().integer().required() }
    }
  }
]);

GhostExpressServer.create(Config.get('server'))
.then(server => {
    server.useRouter(`/api/v1/addresses`, Router);
    return server
})
.then(server => server.start())

Keywords

ghost

FAQs

Package last updated on 20 Mar 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