Controllers as classes. This lib abstracts away the internals of controllers.
yarn add @random-guys/siber
Also, you need yarn add inversify-express-utils
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
})
})
- Tests
- Refactor filesystem structure
- Removed dependency on JSend
- Move integration code to new packages
-
siber-bucket
-
siber-provcs
-