Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 26 27 28 29 30 31 32 33 34 35 36 | 4x 4x 4x 4x 4x 1x 1x 1x 1x 4x 1x 1x 1x 1x 4x 1x 1x 1x | import {
withMiddlewares,
bootstrapNestJSMiddleware,
} from '@npco/component-core';
import { Handler, Context } from 'aws-lambda';
import { AppModule } from '../appModule';
import { SiteService } from '../site';
import { SitesQueryInput, AppAccessContext, SiteQueryInput, CreateSiteInput } from '../types.d';
import { logMiddleware, accessTokenMiddleware, checkDeviceStatusMiddleware } from '../middlewares';
export const getSitesHandler: Handler = withMiddlewares(
async (event: { args: SitesQueryInput }, context: Context) => {
const { app, accessToken } = context as AppAccessContext;
const { limit, nextToken } = event.args;
return app.get(SiteService).getSites(accessToken, limit, nextToken);
},
[logMiddleware, bootstrapNestJSMiddleware(AppModule), accessTokenMiddleware, checkDeviceStatusMiddleware],
);
export const getSiteHandler: Handler = withMiddlewares(
async (event: { args: SiteQueryInput }, context: Context) => {
const { app, accessToken } = context as AppAccessContext;
const { siteUuid } = event.args;
return app.get(SiteService).getSite(accessToken, siteUuid);
},
[logMiddleware, bootstrapNestJSMiddleware(AppModule), accessTokenMiddleware, checkDeviceStatusMiddleware],
);
export const createSiteHandler: Handler = withMiddlewares(
async (event: { args: { input: CreateSiteInput } }, context: Context) => {
const { app, accessToken } = context as AppAccessContext;
return app.get(SiteService).createSite(accessToken, event.args.input);
},
[logMiddleware, bootstrapNestJSMiddleware(AppModule), accessTokenMiddleware],
);
|