当前位置: 首页 > 软件库 > Web应用开发 > >

express-rest-boilerplate

⌛️ Express starter for building RESTful APIs
授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 居和顺
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Express ES2017 REST API Boilerplate

Boilerplate/Generator/Starter Project for building RESTful APIs and microservices using Node.js, Express and MongoDB

Features

  • No transpilers, just vanilla javascript
  • ES2017 latest features like Async/Await
  • CORS enabled
  • Uses yarn
  • Express + MongoDB (Mongoose)
  • Consistent coding styles with editorconfig
  • Docker support
  • Uses helmet to set some HTTP headers for security
  • Load environment variables from .env files with dotenv
  • Request validation with joi
  • Gzip compression with compression
  • Linting with eslint
  • Tests with mocha, chai and sinon
  • Code coverage with istanbul and coveralls
  • Git hooks with husky
  • Logging with morgan
  • Authentication and Authorization with passport
  • API documentation generation with apidoc
  • Continuous integration support with travisCI
  • Monitoring with pm2

Requirements

Getting Started

Clone the repo and make it yours:

git clone --depth 1 https://github.com/danielfsousa/express-rest-es2017-boilerplate
cd express-rest-es2017-boilerplate
rm -rf .git

Install dependencies:

yarn

Set environment variables:

cp .env.example .env

Running Locally

yarn dev

Running in Production

yarn start

Lint

# lint code with ESLint
yarn lint

# try to fix ESLint errors
yarn lint:fix

# lint and watch for changes
yarn lint:watch

Test

# run all tests with Mocha
yarn test

# run unit tests
yarn test:unit

# run integration tests
yarn test:integration

# run all tests and watch for changes
yarn test:watch

# open nyc test coverage reports
yarn coverage

Validate

# run lint and tests
yarn validate

Logs

# show logs in production
pm2 logs

Documentation

# generate and open api documentation
yarn docs

Docker

# run container locally
yarn docker:dev

# run container in production
yarn docker:prod

# run tests
yarn docker:test

Deploy

Set your server ip:

DEPLOY_SERVER=127.0.0.1

Replace my Docker username with yours:

nano deploy.sh

Run deploy script:

yarn deploy

Tutorials

Inspirations

License

MIT License - Daniel Sousa

  • 1.REST简介 REST是指表述性状态传递(Representational State Transfer,简称REST),是Roy Fielding 博士在2000年他的博士论文中提出来的一种软件架构风格。 表述性状态转移是一组架构约束条件和原则。满足这些约束条件和原则的应用程序或设计就是RESTful。 需要注意的是,REST是设计风格而不是标准。REST通常基于使用HTTP、URI和XML

  • 一、Express中的路由         在Express中,路由指的是客户端的请求与服务器处理函数之间的映射关系。         Express中的路由分3部分组成,分别是请求的类型、请求的URL地址、处理函数。 1、Express中的路由的例子 匹配GET请求,且请求URL为 / app.get('/',function(req,res){         res.send('Hello

  • express的基本使用 npm init//创建管理文档 npm i express -S //-S表示在生产环境下也要用到的包 var express = require('express');//导出express的顶级函数 var app = express();//创建express对象 app.get('/', function(req, res){//监听get请求的'/'地址

  • 原因: express.urlencoded()中间件默认只能解析100kb的application/x-www-form-urlencoded编码的文件,当文件大小超过100Kb就会报错 解决方案: 配置解析文件大小 // 配置解析application/x-www-form-urlencoded格式的表单数据的中间件 app.use(express.urlencoded({ extended:

 相关资料
  • express-rest-api-boilerplate Express REST API with JWT Authentication and support for sqlite, mysql, and postgresql authentication via JWT routes mapping via express-routes-mapper support for sqlite,

  • express-mongodb-rest-api-boilerplate Also express-graphql-mongodb-boilerplate - GraphQL API Boilerplate Authentication from scratch Sign In, Sign Up, Reset Password, Change Password, Update User E-mai

  • Express Boilerplate ExpressJS boilerplate with Socket.IO, Mongoose for scalable projects. Includes ExpressJS NodeJS Mongoose Socket.io Nodemon API-Docs Getting Started These instructions will get you

  • Express, React/Redux, MySQL Boilerplate Get Started 1. Prerequisites NodeJs NPM - Node package manager MySQL - Relational database management system (RDBMS) 2. Installation On the command prompt run t

  • express-graphql-boilerplate Express GraphQL API with JWT Authentication and support for sqlite, mysql, and postgresql Authentication via JWT Support for sqlite, mysql, and postgresql Support for graph

  • Express MVC Boilerplate A simple mvc boilerplate for express.js (gulp + expressjs + nodemon + browser-sync) Related modules express - web application framework for node pug - template engine stylus -