npm

Need private packages and team management tools?Check out npm Orgs. »

magnet-router

3.3.0 • Public • Published

Usage

All router api should refer koa-router

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';

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

server/controllers/user.js

export default function user({ router }) {
  router

  .get('/users', async function (ctx) {
    ctx.body = [];
  })

  .post('/user', async function (ctx) {
    ctx.body = ctx.request.body;
  })

  .put('/user/:userId', async function (ctx) {
    ctx.body = ctx.params;
  })

  .get('/user/:userId', async function (ctx) {
    ctx.body = ctx.query;
  });
}

install

npm i magnet-router

Downloadsweekly downloads

11

version

3.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability