Moleculer codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
This repo is functionality complete — PRs and issues welcome!
Live demo on Glitch: https://realworld-moleculer.glitch.me
Glitch project: https://glitch.com/edit/#!/realworld-moleculer
React + Redux front-end UI is included. For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
- Clone this repo
npm install
to install all required dependenciesnpm run dev
to start the local server- the API is available at http://localhost:3000/api
Alternately, to quickly try out this repo in the cloud, you can
Basically the services stores data in an NeDB persistent file storage in the ./data
folder. If you have to use MongoDB, set the MONGO_URI
environment variable.
MONGO_URI=mongodb://localhost/conduit
You can run multiple instances of services. Moleculer uses TCP transporter to communicate all instances. No need any additional configuration, it uses UDP for discovery.
-
Checkout the repo
git clone https://github.com/moleculerjs/moleculer-examples.git
-
cd moleculer-examples/conduit
-
Start with docker-compose:
docker-compose up -d --build
It starts all services in separated containers, a Redis server for caching, a MongoDB server for database and a Traefik reverse proxy. All nodes communicate via Moleculer TCP transporter.
-
Open the http://docker-ip:3000 in your browser
-
Optional: Scale up services
docker-compose up -d --scale api=3 --scale articles=2 --scale users=2 --scale comments=2 --scale follows=2 --scale favorites=2
- moleculer - Microservices framework for NodeJS
- moleculer-web - Official API Gateway service for Moleculer
- moleculer-db - Database store service for Moleculer
- moleculer-db-adapter-mongo - Database store service for MongoDB (optional)
- jsonwebtoken - To generate JWTs used by authentication
- bcrypt - Hashing user password
- lodash - Utility library
- slug - To encode titles into a URL-friendly format
- ioredis - Redis server for caching (optional)
moleculer.config.js
- Moleculer ServiceBroker configuration file.services/
- This folder contains the services.public/
- This folder contains the front-end static files.data/
- This folder contains the NeDB database files.
Tested with realworld-server-tester.
Local tests is missing currently.
$ npm test
In development with watching
$ npm run ci
This project is available under the MIT license.
Copyright (c) 2016-2020 MoleculerJS