Fast Building of Node Backend Service

Time:2019-10-9

Fast Building Node Backend Service

Based on Koa2, Express, Mysql and Mongodb, the Node back-end service is built quickly to realize front-end and back-end communication.

objective

Quickly build node back-end services for different Vue projects, eliminating duplication of work; provide a clear node service building process and template for beginners

Framework and database combination

In the configuration file. / config. js, you can set the combination freely, choose one from the framework, one from the database, or not.

const frameworkOptions = ['koa', 'express']
const databaseOptions = ['mysql', 'mongodb']

module.exports = {
  framework: frameworkOptions[0],
  Database: database Options [0]// false does not use a database
}

Generate server folder

After selecting the framework and database, run node build. JS to generate server folder, package. JSON and related code files

Installation package

Enter the server folder to install dependency packages

cd server\
npm install

Operational Services

node index.js

test

Open index. HTML directly under the example folder to test whether the communication with the background is successful.

summary

Configuration file config.js
node build.js
cd server\
npm install
node index.js

PS

1. After the server folder is generated, the server folder can be copied to the project for use.
2. The database should be established in advance.

If it helps, get a Star.

Github-quick-node-server