Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.CreateAudit])
@post('/audit-logs', {
responses: {
'200': {
description: 'AuditLog model instance',
content: {'application/json': {schema: {'x-ts-type': AuditLog}}},
},
},
})
async create(@requestBody() auditLog: AuditLog): Promise {
return await this.auditLogRepository.create(auditLog);
}
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.ViewAudit])
@get('/audit-logs/count', {
responses: {
'200': {
description: 'AuditLog model count',
content: {'application/json': {schema: CountSchema}},
},
},
})
async count(
@param.query.object('where', getWhereSchemaFor(AuditLog))
where?: Where,
): Promise {
return await this.auditLogRepository.count(where);
}
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.ViewTenant])
@get('/tenants/{id}', {
responses: {
'200': {
description: 'Tenant model instance',
content: {'application/json': {schema: {'x-ts-type': Tenant}}},
},
},
})
async findById(@param.path.number('id') id: number): Promise {
return await this.tenantRepository.findById(id);
}
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.UpdateTenant])
@patch('/tenants/{id}', {
responses: {
'204': {
description: 'Tenant PATCH success',
},
},
})
async updateById(
@param.path.number('id') id: number,
@requestBody() tenant: Tenant,
): Promise {
await this.tenantRepository.updateById(id, tenant);
}
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.UpdateRole])
@patch('/roles/{id}', {
responses: {
'204': {
description: 'Role PATCH success',
},
},
})
async updateById(
@param.path.number('id') id: number,
@requestBody() role: Role,
): Promise {
await this.roleRepository.updateById(id, role);
}
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.UpdateRole])
@put('/roles/{id}', {
responses: {
'204': {
description: 'Role PUT success',
},
},
})
async replaceById(
@param.path.number('id') id: number,
@requestBody() role: Role,
): Promise {
await this.roleRepository.replaceById(id, role);
}
@authenticate(STRATEGY.BEARER)
@authenticate(STRATEGY.BEARER)
@authorize([PermissionKey.CreateAnyUser, PermissionKey.CreateTenantUser])
@post('/users', {
responses: {
'200': {
description: 'User model instance',
content: {'application/json': {schema: {'x-ts-type': User}}},
},
},
})
async create(@requestBody() user: User): Promise {
return await this.userRepository.create(user);
}
@authenticate(STRATEGY.BEARER)
@authorize([
PermissionKey.ViewAnyUser,
PermissionKey.ViewOwnUser,
PermissionKey.ViewTenantUser,
])
@get('/users/count', {
responses: {
'200': {
description: 'User model count',
content: {'application/json': {schema: CountSchema}},
},
},
})
async count(
@param.query.object('where', getWhereSchemaFor(User)) where?: Where,
): Promise {