UNPKG

@tsed/cli

Version:
19 lines (18 loc) 542 B
import { injectable } from "@tsed/cli-core"; import { kebabCase } from "change-case"; export class RoutePipe { transform(route) { const r = route .split("/") .reduce((paths, path) => { const word = kebabCase(path); if (paths.includes(`${word}s`) || paths.includes(word)) { return paths; } return [...paths, kebabCase(path)]; }, []) .join("/"); return `/${r}`.replace(/\/\//gi, "/"); } } injectable(RoutePipe);