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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 9x 9x 9x 9x 9x 38x 38x 38x 38x 38x 2x 2x 2x 38x 1x 1x 38x 2x 2x 2x 2x 1x 1x 1x | import { Injectable } from '@nestjs/common';
import {
SiteTableKeySchema,
SiteConnection,
Site,
CreateSiteInput,
} from '../types.d';
import { EnvironmentService, DynamodbService } from '../common_services';
import { DeviceService } from '../devices';
import { SiteDb } from './siteDb';
@Injectable()
export class SiteService {
siteDb: SiteDb;
constructor(
private readonly envService: EnvironmentService,
private readonly dynamodbService: DynamodbService,
private readonly deviceService: DeviceService,
) {
this.siteDb = new SiteDb(
this.envService.siteTableName,
dynamodbService.documentClient,
envService.deviceTableName,
envService.siteUuidGsi,
);
}
getSites = async (
accessToken: string,
limit: number,
nextToken?: SiteTableKeySchema,
): Promise<SiteConnection> => {
const entityUuid = await this.deviceService.getEntityUuidByAccessToken(
accessToken,
);
return this.siteDb.getSites(entityUuid, limit, nextToken);
};
getSite = async (accessToken: string, siteUuid: string): Promise<Site> => {
const entityUuid = await this.deviceService.getEntityUuidByAccessToken(
accessToken,
);
return this.siteDb.getSite(entityUuid, siteUuid);
};
createSite = async (
accessToken: string,
event: CreateSiteInput,
): Promise<boolean> => {
try {
const entityUuid = await this.deviceService.getEntityUuidByAccessToken(
accessToken,
);
await this.siteDb.createSite(entityUuid, event);
return true;
} catch (err) {
console.log(err);
return false;
}
};
}
|