Skip to content

minhducant/base_nestjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"Hallo-backend"

Description

hallo backend

Running the app in the first time

Remember install docker, docker-compose before run command below:

$ cp .env.example .env 

$ docker-compose up -d

Replica mongo:

Window:See in https://help.tenten.vn/https-tenten-vn-help-huong-dan-cai-dat-openssl-tren-win10/ to install OpenSSL in Windows 10 to create keyfile

$ openssl rand -base64 756 > /mongodb-keyfile.key
$ chmod 400 /mongodb-keyfile.key

to set up replica

$ docker exec -it mongodb-prime  bash 
$ mongosh --username "root" --password "example"                                                                      
var config = {
  "_id" :"rs0",
  "version" :1,
  "members" : [
    {
        "_id" : 1,
        "host" :"mongodb-prime:27017",
        "priority" : 3,
    },
    {
        "_id" : 2,
        "host" :"rep1:27017",
        "priority" : 2,
    },
    {
        "_id" : 3,
        "host" :"rep2:27017",
        "priority" : 1,
    },
  ]
};

$ rs.initiate(config,{ force :true });

Migration:

See in link

Seed:

$ yarn console:dev seeder

Test:

Run test:

$ docker-compose up -d
$ yarn typeorm:run
$ make init-test
$ yarn test

Coding conventions

  • Using space (not tab)
  • Using absolute path: config in vscode: open settings.json -> setting
      "javascript.preferences.importModuleSpecifier": "non-relative",
      "typescript.preferences.importModuleSpecifier": "non-relative" 
    
  • RESTful API:
  • Filename and URL path: using - as separator
  • Name of file and class must use singular noun. Avoid using plural noun. Plural is used only with array of data.
  • Avoid using any in typescript as much as possible
  • Avoid SELECT * in sql query
  • Except entity.ts, others should be named as plural (E.g: orders.service.ts, NOT order.service.ts)
  • Code comment: prefer self-explanatory code, should comment at class and function level
  • Columns in entity follow by camel case.
  • Tables name in database follow plural noun.
  • Using connection: report for read, master for write.
  • Commit Convention: see in link

Some techniques

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •