1.0.0 • Published 6 years ago

@madbean/services v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Micro Services Help.

Lerna

Lerna is a monorepo manager

  • /
    • packages.json
    • lerna.json
    • /packages
      • some_module
        • package.json
        • /src
          • index.js
          • /test x.test.js
        • node_modules
      • ...

Init lerna repo

# in the git repo.
npm i -g lerna
# independent make each repo version independent.
# so only updated packages will be bumped.
lerna init --independent

how to init this repo

# git clone the repo then cd service/
npm install

# bootstrap :
# npm install all external dependencies of each package.
# Symlink together all Lerna packages that are dependencies of each other.
# npm prepublish all bootstrapped packages.
lerna bootstrap

run a service

# go to the package of your choice
cd packages/users/

# then in dev mode run
npm run dev

# go to
http://localhost:3000/

# if you make some modification and save the file the server will auto restart
# stop it
Ctrl + C

# run tests
npm run test

Publish package lerna manualy /!\ don't do this if you don't know what you are doing !

# publish
lerna publish --cd-version patch --yes --registry=http://nexus.madbean.ovh/repository/npm/ --scoped @madbean

Install a packages in another project

# install package
npm login --registry http://nexus.madbean.ovh/repository/npm-group/
npm --registry http://nexus.madbean.ovh/repository/npm-group/ install @madbean/jobs@1.0.36

Lib

ESLint

Plugins

  • eslint
    • eslint-config-standard
  • eslint-plugin-import
  • eslint-plugin-node
  • eslint-plugin-async
    • .eslintrc
  • eslint-plugin-promise
  • eslint-plugin-standard
  • eslint-plugin-react
    • eslint-config-standard-react

Bash

split var

tab=$(lerna updated --json)
elem=$(echo "$tab" | jq '.[0] .name')
part=(${elem//@madbean\//})
echo "${part}"

rancher

#image api service
image: cdrx/rancher-gitlab-deploy

rancher compose

version: "2"

services:
  rancher-server:
    depends_on:
      - mysql
    restart: always
    image: rancher/server:v1.6.7
    ports:
      - "8099:8080"
    container_name: rancher
    links:
      - mysql:mysql
    environment:
      CATTLE_DB_CATTLE_MYSQL_HOST: mysql
      CATTLE_DB_CATTLE_MYSQL_PORT: 3306
      CATTLE_DB_CATTLE_PASSWORD: 3v0ll1SSSG
      CATTLE_DB_CATTLE_USERNAME: cattle
      CATTLE_DB_CATTLE_MYSQL_NAME: cattle

  mysql:
    restart: always
    image: mysql/mysql-server:5.7
    ports:
      - "3306"
    container_name: mysql-rancher
    volumes:
      - /data/docker/volumes/rancher/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: 3v0ll1SSSG
      MYSQL_DATABASE: cattle
      MYSQL_USER: cattle
      MYSQL_PASSWORD: 3v0ll1SSSG

token

//nexus.madbean.ovh/repository/npm/:_authToken=aa1c8e64-b825-3e62-b192-f8ce2829906b

socket.io and pub sub

  • auth
  • session
  • on socket.io connect register soket.id by user in users{}
  • redis pub sub
  • on redis recive socket.io emit
  • react revcive and dispatch