preface
- As I received new requirements, I needed to quickly complete an H5, and I was responsible for both the front and rear ends
- Vue3 + Pinia + WinDI CSS
- The back end has been looking for a long time, express, Nest, KOA, etc
- Dazzling, database Mysql, Mongodb and so on ~
- More dazzling, Typeorm, Sequelize, and Mongoose…
- Due to time constraints, we must choose a simple and easy to expand, and finally decide koA2 +mongodb+ Mongoose
- Looking for a long time, basically to the novice are not too friendly, so start their own hands, made this template!!
An out-of-the-box, quickly build small applications Koa2+mongodb+ Mongoose +… Template framework. The project is layered, including Controller, Models, routes. And the integration of automatic template generation, JSON format return middleware, can be trusted to use.
Github address if I can help you, I hope you can give me a star~
Project directory structure
├ ─ ─ app │ ├ ─ ─ the controller / / controller │ ├ ─ ─ models / / layer models | └ ─ ─ routes / / routing file ├ ─ ─ bin / / boot file ├ ─ ─ the config / / configuration file ├ ─ ─ ├─ public └ ─ app.js └ ─ package.json // Generate └ ─ middleware ├─ public └ ─ app.js └ ─ package.json // Package ├ ─ kick.js //Copy the code
🤖 is compatible with ES6 import writing
In start.js
require('babel-register')
(
{
plugins: ['babel-plugin-transform-es2015-modules-commonjs'],
}
)
module.exports = require('./bin/www')
Copy the code
🤖 Automatically generates routes based on files
In the app.js file
// routes
fs.readdirSync('./app/routes').forEach(route => {
let api = require(`./app/routes/${route}`)
app.use(api.routes(), api.allowedMethods())
})
Copy the code
🤖 Supports automatic file generation
⚙️ code files automatically generated, preset templates controller,models,routes, you can also design more automatic generation scripts according to your own needs. General backend students use this form, very efficient.
After running NPM run new, enter the module name, for example, test
⭐ ️ Show Your Support
If this template has helped you, I hope you can give a star!
Please give a ⭐️ if this project helped you!
👏 Contributing
If you have any questions or requests, or want to contribute to “Moveable” or other packages, please write an issue or give me a free Pull Request.
If you have any questions or requests or want to contribute to koa2_template
or other packages, please write the issue or give me a Pull Request freely.
🐞 Bug Report
If you find a bug, please open a new Issue on GitHub and report it to us. If you find a bug, please report to us opening a new Issue on GitHub.