Skip to content

mkanilsson/mvc-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mvc-creator

A quick and easy way to create Nodejs websites with MVC architecture.

Project Structure

Note: When going trough how it works we will use a Blog Application example. It will only be an API

The Websites entry point is main.ts from there it adds all the routes to the app which it gets from either API.ts or WEB.ts in the Routes directory Inside the API.ts/WEB.ts it imports all routes from Routes/api or Routes/web depending on if it's a web or api controller.

in the routes file it will have:

routes.get("/", PostsController.Index);
routes.post("/", PostsController.Store);

routes.get("/:id", PostsController.Show);
routes.put("/:id", PostsController.Update);
routes.patch("/:id", PostsController.Update);
routes.delete("/:id", PostsController.Destroy);

Folder Structure - TypeScript

.
├── src
│   ├── Controllers
│   │   └── PostsController.ts
│   ├── Models
│   │   └── Post.ts
│   ├── Routes
│   │   ├── API.ts
│   │   └── api
│   │       └── PostRoutes.ts
│   ├── Utils
│   │   ├── ErrorHandeling.ts
│   │   └── Str.ts
│   └── main.ts
├── package.json
└── tsconfig.json

Usage

Projects

Creating

mvc-creator create project <name>

Controllers

Creating

mvc-creator create controller <name>

Flags:

  • -e : --everything, Creates a Model, Controller and Routes
  • -a : --api, Only creates API methods (Excluding: Edit and Create)

Models

Creating

mvc-creator create model <name>

Middleware

Creating

mvc-creator create middleware <name>

Utility

Creating

mvc-creator create util <name>

Error

Creating

mvc-creator create error <name>

.Env

Creating

mvc-creator create env

Generate App key

mvc-creator env key generate

View App Key

mvc-creator env key view

View Value

mvc-creator env get <key>

Set Value

mvc-creator env set <key> <value>

Generate random string for Value

mvc-creator env generate <key>

Remove Value

mvc-creator env remove <key>

Show entire file

mvc-creator env show

TODO

  • Make so any dotenv operation changes the .env.example file
  • Split things into files to remove clutter and copy-code

About

Cli for creating nodejs MVC backends fast

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published