denrox / nestjs-microservices-example Goto Github PK
View Code? Open in Web Editor NEWA working example of microservice architecture implementation using nestjs framework
A working example of microservice architecture implementation using nestjs framework
How do we share code if something like the file below is used by multiple microservices?
Also will npm workspace be used when it is available in node 16 LTS?
Anyway thank you for this very informative example...
It seems all the requests are going to be sent to the gateway service. Since one of the issues that microservices resolve is scalability, in this case, it seems we should vertically scale the server (not horizontally).
Can the front side talk to each microservice instead of the gateway? Any idea?
Initial installation of the platform gives me an issue.
Comand:
docker network create infrastructure && cp .env.example .env && docker-compose up -d
Issue:
unexpected character "<" in variable name near "<[email protected]>\n"
➜ cd ./gateway && npm install && npm run test
> [email protected] test
> jest --config ./test/jest-e2e.json --detectOpenHandles
(node:32062) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(Use `node --trace-deprecation ...` to show where the warning was created)
FAIL test/task.e2e-spec.ts
● Tasks (e2e) › /users/ (POST) - should create a user for checking tasks api
MongoNetworkError: failed to connect to server [db:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND db
at connectionFailureError (../node_modules/mongodb/lib/core/connection/connect.js:340:14)
at Socket.<anonymous> (../node_modules/mongodb/lib/core/connection/connect.js:310:16)
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'db'
}]
at Pool.<anonymous> (../node_modules/mongodb/lib/core/topologies/server.js:438:11)
at ../node_modules/mongodb/lib/core/connection/pool.js:562:14
at ../node_modules/mongodb/lib/core/connection/pool.js:995:11
at ../node_modules/mongodb/lib/core/connection/connect.js:32:7
at callback (../node_modules/mongodb/lib/core/connection/connect.js:280:5)
at Socket.<anonymous> (../node_modules/mongodb/lib/core/connection/connect.js:310:7)
➜ ls ./node_modules/mongodb/lib/core/connection/connect.js
./node_modules/mongodb/lib/core/connection/connect.js
➜ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nestjs-microservices-example_task latest 8f6ea10c6c9c 2 hours ago 301MB
nestjs-microservices-example_token latest d91cd08050e6 2 hours ago 304MB
nestjs-microservices-example_user latest 4ea9ae968a07 2 hours ago 305MB
nestjs-microservices-example_permission latest 45fc5c5b4651 2 hours ago 287MB
nestjs-microservices-example_mailer latest bc43a7509bca 2 hours ago 312MB
nestjs-microservices-example_gateway latest be198aa8b10e 2 hours ago 376MB
mongo 3.7 3db1239d511b 3 years ago 365MB
➜ docker network ls
NETWORK ID NAME DRIVER SCOPE
c1f91c7540aa bridge bridge local
cd35c2d8606f host host local
e202db18ab24 infrastructure bridge local
bb8f103e8d56 nestjs-microservices-example_backend bridge local
ae658c26cd1e none null local
➜ ls -l
total 1224
-rw-r--r-- 1 monolithed staff 188 26 июл 10:06 Dockerfile
-rw-r--r-- 1 monolithed staff 84 26 июл 10:06 nest-cli.json
drwxr-xr-x 524 monolithed staff 16768 26 июл 11:35 node_modules
-rw-r--r-- 1 monolithed staff 598555 26 июл 11:35 package-lock.json
-rw-r--r-- 1 monolithed staff 1555 26 июл 11:35 package.json
drwxr-xr-x 9 monolithed staff 288 26 июл 10:06 src
drwxr-xr-x 11 monolithed staff 352 26 июл 10:06 test
-rw-r--r-- 1 monolithed staff 97 26 июл 10:06 tsconfig.build.json
-rw-r--r-- 1 monolithed staff 362 26 июл 10:06 tsconfig.json
-rw-r--r-- 1 monolithed staff 503 26 июл 10:06 tslint.json
It throws error that 2023-03-31 13:09:51 [Nest] 47 - 03/31/2023, 7:39:51 AM ERROR [ExceptionsHandler] connect ECONNREFUSED 172.23.0.8:8002
2023-03-31 13:09:51 Error: connect ECONNREFUSED 172.23.0.8:8002
2023-03-31 13:09:51 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
whenver I try to hit any endpoint
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.