Giter Site home page Giter Site logo

quick-node-server's Introduction

快速搭建node后端服务

基于Koa2、Express、Mysql、Mongodb快速搭建Node后端服务,实现前后端通讯。

目的

为不同 vue 项目快速搭建 node 后端服务,去除重复性工作;为刚入门的同行提供一个清晰的 node 服务搭建流程与模板

框架、数据库组合

在配置文件 ./config.js 中可自由设置组合,框架二选一,数据库二选一,也可不选

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

module.exports = {
  framework: frameworkOptions[0],
  database: databaseOptions[0]  // false 不使用数据库
}

生成server文件夹

选择好框架、数据库后,运行 node build.js 生成server文件夹、package.json及相关代码文件

安装包

进入server文件夹,安装依赖包

cd server\
npm install

运行服务

node index.js

测试

直接打开 example 文件夹下 index.html,可测试与后台是否成功通讯

总结

配置文件 config.js
node build.js
cd server\
npm install
node index.js

PS

1、生成server文件夹后,就可以将server文件夹拷贝到项目中使用
2、数据库要事先建立好

若有帮助,求颗 Star

Github-quick-node-server

quick-node-server's People

Contributors

moon-future avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.