-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetRoundsAdayLast30DaysRouter.ts
25 lines (24 loc) · 1.22 KB
/
getRoundsAdayLast30DaysRouter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { ExpressToolkit } from '@oats-ts/openapi-express-server-adapter';
import { RawHttpResponse, ServerAdapter } from '@oats-ts/openapi-http';
import { NextFunction, Request, Response, Router } from 'express';
import { StatsServiceApi } from '../api/StatsServiceApi';
export const getRoundsAdayLast30DaysRouter: Router = Router().get(
'/rounds/count-a-day-last-30-days',
async (request: Request, response: Response, next: NextFunction): Promise<void> => {
const toolkit: ExpressToolkit = { request, response, next };
const configuration: ServerAdapter<ExpressToolkit> = response.locals['__oats_configuration'];
const api: StatsServiceApi<ExpressToolkit> = response.locals['__oats_api'];
try {
const typedResponse = await api.getRoundsAdayLast30Days(toolkit);
const rawResponse: RawHttpResponse = {
headers: await configuration.getResponseHeaders(toolkit, typedResponse, undefined),
statusCode: await configuration.getStatusCode(toolkit, typedResponse),
body: await configuration.getResponseBody(toolkit, typedResponse),
};
return configuration.respond(toolkit, rawResponse);
} catch (error) {
configuration.handleError(toolkit, error);
throw error;
}
},
);