ghost-express-router
nodejs express router to handle authorization and permissioning for ghost express apps
Last updated 3 years ago by njgerner .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ghost-express-router 
SYNC missed versions from official npm registry.

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())

Current Tags

  • 1.4.0                                ...           latest (3 years ago)

14 Versions

  • 1.4.0                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.5                                ...           3 years ago
  • 1.2.4                                ...           3 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (16)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |