Home

Awesome

MostlyJS Demos

Build Status

Code structure

The MostlyJS microservices demo project splits codebases into multiple separate independently packages in one repository using a Monorepos approach.

But instead of using Lerna, the project follows a simple Alle Monorepo architecture. You have a file system looks like this:

|-- my-project-repo/
|   |-- package.json
|   |-- packages/node_modules
|   |   |-- package-1/
|   |   |   |-- package.json
|   |   |-- package-2/
|   |   |   |-- package.json

Each services/modules lives under the packages/node_modules, so that you can require common modules in a very simple way without resorting to npm link.

var package1 = require('package-1');

Because require() just walks up the file tree until it finds a node_modules folder with a sub-folder that matches the package name.

The project uses gulp to build the project and PM2 for production deployment.

The project contains the following seperated packages:

express-gateway

An Express demo application serve as a RESTful gateway for calling MostlyJS microservices. Request will be mapping to corresponding microservice.

feathers-service

Sample microservice writing with Feathers.

poplarjs-service

Sample microservice writing with Poplarjs.

feathers-mongoose-services

More complicated sample microservices writing with Feathers using MongoDB.

common

Common modules to be used by other services, for demo only.

Usage

Install and Run NATS Server

https://nats.io/documentation/tutorials/gnatsd-install

Install dependencies in each packages using YARN

$ yarn
$ ./bin/yarn_packages.sh

Run with gulp

$ gulp

Run with PM2

$ bin/run_development.sh

License

MIT