开源软件名称: SystangoTechnologies/koach-typescript开源软件地址: https://github.com/SystangoTechnologies/koach-typescript开源编程语言:
TypeScript
77.6%
开源软件介绍:
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
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 :
CD to project dir
Create build using cmd: $ docker-compose build
Start the server in daemon thread using cmd: $ docker-compose up -d
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.
请发表评论