Backend for NoHai, mostly a C.R.U.D. application. It's written in typescript and it uses GraphQL, MongoDB, Jest and Sinon.
You need Node.js version 10.15.3 to be installed, before you can run the application.
You need yarn package manager to be installed before you can run the application.
You need MongoDB to be installed, before you can run the application.
As a MongoDB UI tool, you can use MongoDB Compass.
You need to install
typeormglobally before:yarn global add typeorm -g.
Clone the repo and enter into the cloned directory:
git clone git@github.com:NoHai/nohai-api.gitcd nohai-api
Install all the node dependencies:
yarn install
Build and start the application:
yarn run environment:all(environment can bemock,dev,stagingorproduction)
The GraphiQL interface can be accessed on: http://localhost:5000/graphql/ (it can be accesed only after running command:
yarn run environment:all).
You need to install
typeormglobally before:yarn global add typeorm -g. Also, be sure that the globally installed, typeorm version matches with the one frompagkage.json.
Migrations are checked and ran on each application startup. To add a new migration you need to:
-
Go into
src/data/migrationsfolder. -
Execute
typeorm migration:create -n YourMigrationNameGoesHere.
A new migration file will be created in the
src/data/migrationsfolder.
yarn lint- lints the codeyarn lint:fix- lints and fixes the codeyarn lint:watch- lints the code in watch mode
The command
yarn lint:watchdoes not fix the founds.
yarn test- runs all unit testsyarn test:watch- runs all unit tests in watch modeyarn copy:graph- copies recursively all the GraphQL schema files to output directory
When you run
yarn copy:graph, all the GraphQL schema files are recursively copied fromsrc/presentation/graphintodist/presentation/graphfolder.
yarn mock:build- executes the build for mock environmentyarn mock:build:watch- executes the build for mock environment in watch mode
When you run
yarn mock:build:watchthe settings file is copied only once. So, if you did some changes to the settings file (mock.jsonordevelopment.jsonorstaging.jsonorproduction.json), you have to re-run this command.
yarn mock- starts the application for mock environmentyarn mock:watch- starts the application for mock environment in watch modeyarn mock:all- lints the code with fixing, builds and starts the application for mock environment
The command
yarn mock:allis kid of a single command to rule them all, usually it's used in development for starting the app faster.
yarn mock:copy:settings- copies the mock settings file to output directory
When you run
yarn mock:copy:settingsthe settings file is copied fromsrc/presentation/settings/mock.jsonintodist/presentation/settingsfolder.
yarn dev:build- executes the build for development environmentyarn dev:build:watch- executes the build for development environment in watch mode
When you run
yarn dev:build:watchthe settings file is copied only once. So, if you did some changes to the settings file (mock.jsonordevelopment.jsonorstaging.jsonorproduction.json), you have to re-run this command.
yarn dev- starts the application for development environmentyarn dev:watch- starts the application for development environment in watch modeyarn dev:all- lints the code with fixing, builds and starts the application for development environment
The command
yarn dev:allis kid of a single command to rule them all, usually it's used in development for starting the app faster.
yarn dev:copy:settings- copies the development settings file to output directory
When you run
yarn dev:copy:settingsthe settings file is copied fromsrc/presentation/settings/development.jsonintodist/presentation/settingsfolder.
yarn staging:build- executes the build for staging environmentyarn staging- starts the application for staging environmentyarn staging:watch- starts the application for staging environment in watch modeyarn staging:all- lints the code with fixing, builds and starts the application for staging environment
The command
yarn staging:allis kid of a single command to rule them all, usually it's used in development for starting the app faster.
yarn staging:copy:settings- copies the staging settings file to output directory
When you run
yarn staging:copy:settingsthe settings file is copied fromsrc/presentation/settings/staging.jsonintodist/presentation/settingsfolder.
yarn production:build- executes the build for production environmentyarn production- starts the application for production environmentyarn production:watch- starts the application for production environment in watch modeyarn production:all- lints the code with fixing, builds and starts the application for production environment
The command
yarn production:allis kid of a single command to rule them all, usually it's used in development for starting the app faster.
yarn production:copy:settings- copies the production settings file to output directory
When you run
yarn production:copy:settingsthe settings file is copied fromsrc/presentation/settings/production.jsonintodist/presentation/settingsfolder.
- Awilix
- express
- express-graphql
- graphql
- mongodb
- reflect-metadata
- rxjs
- typeorm
- copyfiles
- cross-env
- jest
- nodemon
- onchange
- sinon
- tslint
All dependencies can be viewed inside the
package.jsonfile, inside thedependenciesanddevDependenciessections.