Skip to main content

Generate CRUD Module

Super easy method to create CRUD Module which includes

  • Controller, Model, Route, Service, DTO & Settings
  • Automatic standard Routing path
  • Operations: Get All, Get Single, Update Single, Delete Single

Create your first Custom Module#

Run the following inside your Project's root:

calmapi generate module yourModuleName

A new module is now available at http://localhost:PORT/api/your-module-name.

Configure the Router path#

CalmAPI automatically creates a path from module's name.

But you can explicitly define the router path by adding moduleRoute in your-module-name.settings.js

your-module-name/your-module-name.settings.js
'use strict';
/**
* If custom router url is required, export url as "moduleRoute"
*/
module.exports = {
moduleRoute: 'your-custom-path'
};

Now your module is available at http://localhost:PORT/api/your-custom-path.

Routes#

Follow the Sample "Post" module's CRUD instruction here.