https://github.com/hanchiang/node-typescript-koa
Node.js typescript koa project template
https://github.com/hanchiang/node-typescript-koa
koa nodejs typescript
Last synced: about 1 month ago
JSON representation
Node.js typescript koa project template
- Host: GitHub
- URL: https://github.com/hanchiang/node-typescript-koa
- Owner: hanchiang
- Created: 2020-03-18T11:47:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T01:39:20.000Z (over 3 years ago)
- Last Synced: 2023-03-06T01:08:48.291Z (over 3 years ago)
- Topics: koa, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.15 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# My service
This project is created using [koa](https://koajs.com/)
# Project structure
- `chart/`: Helm chart resources for deployment to AWS EKS
- `src/`
- `controllers/`: Main route logic are found here
- `config/`: Contains pre-defined environment variables
- `constants/`: Contains constants used in the entire service
- `db/`: DB configuration and connection
- `migrations/`: Contains a list of migrations used in the project
- `schema.sql`: SQL script to create tables in the database
- `routes/`: APIs routes
- `services/`: Finer grained logic that serves route controllers (and others)
- `types/`: Typescript typings for various codes
- `/utils/`: Various utility functions
- `test/`: Integration tests and unit tests
# Set up environment variables
- Set up environment file `.env.dev` and `.env.test` at project root, by referring to `.env.sample` and `.env.test.sample` respectively
# Running the project
**Run in development mode**
- Start: `docker-compose up -d my-service`
- Server is avaiilable at `localhost:3000`
- Stop: `docker-compose down`
**Run tests**
- Unit tests: `npm run test-unit`
- Integration tests: `npm run test-integration`
- All tests: `npm run test`
# Sequelize migrations
Sequelize migrations are managed using the [this guide](https://medium.com/@samratshaw/sequelize-cli-migrations-with-typescript-bd1bd41cbd6)
**Migration config**
The migration config file contains the DB connection for each environment
- Place ssl file in in `src/db/config/`
- Create a `config.js` in `src/db/config/`, by following `src/db/config/config.sample.js` and modifying the values accordingly
**Writing migration**
- Generate migration file: `./migration-generate.sh `, which will create the migration file in `db/src/migrations`
- Write the migration in that file
**Run migration**
- Migrate: `./migrate.sh `, e.g. `./migrate.sh development`
- Undo migrate: _Stay tuned_