myid-back v1.4.0
kvalifika-backend
this project was bootstraped by Nest CLI
Tech Stack
- Nest JS for development infrastructure
- Typescript for type definition
- Express
- Graphql
Directory Layout
├── .ebextensions/ # elastic beanstalk config
├── dist/ # Compiled output
├── node_modules/ # 3rd-party libraries and utilities
├── deployment/ # Deployment infrastructure
├── jest-stare/ # Nest generated test stats
├── config/ # Application config
├── views/ # Application view engine files for generating html
├── src/ # Application source code
│ ├── shared/ # Shared modules decorators helpers etc.
│ │ │── decorator/ # NestJS Shared decorators
│ │ │── middleware/ # NestJS Shared middleware
│ │ │── interceptor/ # NestJS Shared interceptors
│ │ │── scalars/ # Graphql Shared scalars
│ │ │── types/ # Typescript shared types
├── cli/ # cli commands
├── tsconfig.json # Typescript configuration
├── jest.config.js # Jest configuration
├── nest-cli.json # NestJS Config file
Getting Started
$ git clone https://github.com/vobi-io/myid-backend
$ cd myid-backend
$ yarn
$ yarn start
Environment Variables
environment variable is set by NODE_ENV env variable
Running the app
# development (starts with development environment)
$ yarn start:develop
# development (starts with development_local environment)
$ yarn start:local
# production mode (starts with staging environment)
$ yarn start:staging
Then open http://localhost:8000/ to see your app.
Open http://localhost:8000/api/ to see swagger documentation
Open http://localhost:8000/graphql/ to see graphql playground
Scripts
Start scripts
$ yarn start # takes NODE_ENV variable from cli
$ yarn start:local # starts with development_local env
$ yarn start:staging # starts with staging env
$ yarn start:prod # takes NODE_ENV variable from cli
$ yarn start:debug # starts NestJS with debug mode
Build
$ yarn prebuild # removes built directory
$ yarn build # runs nest build
$ yarn build:staging # building application on staging environment
$ yarn build:prod # building application on production environment
Testing
$ yarn test:e2e # runs jest tests
$ yarn test:e2e:coverage # runs jest tests and generates coverage
$ yarn gen:e2e:report # generates test report
CLI Commands
$ yarn set:admin <email> <isAdmin> # sets isSuperAdmin field on production db
$ yarn set:admin:dev # sets isSuperAdmin field on development db
$ yarn import:storage # this was used to import google bucket images into s3
Other Scripts
$ yarn lint # runs linter on application
$ yarn eject # not used
$ yarn analyze # analyzes sourcemap of application
Hooks
we have pre commit hook which runs linter on application and makes sure everything is okay before committing changes
Git Flow
we use Semantic Commits for branch creation and commit messages
example:
$ git checkout develop
$ git pull
$ git checkout -b feat/some-feature
$ git add .
$ git commit -m "feat: feature description"
$ git push -u origin feat/some-feature
and then create pull request to develop branch
Deployment
Follow this link
DB
UML
Packages
- @google-cloud/storage - google storage sdk
- @google-cloud/vision - google vision sdk
- @nestjs/common - NestJS core library
- @nestjs/config - NestJS configuration library
- @nestjs/core - NestJS core library
- @nestjs/graphql - NestJS Graphql addon
- @nestjs/jwt - NestJS jwt wrapper
- @nestjs/mongoose - nests wrapper to mongoose
- @nestjs/passport - passport wrapper by nestjs
- @nestjs/platform-express - NestJS express addon
- @nestjs/serve-static - NestJS Static file server
- @nestjs/swagger - NestJS Swagger documentation
- @sendgrid/mail - mail service
- @sentry/node - NodeJS Error logger for production
- archiver - Archive generator
- aws-sdk - Aws sdk
- bcryptjs - String hasher
- body-parser - Parses body of request
- class-validator - Validates body of request in class
- dotenv - Parses env files
- geoip-lite - Lookups ip location
- gm - Image manipulation library
- hbs - View engine
- helmet - Application guard
- js-levenshtein - Levenshtein distance calculator
- json2csv - Generates csv from json
- jsonwebtoken - Decodes encodes jwt
- mime-types - Gets info from mimeTypes
- mjml - Mail view engine
- moment - Nice api for working with dates
- mongoose - Mongodb
- mrz - Mrz parser
- node-fetch - Fetch api in node
- passport - Used by @nestjs/passport
- passport-jwt - Used by @nestjs/passport
- psl - Gets domain from origin
- randomatic - Random string generator
- request-ip - Gets ip from request
- rxjs - Reactive programming library
- shortid - Short id generator
- swagger-ui-express - Used by @nestjs/swagger
- twilio - Messaging api
- type-graphql - Used by @nestjs/graphql
- ua-parser-js - User agent parser
- uuid - Unique id generator
Yarn packages
- For installing dependensies use
yarn add <package>
- To add de dependency use
yarn add <package> --dev
Api versioning guides.
! Moving breaking changes to new version. old one remains unchanged.
- Example of new version vs old one http://apidev.kvalifika.com/api/v1.0/company/settings http://apidev.kvalifika.com/company/settings
Note
Version incriment should follow release managment principles. First Digit. Major Change Second Digit. Minor Change
Example of Breaking change http://apidev.kvalifika.com/api/v2.0/company/settings
Example of Minor change change. http://apidev.kvalifika.com/api/v2.1/company/settings