Skip to content

Commit

Permalink
provider sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed May 18, 2024
1 parent 7814a7a commit 5b641a5
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/features/provider/provider.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,46 @@ export class ProviderController {
body.nestProviderId,
);
} catch (e) {
body;
throw new ServerError(e.message, e.status);
}
return relation;
}

@Get('need/:needId')
@ApiSecurity('flask-access-token')
@ApiHeader({
name: 'flaskId',
description: 'to use cache and flask authentication',
required: true,
})
@ApiOperation({ description: 'Create one provider' })
async getProviderByNeed(
@Req() req: Request,
@Param('needId') needId,
): Promise<ProviderEntity> {
const panelFlaskUserId = req.headers['panelFlaskUserId'];
const panelFlaskTypeId = req.headers['panelFlaskTypeId'];
if (!isAuthenticated(panelFlaskUserId, panelFlaskTypeId)) {
throw new ForbiddenException('You Are not authorized');
}
let provider: ProviderEntity;
try {
const relation = await this.providerService.getProviderNeedRelationById(
needId,
);
if (relation) {
provider = await this.providerService.getProviderById(
relation.nestProviderId,
);
return provider;
} else {
throw new BadRequestException('No provider relation for this need');
}
} catch (e) {
throw new ServerError(e.message, e.status);
}
}

@Post('add')
@ApiSecurity('flask-access-token')
@ApiHeader({
Expand Down

0 comments on commit 5b641a5

Please sign in to comment.