The seed of koa(2.x) with typescript
yarn
# use ts-node
yarn start
# first run `yarn start`
yarn test
# lint:check
yarn run eslint:check
# lint:fix
yarn run eslint:fix
Refer to config-document
yarn run build
# if not pm2, please run `yarn global add pm2`
# first run `yarn run build`
yarn run prod
With docker
# build docker image
docker build -t <image-name>:<tag> .
# this is an example
#!/bin/bash
echo 'start...'
docker stop koa-sail-ts
docker rm koa-sail-ts
docker rmi koa-sail-ts:0.1.0
docker build -t koa-sail-ts:0.1.0 .
docker run --name koa-sail-ts -p 8183:8181 -v /home/docker/koa-sail-ts/logs:/usr/src/app/logs -d koa-sail-ts:0.1.0
echo 'finished'
exit 0
- Use
typescript
- Use pm2 as
nodejs
process manager - Login and api authorization(powered by passportjs and jwt)
- Api params validator validator-document
- websocket supported(powered by ws)
- Logging(powered by log4js)
- Unit test(powered by mocha)
Docker
supported
The project's birth and development is inseparable from koa
, log4js
, jsonwebtoken
, typescript
, and so on. For detail, refer to the part dependencies
and devDependencies
of package.json.
The project initially generated with koa-generator with javascript
, and switch to typescript
since 0.4.0
. The project has undergone great change with the development of the project, but koa-generator
is import for the birth of koa-sail-ts
.
If you want to construct restful api by class
, please refer to 0.8.x branch [The implementation refers to 如何使用koa2+es6/7打造高质量Restful API].
If you prefer style like express, please refer to 0.6.x branch.