Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/random-guys/siber
- Owner: random-guys
- Created: 2019-06-23T22:35:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T00:59:51.000Z (about 2 years ago)
- Last Synced: 2024-12-21T15:49:09.653Z (about 2 months ago)
- Topics: dotenv, expressjs, inversify-express, inversifyjs, joi, library
- Language: TypeScript
- Size: 1.03 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
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`