@puq/names
Version:
The library provides a useful function to create all casing variants of a given string value such as title-case, pascal-case, snake-case and so more.
32 lines (31 loc) • 1.04 kB
JavaScript
import { names } from '../names/names.js';
import { pluralize } from '../names/pluralize.js';
export function resourcePaths(resourceName) {
const s = names(resourceName).kebab;
const p = names(pluralize(s)).kebab;
const singularPath = `${s}`;
const pluralPath = `${p}`;
const singularByPath = `${s}/:property/:value`;
const pluralByPath = `${p}/:property/:value`;
const idPath = `${s}/:id`;
return {
deleteMany: pluralPath,
deleteManyBy: pluralByPath,
deleteOne: singularPath,
deleteOneBy: singularByPath,
deleteOneById: idPath,
findMany: pluralPath,
findManyBy: pluralByPath,
findOne: singularPath,
findOneBy: singularByPath,
findOneById: idPath,
saveMany: pluralPath,
saveOne: singularPath,
updateMany: pluralPath,
updateManyBy: pluralByPath,
updateOne: singularPath,
updateOneBy: singularByPath,
updateOneById: idPath
};
}
//# sourceMappingURL=resource-paths.js.map