kff 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
..
.vscode 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
docs 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
factory-env 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
factory-types 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
secrets 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
src 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
static 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
test 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
.dockerignore 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
.eslintrc.js 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
.gitignore 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
.prettierrc 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
Dockerfile 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
README.md 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
nest-cli.json 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
package-lock.json 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
package.json 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
tsconfig.build.json 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ
tsconfig.json 22214bd0c3 12-11初始化代码,截止双语版本 1 dienu atpakaļ

README.md

Nginx - Reverse Proxy

Network

  • factory

Document

  • ./docs

Use and agreement

  • Folder structure
        -src
            -clients ------------------------------------------- All For App used api, and it's private
                -exampleMicroservice --------------------------- Every microservice have a single folder to use
                    -exampleMicroservice.controller.ts --------- In the position handle http request,and every controller should follow naming convention
                -....
            -admin   ------------------------------------------- All For admin used api, and it's private
                -exampleMicroservice --------------------------- Same as clients
                    -...
            -global  ------------------------------------------- Clients and admin use together, and it's private too
                -exampleMicroservice
                    -...
            -public  ------------------------------------------- All public api position
                -clients  -------------------------------------- clients used public api
                  -clientsPublic.controller.ts
                  -clientsPublic.controller.ts
                  -clientsPublic.controller.ts
                -admin    -------------------------------------- admin used public api
                  -adminPublic.controller.ts
                  -adminPublic.controller.ts
                  -adminPublic.controller.ts
                -common.controller.ts -------------------------- clients and admin public api
                -common.controller.ts -------------------------- clients and admin public api
                -common.controller.ts -------------------------- clients and admin public api
            -app.module.ts
            -main.ts
            -register.module.ts -------------------------------- For All microservice register
    
  • Every microservice have to register in src/register.module.ts
ClientsModule.register([
    {
    name:'microservice',
    transport:Transport.TCP,
    options:{
      port : 3100
    }

    }
])

Tip: "name" is same with microservice folder /src/microservice example: If we have a folder "/src/customer", there is all router for customer microservice, then "name" should be 'CUSTOMER' and port is that service port

  • ##### How to create controller and use module
  • In src/admin src/clients src/global src/public src/public/clients src/public/admin , every folder have private module, and they controller should register in they module

  • The best way of create a microservice controller is use nest cli: 'nest g co <name> <path>'


@Module({
  imports: [],
  controllers: [TestController],
})
  • When you want to use any microservice, you have to injection to controller

    constructor(
        @Inject('MICROSERVICE_SERVICE') private microservice_client:ClientProxy
        ) {}


  • Naming agreement
  • Folder

    • lower case
    • microservice controller direct use 'name'. Such as Email microservice use email
  • File have to include type such as: xxxx.module.ts or xxxx.controller.ts

    • lower case
    • If use multiple word, use . to separate
  • Class name

    • Capitalize first letter and use hump
    • Should include type and main what for such as: PClientsModule
  • Microservice register name

    • ALL CAPS
    • Have to end with _SERVER such as: CUSTOMER_SERVICE
  • Function name

    • Lower case first letter
    • Use hump
    • Forbid use meaningless word such as : a(){} or first_function(){}
    • Should simple summary the function
  • Attributes name

    • Lower case first letter
    • Use _
    • Forbid use meaningless word such as :const a = '' or const num = 0
    • Should simple summary the attributes
  • Param name

    • Lower case first letter
    • Use hump
    • Should simple summary the param

Route

Container Port TCP Port Network
MySQL 3306 null Broadcast
CDN System 12300 null Broadcast
Gateway System 12000 null factory
Env Server 12010 null factory
Env Center 12020 null factory
Customer System 12110 12100 factory
Product System 12200 null factory
ShoppingCart System 12300 null factory
Multi-Currency System 12400 null factory
Email System 12500 12500 factory
ChargeStation System 12610 12600 factory
Reservation System 12710 12700 factory
Promotion System 12810 12800 factory
Payment System 12910 12900 factory