Example #1
0
  forEach(resouces, ({ prefix, routes }) => {
    const rtr = router()
    rtr.prefix(prefix)

    forEach(routes, route => {
      rtr.route(route)
    })

    debug('api')(`Added new resource ${prefix}`)

    app.use(convert(rtr.middleware()))
  })
Example #2
0
module.exports = function* (app) {
  costripe(this.config('stripe_sk'));

  if (this.config('stripe_sync')) {
    this.info('syncing stripe...');
    yield plans.sync;
    this.info('stripe sync complete.');
  }

  // KOA
  var payments = router();
  app.use(payments.middleware());

  // Routes
  payments.post('/subscribe', routes.createSubscription);

  return app;
}
Example #3
0
module.exports = function(app) {
    var api = {};
    var apiRoutes = [];
    var apiRouter = router();

    api.initialize = function() {
        services.load();
        routes.load(services);
        apiRoutes = routes.get();
        app.use(queryParser);
        registerRoutes();
    };

    function registerRoutes() {
        apiRoutes.forEach(function(route) {
            apiRouter.route(route);
        });

        app.use(apiRouter.middleware());
    }

    api.initialize();
};
/**
 * The `settings` API module that provides functionality to create, read, update and delete setting.
 *
 * @author    Martin Micunda {@link http://martinmicunda.com}
 * @copyright Copyright (c) 2015, Martin Micunda
 * @license   GPL-3.0
 */
'use strict';

import koa from 'koa';
import router from 'koa-joi-router';
import validator from './lib/validator';
import * as settingDAO from './lib/dao';

const app = koa();
const api = router();

const routes = [
    {
        method: 'GET',
        path: '/:id',
        validate: validator.findByID,
        handler: function *() {
            this.body = yield settingDAO.findByID(this.params.id);
        }
    },
    {
        method: 'GET',
        path: '/',
        validate : validator.find,
        handler: function *() {
/**
 * Created by Jordan on 6/26/2015.
 */
'use strict';

const Router    = require('koa-joi-router');
const Joi       = require('joi');

const router    = Router();

const secCtrl       = require('../controllers/security');
const reviewCtrl    = require('../controllers/review');

/**
 * @api {post} /bookings/:bookingId/reviews Post a review for a booking
 * @apiVersion 0.1.0
 * @apiName PostReview
 * @apiGroup Review
 * @apiPermission loggedIn
 * @apiUse loggedIn
 *
 * @apiParam {String} bookingId Booking unique id.
 * @apiParam {String} comment Review comment.
 * @apiParam {Number} hospitalityRating Review hospitality rating from 0 to 10.
 * @apiParam {Number} foodRating Review food rating from 0 to 10.
 *
 * @apiParamExample {json} Request-Example:
 *      {
 *          "comment": "Was so cool, would go again",
 *          "hospitalityRating": 5,
 *          "foodRating": 7
Example #6
0
const createRouter = route => {
   const rtr = router();
   [].concat(route || []).forEach(it => rtr.route(it));
   return rtr;
};
Example #7
0
const Router = require('koa-joi-router');
const Joi = Router.Joi;
const Api = require('../controller/api');

let api = Router();
api.post('/', {
    validate: {
        body: {
            name: Joi.string().max(30),
        },
        type: 'form',
        continueOnError: true
    },
}, Api.index);

module.exports = api;