Skip to content

Meta-Network/meta-network-backend

Repository files navigation

Nest Logo

Description

Meta Network Backend

Installation

# edit the config file
$ cp config.example.yaml config.production.yaml
$ vim config.production.yaml
$ yarn install

Running the app (choose one)

# Generate RSA Key for JWT signing
$ openssl genrsa -out JWT_PRIVATE_KEY.pem 1024

# Get RSA Public Key from the private key
$ openssl rsa -in JWT_PRIVATE_KEY.pem -pubout > JWT_PUBLIC_KEY.pub

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Test

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Conventional Commits

This project is following commitlint rules and checks the commit message with husky. You can also follow the Local setup installation guide to install this lint in your project, like following:

# Install and configure if needed
npm install --save-dev @commitlint/{cli,config-conventional}
# or
yarn add -D @commitlint/{cli,config-conventional}
echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js

# Install Husky v6
npm install husky --save-dev
# or
yarn add husky --dev

# Active hooks
npx husky install
# or
yarn husky install

# Add hook
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
# or
yarn husky add .husky/commit-msg 'yarn commitlint --edit $1'

Coding Stye

Lint-staged

npx mrm@2 lint-staged

Microservices

Hybrid applcation + NATS

MessagePattern

camelCase

  • findHexGridByUserId

EventPattern

lowwercase + dot

  • user.profile.modified
  • ``

Docker

Build

docker build -t metaio/meta-network:v0.0.1 .

Docker-compose

Redis + NATS + Meta-UCenter-BE + Meta-Network-BE

default as production environment

config path:

  • meta-ucenter: /var/docker/meta-ucenter/config
  • meta-network: /var/docker/meta-network/config

Can be changed in the docker-compose.yml file

network:
  build: .
  ports:
    - '3001:3000'
  # config path
  volumes:
    - /var/usr/local/meta-network/config:/app/config
  # development environment
  environment:
    - NODE_ENV=development
  depends_on:
    - redis
    - nats
  restart: on-failure

You should add config.development.yaml config.biz.development.yaml files in the config paths.

/var/docker
|____meta-network
| |____config
| | |____config.production.yaml
| | |____rds-ca-2019-root.pem
| | |____config.biz.production.yaml
| | |____config.biz.example.yaml
| | |____config.example.yaml
| | |____JWT_PUBLIC_KEY.pub
|____meta-ucenter
| |____config
| | |____config.production.yaml
| | |____rds-ca-2019-root.pem
| | |____config.biz.production.yaml
| | |____config.example.yaml
| | |____JWT_PUBLIC_KEY.pub
| | |____JWT_PRIVATE_KEY.pem
# create & start
docker-compose up -d
# stop
docker-compose stop
#start
docker-compose start
# restart
docker-compose restart
#log (execute in a new terminal)
## network
docker-compose logs --follow network
## ucenter
docker-compose logs --follow ucenter
# stop & remove
docker-compose down

docker-compose-base.yml

development dependencies: Redis + NATS

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages