All files / src/controllers/public transport.controller.ts

86.67% Statements 13/15
100% Branches 0/0
0% Functions 0/1
84.62% Lines 11/13

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 691x 1x 1x   1x 1x 1x 1x 1x   1x                                                                                 1x                 1x                
import { authenticate } from '@loopback/authentication';
import { Constructor, service } from '@loopback/core';
import { api, oas } from '@loopback/rest';
 
import { BaseController, MixinOptions, ExtendOptions, createBaseControllerFactory } from '@logchain/controllers';
import { Module, Constants } from '@logchain/configs';
import { TransportDto } from '@logchain/dtos';
import { Transport } from '@logchain/models';
import { TransportService } from '@logchain/services';
 
const options: MixinOptions = {
  basePath: '/transports',
  modelClass: Transport,
  modelDtoClass: TransportDto,
  admin: false,
  schemaOptions: {
    updateById: {
      exclude: [
        'flow_id',
        'journey_point_id',
        'flow_action_id',
        'is_pdf_created',
        'company_id',
        'driven_by',
        'production_location_id',
        'expected_arrival_time',
        'actual_start_time',
        'actual_end_time',
      ],
      authorize: {
        resource: Module.LogChain.TransportMgmt,
        scopes: [Constants.AccessScope.Update],
      },
    },
    findById: {
      exclude: [],
      authorize: {
        resource: Module.LogChain.TransportMgmt,
        scopes: [Constants.AccessScope.Retrieve],
      },
    },
    find: {
      exclude: [],
      authorize: {
        resource: Module.LogChain.TransportMgmt,
        scopes: [Constants.AccessScope.Retrieve],
      },
    },
  },
};
 
const extendOptions: ExtendOptions = {
  isExtendRead: true,
  isExtendReadById: true,
  isExtendUpdateById: true,
};
 
@oas.tags('Transports')
@api({ basePath: '/' })
@authenticate('aws-cognito')
export class TransportController extends createBaseControllerFactory<Transport, Constructor<BaseController>>(BaseController, options, extendOptions) {
  constructor(
    @service(TransportService)
    public selfService: TransportService,
  ) {
    super();
  }
}