Skip to content

moleculerjs/project-demo

Repository files navigation

Moleculer

project-demo

This is a Moleculer-based microservices project. Generated with the Moleculer CLI.

Template architecture

Moleculer supports different deployment modes. The figures below represent the deployment and production architectures. Switching between the architectures is automatically handled by moleculer. To run in dev mode use npm run dev, for production mode run npm run dc:up.

Development architecture view

dev arch

Production architecture view

distributed arch

Usage

Start the project with npm run dev command. After starting, open the http://localhost:3000/ URL in your browser. On the welcome page you can test the generated services via API Gateway and check the nodes & services.

In the terminal, try using Moleculer REPL by running the following commands:

  • nodes - List all connected nodes.
  • services - List all the available services.
  • actions - List all registered service actions.
  • info - List node info (e.g., IP, memory usage).
  • call greeter.hello - Call the greeter.hello action.
  • call greeter.welcome --name John - Call the greeter.welcome action with the name parameter.
  • call products.list - List the products (call the products.list action).

Services

  • api: API Gateway services
  • greeter: Sample service with hello and welcome actions.
  • products: Sample DB service. To use with MongoDB, set MONGO_URI environment variables and install MongoDB adapter with npm install mongodb.
  • inventory: Sample service with a single channel handler that uses persistent queues to reliably process the messages.

Mixins

Useful links

NPM scripts

  • npm run dev: Start development mode (load all services locally with hot-reload & REPL)
  • npm run start: Start production mode (set SERVICES env variable to load certain services)
  • npm run cli: Start a CLI and connect to production. Don't forget to set production namespace with --ns argument in script
  • npm run lint: Run ESLint
  • npm run ci: Run continuous test mode with watching
  • npm test: Run tests & generate coverage report
  • npm run dc:up: Start the stack with Docker Compose
  • npm run dc:down: Stop the stack with Docker Compose

About

Demo Project. Generated by official "project" template

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published