https://github.com/developer239/localized-graphql-koa-typescript
JavaScript meets server. Objection and GraphQL with support for 🌍 multiple languages. 🐳 and 100 % test coverage included.
https://github.com/developer239/localized-graphql-koa-typescript
Last synced: 6 months ago
JSON representation
JavaScript meets server. Objection and GraphQL with support for 🌍 multiple languages. 🐳 and 100 % test coverage included.
- Host: GitHub
- URL: https://github.com/developer239/localized-graphql-koa-typescript
- Owner: developer239
- Archived: true
- Created: 2018-08-21T10:42:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-13T14:17:41.000Z (almost 7 years ago)
- Last Synced: 2024-08-09T13:17:55.313Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 11.9 MB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://circleci.com/gh/developer239/localized-graphql-koa-typescript) [](https://codeclimate.com/github/developer239/localized-graphql-koa-typescript/test_coverage) [](https://codeclimate.com/github/developer239/localized-graphql-koa-typescript/maintainability) [](https://greenkeeper.io/)
# Localized GraphQL Koa TypeScript
Example boilerplate for you next GraphQL NodeJs server. Part of the project setup is from [petrhanak/backend-typescript-boilerplate](https://github.com/petrhanak/backend-typescript-boilerplate).
**Demo**
You can try the application [here](https://localized-graphql-koa-ts.herokuapp.com/playground) (it might take a while before the free server wakes up)
**With Multiple Languages** 🌍
By default all queries return data in english. If you want to request different translation then you have to send language code in http header:
```
{
"language": "cs"
}
```
If you are not familiar with docker, I highly recommend using it. You can download [Docker.dmg here](https://download.docker.com/mac/stable/Docker.dmg).
All you have to do to run the application in development mode is:
1. `docker-compose up -d`
2. `make db-migrate`
3. `make db-seed`
4. Open [http://localhost:3000/playground](http://localhost:3000/playground) in your browser

## Docker Users
You don't have to install node or postgres or any other library. Development environment is inside docker containers. `Makefile` is middleman between docker containers and our virtualized application.
**NOTE:** make sure that `CONTAINER_NAME` in `Makefile` has a correct value.
**Development:**
- `make enter` enter container terminal
- `make node_modules` reinstall node modules
- `make db-migrate` apply database migration
- `make db-rollback` rollback database migration
- `make db-reset` rollback and migrate
- `make db-seed` seed database
- `make dev` start development server
**Test**
- `make test` run tests
- `make test-coverage` run tests and report coverage
**Production:**
- `make build` build static javascript files
## Without Docker
If for some reason you can't or don't want to use docker then following instruction will guide you through the whole installation process:
**System Dependencies**
- Install node environment: `brew install node`
- Install yarn package manager: `brew install yarn`
- Install database `brew install PostgreSQL`
## Commands
**Development:**
- `yarn install` install node modules
- `yarn db:migrate` apply database migration
- `yarn db:rollback` rollback database migration
- `yarn db:reset` rollback and migrate
- `yarn db:seed` seed database
- `yarn dev` start development server
**Test**
- `yarn test` run tests
- `yarn test:coverage` run tests and report coverage
**Production:**
- `yarn build` build static javascript files
## Database
Use these commands to control `PostgreSQL` service:
1. `$ brew services start PostgreSQL`
2. `$ brew services stop PostgreSQL`
3. `$ brew services restart PostgreSQL`
**Troubleshooting**
```
Error: connect ECONNREFUSED 127.0.0.1:5432
```
If PostgreSQL stops working for no particular reason, run: `rm /usr/local/var/postgres/postmaster.pid` you can find [more information here](https://stackoverflow.com/questions/17800249/postgres-db-not-starting-on-mac-osx-error-says-connections-on-unix-domain-sock)