Giter Site home page Giter Site logo

node-api-template's Introduction

NodeJS API项目模板

依赖

Node.js v10.15.2+

模板内容

本例使用mongodb作为数据库,实现了Animal对象的查找和创建功能。

Sample的使用

docker run --name mongodb -p 27017:27017 -d mongo
npm install
npm start

目录结构

|-- Workspace
    |-- .eslintignore     eslint忽略配置文件,配置不需要做eslint检查的文件
    |-- .eslintrc.js      eslint配置
    |-- .eslintrc.json    eslint配置
    |-- .gitignore        git忽略文件
    |-- Dockerfile        标准node服务Dockerfile
    |-- README.md         
    |-- app.js            API主入口
    |-- package.json      依赖配置
    |-- server.js
    |-- swagger.json      API定义
    |-- model               业务模型
    |   |-- Model.js        业务模型
    |   |-- animalProcess.js  业务模型(animal)的业务处理逻辑
    |   |-- animalRoute.js    业务模型(animal)的路由
    |-- util
        |-- commonUtil.js   共通方法
        |-- db.js           数据库接口的实现

开发

建议使用vscode,安装Todo Tree插件后查找TODO

代码静态检查

  • eslint配置例

UT

  • 路由模块测试程序例
  • 业务逻辑测试程序例
  • 业务模型测试程序例
  • 单个测试程序测试执行方法
  • 整个工程程序测试执行方法

IT

  • 测试用例模板
  • 测试执行shell套件模板

部署

  • Docker部署
  • pm2部署

最佳实践

使用到的一些包

node-api-template's People

Contributors

k19810703 avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  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.