This is a boiler-plate creator for expressJS in an MVT format. Each Router-domain has its own Model,View & Routes.
- As each Router Domain has its own work-folder, the domains can be re-used in other products by simply picking and droping into new project files.
So Basically if I have a project1 and have 3 app/router-domains in it(as displayed in the image above). I also have another project, Project2 which rquires app1 in it.
It would be very easy, as all the domains work independently and are coded independently, I would simply copy it to project2 and register it in router.JS
npm install -g create-express-mvt
Then go to the folder you want to create your express app
npx create-express-mvt
Create .env file
Define
DB_HOST=`Your MongoDB cluster link without enverted commas`
PORT=`PORT Number without inverted commas`
Only use it from inside the CEM project-workspace
npx create-express-mvt startapp
Now add the app_name to app_register.json in
{"app_name":"router-domain you want it on"}
The index.js is the main file. It controls the basic defintions and middlewares,etc. Each router-domain known as an App
has its own model,view and routes.
What happens in an App
:
- The model is created in model.js
- The model is then imported to views.js, where views/functions are coded using the imported data-models. Each function which is to be called upon a route is imported independently using
module.exports.FUNCTION_NAME=FUNCTION_NAME
- Then the views are imported in route.js and are connected to needed routes. The router is then exported.
- The main.js in the app imports routes which is then exported to Global routes.js. The routes.js routes all the routes registered in its JSON object. See the routes.js for understadning how to import your
App
.
- Admin Panel
- JWT Auth Default-App