Overview of Dependencies
The kschema-fs-api-gen-post-actions package works hand-in-hand with two custom utility libraries developed by KeshavSoft. These dependencies isolate endpoint parsing logic and standard REST API code generation respectively.
1. express-fix-endpoints-post-js
This library is responsible for modifying the Express router registration file (typically end-points.js) whenever a new POST action is created.
💡 Why not standard AST parsing?
Standard AST (Abstract Syntax Tree) modification tools can be fragile and prone to destroying code styling, formatting, or comments. The express-fix-endpoints-post-js package is tailored to preserve file structure while reliably appending imports and route registrations.
Key Roles & Functions
- ES module import insertion: Scans the top of
end-points.jsand adds the corresponding ES import statement for the newly generated controller. - Route attachment: Locates the router definition (e.g.
router.post(...)orrouter.use(...)) and appends the new path handler integration safely. - Validation schemas: Integrates validation middleware into the route structure dynamically.
2. kschema-fs-api-gen-rest
This library handles generating matching database CRUD and REST specification schemas when the optional inGenerateRest flag is set to true during programmatic invocation.
// Example activation:
await insertAsIs({
toPath: './src/api',
inFolderName: 'InsertAsIs',
inGenerateRest: true // activates kschema-fs-api-gen-rest integration
});
Key Roles & Functions
- Full CRUD/REST scaffolding: Builds additional schema definitions to match your post actions.
- Dynamic mapping: Coordinates schema structures dynamically with the POST validation engine and DAL layers.