Skip to content

Latest commit

 

History

History
135 lines (79 loc) · 1.81 KB

12_Code_Sharing_and_Reuse_Between_Services.md

File metadata and controls

135 lines (79 loc) · 1.81 KB

[Stephen Grider] Microservices with Node JS and React [ENG, 2020]

12. Code Sharing and Reuse Between Services


01. Shared Logic Between Services


Application


02. Options for Code Sharing


Application


Application


03. NPM Organizations


Application


npmjs --> create organization


Application


04. Publishing NPM Modules

$ cd app
$ mkdir common
$ cd common/
$ npm init -y

$ git init
$ git add .
$ git commit -m "initial commit"

$ npm login
$ npm publish --acces public

05. Project Setup

$ tsc --init
$ npm install --save-dev typescript del-cli

tsconfig.json

"declaration": true
"outDir": "./build"

$ npm run build

06. An Easy Publish Command


$ npm version patch
$ npm run build

07. Relocating Shared Code

auth/src/errors copy to common/src/errors
auth/src/middlewares copy to common/src/middlewares
$ npm install --save \
express \
express-validator \
cookie-session \
jsonwebtoken \
@types/cookie-session \
@types/express \
@types/jsonwebtoken

$ tsc

$ npm run publish

08. Updating Import Statements

$ cd auth
$ npm install --save @grider-ms-tickets/common

09. Updating the Common Module

$ cd auth
$ npm update @grider-ms-tickets/common


Marley

Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат