@random-guys/siber
TypeScript icon, indicating that this package has built-in type declarations

0.15.1 • Public • Published

siber

Controllers as classes. This lib abstracts away the internals of controllers.

How to install?

yarn add @random-guys/siber

Also, you need yarn add inversify-express-utils

How does it work?

my.controller.ts

export class MyController extends Controller<MyResponseType> {
  @httpGet('/', myMiddleWare)
  async getData(@request() req: Request, @response() res: Response) {
    try {
      // ...do somethings
      this.handleSuccess(req, res, myResponse);
    } catch (err) {
      this.handleError(req, res, err);
    }
  }
}

In your ioc.ts

import { Container } from 'inversify';
import './my.controller.ts';

const container = new Container();
export default container;

Finally, in your app.ts

const server = new InversifyExpressServer(container, null);
.server.setConfig((app: Application) => {
  siber.buildInto(app, logger, {
    cors: false,
    jsend: true,
    tracking: true
  })
})

TODO

  • [ ] Tests
  • [ ] Refactor filesystem structure
  • [ ] Removed dependency on JSend
  • Move integration code to new packages
    • [ ] siber-bucket
    • [ ] siber-provcs

Readme

Keywords

none

Package Sidebar

Install

npm i @random-guys/siber

Weekly Downloads

2

Version

0.15.1

License

MIT

Unpacked Size

38.1 kB

Total Files

24

Last publish

Collaborators

  • random-guys