magnet-respond

0.2.2 • Public • Published

Usage

Basic

import magnet from 'magnet-core';
import Config from 'magnet-config';
import Logger from 'magnet-bunyan';
import Server from 'magnet-spdy';
import Session from 'magnet-session';
import Router from 'magnet-router';
import Respond from 'magnet-respond';

let app = await magnet([Config, Logger, Server, Session, Respond, Router]);

controllers/todo.js

export default function todo({
  Joi,
  router,
  validation
}) {
  router

  .get(
    '/bookings',
    async function index(ctx) {
      try {
        ctx.body = await app.models.Booking.find().lean();
      } catch (err) {
        app.log.error(err);
        ctx.respond.internalServerError();
      }
    }
  )
}

Readme

Keywords

Package Sidebar

Install

npm i magnet-respond

Weekly Downloads

0

Version

0.2.2

License

MIT

Last publish

Collaborators

  • kievechua