Gathering detailed insights and metrics for express-mongoose-gen
Gathering detailed insights and metrics for express-mongoose-gen
Gathering detailed insights and metrics for express-mongoose-gen
Gathering detailed insights and metrics for express-mongoose-gen
mongoose-express-gen
產生基本mongoose與express MVC架構 目錄結構 ```bash myfirst ├── api #route api 存放位置 │ └── example #api 名稱 │ ├── controller │ │ └── get.js │ └── index.js # 放 route.get post... ├── models │ ├── mongodb │ │ ├── connector.js │
express-node-gen
Simple and beginner friendly express node boilerplate
express-mongoose-gen-es6
It’s a mongoose model, REST controller and Express router code generator for Express.js 4 application
ts-express-mongoose-crud-gen
TS Express Monggose CRUD generator is npm package that helps to generate typescript modules
Using this project, you can completely enter an initial configuration command to do your project with the best ninety packages.
npm install express-mongoose-gen
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (91.51%)
TypeScript (8.49%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
36 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 14, 2024
Latest Version
2.0.3
Package Id
express-mongoose-gen@2.0.3
Unpacked Size
34.55 kB
Size
8.00 kB
File Count
15
NPM Version
6.14.8
Node Version
14.11.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This package of models receives your database and structures your project with architecture MVC as REST controller and Express router code generator for Express.js 4.0.17 application. Full support for type script and defining files as base class
Note that the package must be installed globally on your system
1$ npm install -g express-mongoose-gen
1$ mongoose-gen -m user -f firstName:number,lastName:string -r 2 create: ./models/userdModel.js 3 create: ./routes/userdRoutes.js 4 create: ./controllers/userdController.js
-m, --model <modelName>
- the model name.-f, --fields <fields>
- the fields (name1:type,name2:type).-r, --rest
- enable generation REST.-t, --tree <tree>
files tree generation grouped by (t)ype or by (m)odule1$ mongoose-gen 2Model Name : user 3Available types : string, number, date, boolean, array 4Field Name (press <return> to stop adding fields) : door 5Field Type [string] : number 6Field Name (press <return> to stop adding fields) : color 7Field Type [string] : 8Field Name (press <return> to stop adding fields) : owner 9Field Type [string] : objectId 10Reference (model name referred by the objectId field) : User 11Field Name (press <return> to stop adding fields) : 12Generate Rest (yes/no) ? [yes] : 13Files tree generation grouped by Type or by Module (t/m) ? [t] : 14 create: ./models/userModel.js 15 create: ./routes/usersRoutes.js 16 create: ./controllers/userController.js
models/userModel.js :
1const mongoose = require('mongoose'); 2const Schema = mongoose.Schema; 3 4const userSchema = new Schema({ 5 firstName : { type : String }, 6 lastName : { type : Number }, 7 owner : { 8 type: Schema.Types.ObjectId, 9 ref: 'User' 10 } 11}, {timestamps : true}); 12 13module.exports = mongoose.model('user', userSchema);
routes/userRoutes.js :
1const express = require('express'); 2const router = express.Router(); 3const userController = require('../controllers/userController.js'); 4 5 6router.get('/', userController.list.bind(userController)); 7 8router.get('/:id', userController.show.bind(userController)); 9 10router.post('/', userController.create.bind(userController)); 11 12router.put('/:id', userController.update.bind(userController)); 13 14router.delete('/:id', userController.remove.bind(userController)); 15 16module.exports = router; 17
controllers/userController.js :
1const userModel = require({modelPath}); 2 3 4module.exports = new class user { 5 list(req , res) { 6 userModel.find({} , (err, user) => { 7 if (err) { 8 return res.status(500).json({ 9 message: 'Error when getting user.', 10 error: err 11 }); 12 } 13 return res.status(200).json(user); 14 }); 15 }; 16 show(req , res) { 17 userModel.findById(req.params.id, (err, user) => { 18 if (err) { 19 return res.status(500).json({ 20 message: 'Error when getting user.', 21 error: err 22 }); 23 } 24 if (!user) { 25 return res.status(404).json({ 26 message: 'No such user' 27 }); 28 } 29 return res.status(200).json(user); 30 }); 31 }; 32 create(req , res) { 33 let user = new userModel({{createFields} 34 }); 35 36 user.save((err, user) => { 37 if (err) { 38 return res.status(500).json({ 39 message: 'Error when creating user', 40 error: err 41 }); 42 } 43 return res.status(201).json(user); 44 }); 45 }; 46 update(req , res) { 47 userModel.findById(req.params.id , (err, user) => { 48 if (err) { 49 return res.status(500).json({ 50 message: 'Error when getting user', 51 error: err 52 }); 53 } 54 if (!user) { 55 return res.status(404).json({ 56 message: 'No such user' 57 }); 58 } 59 {updateFields} 60 user.save((err, user) => { 61 if (err) { 62 return res.status(500).json({ 63 message: 'Error when updating user.', 64 error: err 65 }); 66 } 67 return res.json(user); 68 }); 69 }); 70 }; 71 remove(req , res) { 72 userModel.findByIdAndRemove(req.params.id, (err, user) => { 73 if (err) { 74 return res.status(500).json({ 75 message: 'Error when deleting the user.', 76 error: err 77 }); 78 } 79 return res.status(204).json(); 80 }); 81 }; 82};
1Files tree generation grouped by Type or by Module (t/m) ? [t] : m 2 create: ./user 3 create: ./user/userModel.js 4 create: ./user/userController.js 5 create: ./user/userRoutes.js
You then only have to add router in app.js file and MongoDB connection whit Mongoose. app.js :
1const routes = require('./routes/index'); 2const users = require('./routes/userRoutes'); 3 ... 4 5app.use('/', routes); 6app.use('/users', users); 7 ... 8
Copyright (c) 2020 Navidrezadoost Licensed under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More