npm.io
1.19.9 • Published 22h ago

kschema-fs-api-gen-post-actions

Licence
Version
1.19.9
Deps
2
Size
267 kB
Vulns
0
Weekly
201

kschema-fs-api-gen-post-actions

A configuration-driven scaffolding library to instantly generate Express.js POST API actions.

This package automatically generates boilerplate code (controllers, data access layers, routes, and validation schemas) and registers the newly created routes directly into your end-points.js file.

This package is a programmatic-only library. It is designed to be imported and executed inside your scripts, automation tasks, or build pipelines, and does not provide a command-line interface (CLI).


Installation

npm install kschema-fs-api-gen-post-actions

Programmatic API Usage

Import and call the action generators directly in your scripts:

import { 
  withMail, 
  insertGenPk, 
  insertAsIs, 
  filter, 
  groupBy 
} from 'kschema-fs-api-gen-post-actions';

// Example: Generate a standard insert action
await insertAsIs({
  toPath: './src/api',            // Target directory containing your end-points.js
  inFolderName: 'InsertAsIs',      // Folder name to generate under the target directory
  inGenerateRest: false           // Whether to generate REST specifications
});
Available Generator Functions

Each function accepts a configuration object containing path specifications and generation options:

  1. withMail: Generates a POST action with email sending logic.
  2. insertGenPk: Generates an insert action with an automatically generated primary key.
  3. insertAsIs: Generates a standard insert action without modifying or generating the primary key.
  4. filter: Generates a filter/query action.
  5. groupBy: Generates a database grouping/aggregation action.

Output Structure

When any generator function executes successfully, it scaffolds a directory with the following files under your target directory:

[inFolderName]/
├── controller.js   # Handles the route request and invokes the DAL
├── dal.js          # Direct database interaction queries
├── route.js        # Defines validation middleware and endpoint routing
└── validation.js   # Validation schemas

Additionally, it dynamically parses and updates your local end-points.js file to import the new controller and bind it to the Express router.


Documentation & Development

For detailed instructions, architecture layouts, and workflows, refer to the following resources:

Markdown Guides
HTML Documentation

License

MIT