GithubHelp home page GithubHelp logo

denrox / nestjs-microservices-example Goto Github PK

View Code? Open in Web Editor NEW
818.0 818.0 240.0 71 KB

A working example of microservice architecture implementation using nestjs framework

Shell 1.00% Dockerfile 1.16% TypeScript 93.89% JavaScript 3.95%
docker docker-compose microservice-architecture microservices mongoose nestjs

nestjs-microservices-example's People

Contributors

denrox avatar dependabot[bot] avatar joker666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nestjs-microservices-example's Issues

Connecting to gateway scalability issue

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?

MongoNetworkError: failed to connect to server

➜ 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

Not able to connect with microservice when I deploye it with docker

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.