Commit 2714d13c authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Update some parameters types

parent 3573f260
Pipeline #2363 passed with stages
in 5 minutes and 45 seconds
......@@ -18,9 +18,9 @@
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json",
"webpack": "webpack --config webpack.config.js",
"typeorm:generate": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate -n",
"typeorm:migrate": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run",
"typeorm:revert": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:revert",
"typeorm:generate": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate -n",
"typeorm:migrate": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run",
"typeorm:revert": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:revert",
"typeorm:migrate-ci": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run"
},
"dependencies": {
......
......@@ -32,7 +32,7 @@ export class OrganizationsController {
@ApiOperation({ title: 'Get one organization' })
@ApiResponse({ status: 200, description: 'Return one organization.', type: Organization })
@Get(':id')
findOne(@Param('id') id: number, @Req() req): Promise<Organization> {
findOne(@Param('id') id: string, @Req() req): Promise<Organization> {
const userGroups = req.headers[this._configService.config.groupHeader] ?
req.headers[this._configService.config.groupHeader].split(',').map(e => e.trim()) :
[];
......@@ -41,7 +41,7 @@ export class OrganizationsController {
@ApiResponse({ status: 200, description: 'Return the links of an organization.', type: LinkEntity, isArray: true })
@Get(':id/links')
findLinks(@Param('id') id: number, @Req() req): Promise<LinkEntity[]> {
findLinks(@Param('id') id: string, @Req() req): Promise<LinkEntity[]> {
const userGroups = req.headers[this._configService.config.groupHeader] ?
req.headers[this._configService.config.groupHeader].split(',').map(e => e.trim()) :
[];
......@@ -64,7 +64,7 @@ export class OrganizationsController {
@ApiResponse({ status: 403, description: 'User does not have sufficient rights.' })
@Put(':id')
@Groups('admin')
update(@Param('id') id: number, @Body() organizationDTo: OrganizationDTO) {
update(@Param('id') id: string, @Body() organizationDTo: OrganizationDTO) {
return this.organizationsService.update(id, organizationDTo);
}
......@@ -75,7 +75,7 @@ export class OrganizationsController {
@HttpCode(204)
@Delete(':id')
@Groups('admin')
delete(@Param('id') id: number) {
delete(@Param('id') id: string) {
return this.organizationsService.delete(id);
}
}
......@@ -75,8 +75,12 @@ export class OrganizationsService {
this.logger.log('Entering function', `${OrganizationsService.name} - ${this.findOne.name}`);
const organization = await this.organizationRepository.findOne(id).catch((error) => {
this.logger.error(`Error while looking the organization with id ${id}.`, `${error}`, `${OrganizationsService.name} - ${this.findOne.name}`);
throw new InternalServerErrorException({ error, message: 'Error while looking the organization with id ${id}.' });
this.logger.error(
`Error while looking for the organization with id ${id}.`,
`${error}`,
`${OrganizationsService.name} - ${this.findOne.name}`,
);
throw new InternalServerErrorException({ error, message: 'Error while looking for the organization with id ${id}.' });
});
if (!organization) {
......@@ -85,7 +89,7 @@ export class OrganizationsService {
// Only admin can see an unpublished data producer
if ((!userGroups || !userGroups.includes(this._configService.config.groupNames.admin)) && organization.published === false) {
throw new ForbiddenException({ message: 'You don\'t have access to this data producer' });
throw new ForbiddenException({ message: 'You don\'t have access to this organization.' });
}
return organization;
......@@ -111,7 +115,7 @@ export class OrganizationsService {
// Only admin can see an unpublished data producer
if ((!userGroups || !userGroups.includes(this._configService.config.groupNames.admin)) && organization.published === false) {
throw new ForbiddenException({ message: 'You don\'t have access to this data producer' });
throw new ForbiddenException({ message: 'You don\'t have access to this organization' });
}
return organization.links;
......@@ -154,7 +158,11 @@ export class OrganizationsService {
this.logger.log('Entering function', `${OrganizationsService.name} - ${this.update.name}`);
const toUpdate = await this.organizationRepository.findOne(id).catch((error) => {
this.logger.error(`Error while looking for the organization with the id ${id}.`, `${error}`, `${OrganizationsService.name} - ${this.update.name}`);
this.logger.error(
`Error while looking for the organization with the id ${id}.`,
`${error}`,
`${OrganizationsService.name} - ${this.update.name}`,
);
throw new InternalServerErrorException({ error, message: 'Error while looking for the organization.' });
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment