• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

naveteam/back-boilerplate: A boilerplate for building RESTful APIs using Node.js ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

naveteam/back-boilerplate

开源软件地址:

https://github.com/naveteam/back-boilerplate

开源编程语言:

JavaScript 98.1%

开源软件介绍:

Node API boilerplate by nave.rs

A boilerplate for building RESTful APIs using Node.js, PostgreSQL, koa, knex, objection.

Getting started

Installation

  1. Install Node.JS LTS version
  2. Install PostgreSQL
  3. Clone this repository and enter on the respective folder
  4. Install dependencies running: yarn or npm install

Things to do before run the project:

  1. Create database (by follow the commands):
  • CREATE USER user WITH PASSWORD password
  • CREATE DATABASE database
  • GRANT ALL PRIVILEGES ON DATABASE database to user
  1. Install citext extension on your database with the command CREATE EXTENSION citext;

  2. Change name value of .env.example to .env and set the key SECRET to any value you wish

  3. Change DATABASE_URL to postgress://user:password@localhost/database

  4. Run migrations: yarn db:migrate

  5. Run seeds: yarn db:seed

  6. Install Docker

  • Pull redis: docker pull redis
  • Create image: docker run --name your-image-name -d redis
  • Start redis: docker start your-image-name
  1. Run yarn start or yarn dev to start server

Testing

  1. Run tests: yarn test

Directory Structure

├── /src
|   ├── /controllers
|   ├── /database
|   |    ├── /migrations
|   |    ├── /seeds
|   ├── /helpers
|   ├── /middleware
|   ├── /models
|   ├── /routes
|   ├── /validators
├── /test

Postman

Run in Postman

Styleguide

Standard - JavaScript Style Guide

Nodemailer

To use the nodemailer helper in a non-production environment, you need to set the variable in .env ALLOW_LIST and assign an array with the domains allowed for sending e-mail. This domain must start with an @, followed by a minimum of 2 characters, a . and 2 characters in the end. In case the informed email is not part of any informed domain, the email will not be sent.

Examples:

The following domains: nave.rs and@nave are not allowed as they do not satisfy the domain description, given above.

Database

This project uses objection.js as ORM and knex as query builder.

Migrations:

In order not to use before update hooks on our models, we decided to create a function and trigger via migration, everytime you create a table with updated_at add the trigger to it. (an example is in the file: "src/database/migrations/20180910221504_init.js")

Steps to use Queue UI

  1. After adding a new queue, need to add in queue.js a new adapter
  2. Acess UI on http://localhost:3001/v1/queues/dashboards



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap