Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/random-guys/siber


https://github.com/random-guys/siber

dotenv expressjs inversify-express inversifyjs joi library

Last synced: 16 days ago
JSON representation

Awesome Lists containing this project

README

        

# 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`

```ts
export class MyController extends Controller {
@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`

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

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

Finally, in your `app.ts`

```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`