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

paralect/koa-api-starter: A starter kit for building Koa.JS based restful api

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

开源软件名称:

paralect/koa-api-starter

开源软件地址:

https://github.com/paralect/koa-api-starter

开源编程语言:

JavaScript 97.2%

开源软件介绍:

This repository is no longer maintained. Check Ship.

Koa.JS REST api starter

Stack

Fully featured Koa.JS restful api starter application. The goal of this project is to solve all routine tasks and keep your focus on the product and business logic of the application, not on the common things, such logging, configuration, dev/production environments

Out of the box support following features:

  1. Config management.
  2. Configured console logger based on common-logger
  3. Automatic application restart when code changes with Nodemon
  4. MongoDB configuration
  5. Docker configuration for development and production environments.
  6. Code linting based on paralect/eslint-config
  7. Simplified request data validation and clean up based on joi and koa-validate
  8. Production ready account API resource (singup, signin, forgot password, reset password functionality)
  9. Access token based authentication.
  10. Tests for endpoints.
  11. WebSocket server (socket.io)
  12. Database migrations
  13. Scheduler

Prerequisites

Google authorization

Fill data from google in src/config/environment/index.js

google: {
  clientId: 'clientId',
  clientSecret: 'clientSecret',
  redirectUri: 'redirectUri',
}

Start

In order to start server in the docker container you can use bash file ./bin/start.sh:

$ ./bin/start.sh

To start the project not in the docker container just run: npm run dev. This command will start the application on port 3001 and will automatically restart whenever you change any file in ./src directory.

Explanations of the files structure

We try to keep things as simple as possible, so you can focus on building product instead of learning concepts.

There are three main directories within project:

  1. src/config - consist of configuration for the environment, koa server and API routes.

  2. src/config/routes - consist of public (don't require access token) and authenticated (require access token) routes and middlewares.

    • middlewares - koa middlewares which we use on every request (for example, get current user data from the database)
  3. src/resources - REST api resources and everything related to the resource:

  4. src/services - application services for various purposes. Not this directory contains the following services:

All other files, that does not fit that structure should be placed straight in the src folder. We can always introduce more folders as we need them. Currently root folder consist following:

  1. src/app.constants.js - constant variables that are used in the application
  2. src/app.js - starting point of the node.js application. It combine application configuration and start Koa http listener.
  3. src/db.js - handles connection to the MongoDB.
  4. src/logger.js - application logger.
  5. src/security.util.js - number of methods for generating secure tokens and comparing passwords with password hash.



鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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