Skip to content
/ TyKoa Public template

A quickstart template for TypeScript + Koa 2

License

Notifications You must be signed in to change notification settings

lgh06/TyKoa

Repository files navigation

TyKoa

A quickstart template for TypeScript + Koa 2

中文README

Feature

  1. TypeScript + Koa 2
  2. Auto scan routes, configure routes using @Controller('/path') above class, and @Post('/subPath') above each function ( other HTTP methods are also supported )

System Requirements

  1. Node.js latest v10.x or newer
  2. PostgreSQL ( if you use MySQL, need to configure right driver for knex, and disable PostGraphile manually )

Usage

  1. first things first, input postgres configurations in conf/local
  2. then:
npm install  
npm run n (dev mode)  
open http://localhost:3000/test/2  

( or, open http://localhost:3000/test/1 , you should ensure you have a table named `user_tb` first )  
  
-----------------------------------------------------------

npm run build ( use tsc to build codes for production )
npm start (run compiled codes for production)

TODO

  1. Better routes, like scanning directories then require, using globby
  2. duplicated route path warning.
  3. IoC container, using injection or tsyringe or Inversify
  4. add service directory
  5. jsonwebtoken
  6. Better README
  7. Better logger
  8. Plugins support (like eggjs?..)
  9. CLI support to quickly generate structure
  10. RPC

main third party dependencies:

  1. TypeScript + its decorators + reflect-metadata
  2. Koa 2
  3. Knex.js , a SQL query builder
  4. pg , Postgresql Nodejs driver
  5. PostGraphile , make GraphQL and Postgres things easy
  6. dotenv , configurations in .env files

dev dependencies:

  1. nodemon , auto restart node when code changes
  2. ts-node , execute .ts files without building to .js
  3. eslint , typescript-eslint ( TSLint is deprecated )
  4. concurrently , run multiple commands at one time
  5. open-cli , open URL in browser, through terminal.

Other

inspired by:
https://github.com/midwayjs/midway/

Other similar projects:
https://github.com/thinkkoa/koatty