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

SystangoTechnologies/koach-typescript: Production ready Koa2 boilerplate written ...

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

开源软件名称:

SystangoTechnologies/koach-typescript

开源软件地址:

https://github.com/SystangoTechnologies/koach-typescript

开源编程语言:

TypeScript 77.6%

开源软件介绍:

KOACH

KOACH-Typescript

Production ready boilerplate for building APIs in Typescript(3.4) with koa2, and using SQL database and http/2 as the communication protocol.

Features

  • Object oriented
  • Typescript
  • Authentication (JWT)
  • http/2 support
  • Sequelize ORM
  • Doc generation with Swagger
  • TS linting
  • Dockerized Version

Please note, This boilerplate is for the API only application.

Visit https://localhost:3000/ to access the root page.

Requirements

  • Node v10.16.0
  • SQL Database (anyone MySQL, MariaDB, SQLite, PostgreSQL, MSSQL)
  • Docker

Environment Variables Configuration

To simulate environment variables

Dev environment (use anyone)

  • src/resources/config/env.development.ts
  • .env file

Production environment

  • /etc/environment file

The environment variables are as follows -

NODE_ENV=production                                 // Environment development/production
SERVER_PORT=3000                                    // Server's Port
SESSION=secret_key                                  // secret-boilerplate-token
JWT_SECRET=token                                    // Jwt secret key
DB_HOST=host                                        // DB Host address
DB_PORT=3306                                        // DB Port number
DB_DIALECT=db                                       // DB (mysql, PostgreSQL, MySQL, etc)
DB_NAME=name                                        // DB name
DB_USER=user                                        // DB user name
DB_PASSWORD=password                                // DB password

Installation

git clone https://github.com/SystangoTechnologies/Koach-Typescript.git
 

Modules Used

Structure

│   .gitignore                                      // Standard git ignore file
|   .env                                            // dotenv configuration file for environment variable
│   docker-compose.yml                              // Standard docker compose file
│   Dockerfile                                      // Standard docker file
│   gruntfile.js                                    // Standard  gruntfile.js file
│   package.json                                    // Standard package.json file
│   README.md
│   tslint.json                                     // Standard tslint.json file
│
├───log                                             // logs directory
└───src                                             // source code
    │   .sequelizerc                                // Standarded sequlize config file
    │
    ├───app
    │   ├───constant                                // constants
    │   │       httpConstants.ts                    // http status code constant file
    │   │
    │   ├───controller                              // controller
    │   │       BookController.ts
    │   │
    │   ├───core
    │   │   │   RouterGenerator.ts                  // Generating all routes
    │   │   │   RouterManager.ts                    // Route depedency
    │   │   │
    │   │   └───middleware                          // middlewares
    │   │           ErrorMiddleware.ts 
    │   │           RequestValidator.ts             // request body validator
    │   │
    │   ├───db
    │   │   │   config.json
    │   │   │   DatabaseConfigurationManager.ts
    │   │   │
    │   │   ├───entity                              // entities
    │   │   |   ├───library
    │   │   |   │       book.ts                     // book entity
    │   │   |   │       index.ts
    │   │   |   │
    │   │   |   └───migrations                      // Migrations
    │   │   |       │   20190703135002-create-book.ts
    │   │   |       │
    │   │   |       └───compiled                    // compiled migrations
    │   │   |               20190703135002-create-book.js       
    │   │   |
    │   │   |
    │   │   └───repository                          // repository
    │   │          Book.ts        
    │   │   
    │   ├───model
    │   │       Book.ts                             // book model
    │   │ 
    │   ├───routes                                  // router
    │   │       BookRouter.ts
    │   │       index.ts
    │   │
    │   ├───service                                 // Service file for database
    │   │       BookService.ts
    │   │
    │   └───validation                              // validations
    │           BookValidator.ts
    │
    ├───logger                                      // logger file.
    │      index.ts
    │      LogManager.ts
    │
    ├───resources                                   // resources
    │   ├───config                                  //  configuration setting
    │   │       ConfigurationManager.ts
    │   │       env.common.ts
    │   │       env.development.ts
    │   │       index.ts
    │   │
    │	├───cert                                    // SSL certificates
    │	│      localhost.crt
    │	│      localhost.key
    │	│       
    │   └───swagger                                 // Swagger
    │
    └───server                                      // server
           server.ts

Usage

  • npm run build compile the typescripts in src folder
  • npm start Starts the server on development mode in Typescript
  • npm run dev Starts the server on development mode in Javascript
  • npm run grunt Starts server using grunt file
  • docker-compose up -d Starts the server for production

Running the server in Docker Container

Prerequisite For Docker Configuration: Docker and docker compose must be installed on the system.

Steps to run the app in a docker container :

  1. CD to project dir
  2. Create build using cmd: $ docker-compose build
  3. Start the server in daemon thread using cmd: $ docker-compose up -d
  4. Stop the server using cmd: $ docker-compose down

Documentation

The API documentation is written in Swagger (https://github.com/swagger-api/swagger-node#readme).

To view swagger API documentation

Visit https://localhost:3000/swagger to view Swagger UI.

Contributors

Sparsh Pipley

Anurag Vikram Singh

Abhishek Parmar

Ayush Sharma

License

MIT.




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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