lynx-framework
Version:
lynx is a NodeJS framework for Web Development, based on decorators and the async/await support.
25 lines (22 loc) • 797 B
text/typescript
import { Request as ERequest, Response as EResponse } from 'express';
import Response from './response';
/**
*
* This class simply wrap the original Response class in order to add async/await
* functionality, improving code readability and maintenability.
*/
export default abstract class AsyncResponse extends Response {
/**
* Generate the correct response, injecting it to the standard Express response.
* @param req the standard Express request
* @param res the standard Express response
*/
abstract asyncResponse(req: ERequest, res: EResponse): Promise<void>;
performResponse(req: ERequest, res: EResponse) {
this.asyncResponse(req, res)
.then(() => {})
.catch((err) => {
throw err;
});
}
}