All files / src/controllers/public flow-alert.controller.ts

70% Statements 14/20
100% Branches 0/0
0% Functions 0/2
66.67% Lines 12/18

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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 781x 1x   1x   1x 1x 1x   1x 1x   1x                                                       1x             1x                             1x                              
import { authenticate } from '@loopback/authentication';
import { Constructor, intercept, service } from '@loopback/core';
import { Where } from '@loopback/repository';
import { get, getWhereSchemaFor, oas, param, } from '@loopback/rest';
 
import { createBaseControllerFactory, BaseController, ExtendOptions, MixinOptions, } from '@logchain/controllers';
import { EnsurePagingCorrectInterceptor, serialize } from '@logchain/interceptors';
import { buildResponseObject, limitSpec, offsetSpec, qSpec, sortSpec, } from '@logchain/apidefs';
import { Flow, Verification } from '@logchain/models';
import { FlowAlertService } from '@logchain/services';
import { VerificationView } from '@logchain/models/views';
 
const options: MixinOptions = {
  basePath: '/flows-alerts',
  modelClass: VerificationView,
  modelDtoClass: VerificationView,
  admin: true,
  schemaOptions: {
    updateById: {
      exclude: [
        'flow_id',
        'flow_journey_point_id',
        'flow_action_id',
        'form_id',
        'verification_id',
        'is_actor',
      ],
      authorize: {},
    },
    findById: {
      exclude: [],
      authorize: {},
    },
    find: {
      exclude: [],
      authorize: {},
    },
  },
};
 
const extendOptions: ExtendOptions = {
  isExtendReadById: true,
  isExtendUpdateById: true,
}
 
@oas.tags('Flow Alerts')
@authenticate('aws-cognito')
export class FlowAlertController extends createBaseControllerFactory<Verification, Constructor<BaseController>>(BaseController, options, extendOptions) {
  constructor(
    @service(FlowAlertService)
    public selfService: FlowAlertService,
  ) {
    super();
  }
 
  @get(`${options.basePath}`, {
    responses: {
      '200': buildResponseObject(options.modelDtoClass, options.admin),
    },
  })
  @intercept(EnsurePagingCorrectInterceptor.BINDING_KEY)
  @intercept(serialize(VerificationView))
  async find(
    @param(offsetSpec) offset: number,
    @param(limitSpec) limit: number,
    @param(sortSpec) sort: Array<string>,
    @param(qSpec) q: string,
    @param.query.object('where', getWhereSchemaFor(options.modelClass))
    where: Where<Flow>,
  ) {
    this.selfService.buildBaseFilter(offset, limit, sort, where);
    await this.selfService.buildSearchQuery(q);
    await this.selfService.ensureRightAccessRecord();
    return this.selfService.find();
  }
}