(req: Request, _: Response, next: NextFunction)
| 23 | } |
| 24 | |
| 25 | export async function instanceExistsGuard(req: Request, _: Response, next: NextFunction) { |
| 26 | if (req.originalUrl.includes('/instance/create') || req.originalUrl.includes('/instance/fetchInstances')) { |
| 27 | return next(); |
| 28 | } |
| 29 | |
| 30 | const param = req.params as unknown as InstanceDto; |
| 31 | if (!param?.instanceName) { |
| 32 | throw new BadRequestException('"instanceName" not provided.'); |
| 33 | } |
| 34 | |
| 35 | if (!(await getInstance(param.instanceName))) { |
| 36 | throw new NotFoundException(`The "${param.instanceName}" instance does not exist`); |
| 37 | } |
| 38 | |
| 39 | next(); |
| 40 | } |
| 41 | |
| 42 | export async function instanceLoggedGuard(req: Request, _: Response, next: NextFunction) { |
| 43 | if (req.originalUrl.includes('/instance/create')) { |
nothing calls this directly
no test coverage detected