diff options
Diffstat (limited to 'server/middlewares/validators/runners/registration-token.ts')
-rw-r--r-- | server/middlewares/validators/runners/registration-token.ts | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/server/middlewares/validators/runners/registration-token.ts b/server/middlewares/validators/runners/registration-token.ts deleted file mode 100644 index cc31d4a7e..000000000 --- a/server/middlewares/validators/runners/registration-token.ts +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { param } from 'express-validator' | ||
3 | import { isIdValid } from '@server/helpers/custom-validators/misc' | ||
4 | import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' | ||
5 | import { forceNumber } from '@shared/core-utils' | ||
6 | import { HttpStatusCode } from '@shared/models' | ||
7 | import { areValidationErrors } from '../shared/utils' | ||
8 | |||
9 | const tags = [ 'runner' ] | ||
10 | |||
11 | const deleteRegistrationTokenValidator = [ | ||
12 | param('id').custom(isIdValid), | ||
13 | |||
14 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
15 | if (areValidationErrors(req, res, { tags })) return | ||
16 | |||
17 | const registrationToken = await RunnerRegistrationTokenModel.load(forceNumber(req.params.id)) | ||
18 | |||
19 | if (!registrationToken) { | ||
20 | return res.fail({ | ||
21 | status: HttpStatusCode.NOT_FOUND_404, | ||
22 | message: 'Registration token not found', | ||
23 | tags | ||
24 | }) | ||
25 | } | ||
26 | |||
27 | res.locals.runnerRegistrationToken = registrationToken | ||
28 | |||
29 | return next() | ||
30 | } | ||
31 | ] | ||
32 | |||
33 | // --------------------------------------------------------------------------- | ||
34 | |||
35 | export { | ||
36 | deleteRegistrationTokenValidator | ||
37 | } | ||