mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 06:04:05 +00:00
refactoring some op functions, chain populating, type corrections
This commit is contained in:
@@ -1,25 +1,30 @@
|
||||
import { body } from "express-validator";
|
||||
import type { RequestHandler } from "express";
|
||||
|
||||
const createLinkValidator: RequestHandler = async (req, _res, next) => {
|
||||
const linkValidator: RequestHandler = async (req, _res, next) => {
|
||||
await body("from")
|
||||
.notEmpty()
|
||||
.withMessage("from not defined in body")
|
||||
.isURL()
|
||||
.withMessage("from must be a valid link")
|
||||
.withMessage("from must be a valid playlist link")
|
||||
.run(req);
|
||||
await body("to")
|
||||
.notEmpty()
|
||||
.withMessage("to not defined in body")
|
||||
.isURL()
|
||||
.withMessage("to must be a valid link")
|
||||
.withMessage("to must be a valid playlist link")
|
||||
.run(req);
|
||||
next();
|
||||
};
|
||||
|
||||
export {
|
||||
createLinkValidator,
|
||||
createLinkValidator as removeLinkValidator,
|
||||
createLinkValidator as populateSingleLinkValidator,
|
||||
createLinkValidator as pruneSingleLinkValidator,
|
||||
const nodeValidator: RequestHandler = async (req, _res, next) => {
|
||||
await body("root")
|
||||
.notEmpty()
|
||||
.withMessage("root not defined in body")
|
||||
.isURL()
|
||||
.withMessage("root must be a valid playlist link")
|
||||
.run(req);
|
||||
next();
|
||||
};
|
||||
|
||||
export { linkValidator, nodeValidator };
|
||||
|
||||
Reference in New Issue
Block a user