5.0.0 • Published 10 months ago

@aging/rest-path v5.0.0

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

rest-path

Class: RestPath

  • This class provides a helper method to dynamically generate RESTful API paths for a specific database entity. It is intended to simplify the creation and management of endpoints for CRUD (Create, Read, Update, Delete) operations and other entity-specific routes by following REST conventions.

Features:

  • Path Generation: Automatically constructs API paths for various operations such as retrieving, creating, updating, and deleting resources based on the entity's base URL.
  • Consistency: Ensures uniform and predictable API paths across the application.
  • Customization: Allows for the definition of custom routes or variations in paths for specific actions.

Usage:

import { RestPath } from '@aging/rest-path';

const S = new RestPath({ name: 'sample', pluralName: 'samples', prefix: '' });

S.PREFIX; // Output: ''

S.ID_PATH; // Output: /sample/:id

S.INCREMENT_PATH; // Output: /sample/:id

S.SINGULAR_PATH; // Output: /sample

S.PLURAL_PATH; // Output: /samples

S.RELATION_PATH; // Output: /sample/:id/:rn/:rid

S.UNSET_RELATION_PATH; // Output: /sample/:id/:rn

S.COUNT_PATH; // Output: /sample

Benefits:

  • Scalability: As the number of entities in your application grows, managing API routes becomes easier with a centralized, reusable approach.
  • Maintainability: Reduces redundancy and potential for errors in hardcoded paths.
  • Flexibility: Adaptable to different naming conventions or route structures.
5.0.0

10 months ago

4.0.0

10 months ago

3.8.0

10 months ago

3.7.0

10 months ago

3.6.0

10 months ago

3.5.0

10 months ago

3.4.0

10 months ago

3.3.0

10 months ago

3.1.0

10 months ago

3.0.0

10 months ago

2.0.0

10 months ago

0.0.4

10 months ago

0.0.2

10 months ago