orzjs

0.0.6 • Public • Published

orzjs

介绍

orzjs 是对koa koa-router 的简单封装

软件架构

软件架构说明

安装教程

npm i orzjs
或
yarn add orzjs

使用说明

模板结构

.
├── config
│   └── middleware.js
├── controller
│   └── api.js
└── app.js
  1. app.js
import Micro from ('orzjs');
import middleware from './config/middleware';

const app = new Application({
  srcPath: __dirname,
  middleware,
});

app.run();
  1. middleware.js
import cors from '@koa/cors';
import error from 'koa-error';
import helmet from 'koa-helmet';
import body from 'koa-body';
import logger from 'koa-logger';

export default {
  helmet: () => helmet(),
  error: () => error(),
  cors: () => cors(),
  body: () => body({
    multipart: true,
    formidable: {
      maxFileSize: 1024 * 1024 * 1024,
    },
  }),
  logger: () => logger(),
};
  1. api.js
import {
  Controller, GET,POST,PUT,DELETE
} from '../../libs/decorator';

@Controller('/api')
class ApiController {
  @GET('/get')
  // @GET('/get1')
  getAction() {
    return 'this is get!';
  }

  // @POST('/post')
  // postAction() {
  //   return (ctx) => ctx.body = 'this is post!';
  // }

  // @PUT('/put')
  // putAction() {
  //   return (ctx) => ctx.body = 'this is put!';
  // }

  // @DELETE('/delete')
  // deleteAction() {
  //   return (ctx) => ctx.body = 'this is delete!';
  // }
}
export default ApiController;

Readme

Keywords

none

Package Sidebar

Install

npm i orzjs

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

13.3 kB

Total Files

18

Last publish

Collaborators

  • sixlib