For my job, we create a lot of small web applications with NodeJS for the backend and Angular for the frontend
Said apps usually involve a lot of CRUDs
With Angular, I can run:
ng generate component 'component-name'
Which generates the ts, html, scss, and spec files
How would I go about creating a custom script to do something similar in NodeJS?
Currently, the project uses ExpressJS and Sequelize, and the structure as follows:
├── src
│ ├── controllers
│ | ├── product.controller.js
│ ├── models
| | ├── product.model.js
│ ├── routes
| | ├── product.routes.js
├── index.js
├── package.json
Basically I want to create a script that generates all 3 files when given the name, something like
node generate client
Is it possible?
You can simply do this by adding a bash script, and calling it in your package.json.
Step 1: create a bash script
generate-controller-model-route.shin the route folderStep 2: add the bash script to the package.json (scripts property).
Step 3: call it with yarn/npm