MCPcopy Create free account
hub / github.com/evolution-foundation/evolution-api / instanceExistsGuard

Function instanceExistsGuard

src/api/guards/instance.guard.ts:25–40  ·  view source on GitHub ↗
(req: Request, _: Response, next: NextFunction)

Source from the content-addressed store, hash-verified

23}
24
25export 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
42export async function instanceLoggedGuard(req: Request, _: Response, next: NextFunction) {
43 if (req.originalUrl.includes('/instance/create')) {

Callers

nothing calls this directly

Calls 1

getInstanceFunction · 0.85

Tested by

no test coverage detected