0. Prerequisites

Name Version Link
NodeJS >=10 https://nodejs.org
MySQL >=5.7.27 https://dev.mysql.com/downloads/mysql/
Redis >=6.2.0 mac/linux: https://redis.io
windows download: windows-redis-7.0.5

Why use Redis?

  • CabloyJS supports distribution through Redis. Therefore, cluster expansion can be done easily

Any question, see also: FAQ - Summary List

0. Install Lerna

  1. 1$ sudo npm i -g lerna

1. Create a project

Create a project named as cabloy-demo,then install all dependencies

  1. 1# create a project
  2. 2$ npm init cabloy cabloy-demo
  3. 3# go to project directory
  4. 4$ cd cabloy-demo
  5. 5# install dependencies
  6. 6$ lerna bootstrap

Take notice: Use lerna bootstrap to install project dependencies, not npm install

2. Configure Redis

Cluster now becomes the first class citizen of CabloyJS. In other words, the CabloyJS project is ready to be deployed in a clustered environment

The cluster feature of CabloyJS is designed based on Redis. Therefore, the connection configuration information of Redis needs to be set

Take notice: Use the default configuration, and just confirm whether the host and port parameters meet the actual values

3. Configure MySQL

CabloyJS provides three runtime environments. Therefore, it is necessary to set up the database connection configuration of the three runtime environments separately

Take notice: Use the default configuration, and just confirm whether the host, port, user and password parameters meet the actual values

4. Unit-Test

  1. 1$ npm run test:backend

CabloyJS recommends a test-driven development mode. By test-driven, you can lock in the results of development, and when there are code changes, you can find problems as soon as possible, so as to solve problems

In addition, the database schema changes frequently during the development stage, when only one unit test command is needed to take effect, which means that the old test database is always deleted and a new test database is created automatically

5. Run

Start backend service

  1. 1$ npm run dev:backend

Start frontend service

  1. 1$ npm run dev:front

6. Enjoy

Appendix 1. Docker Compose

There is a docker-compose.yml configuration file in the root directory of the project. If you have installed the docker compose environment, you can start all services of CabloyJS with only one command, including Redis, MySQL, Nginx and CabloyJS backend service

  1. 1$ sudo docker-compose build
  2. 2$ sudo docker-compose up

Appendix 2. Install Core Modules freely

Because the built-in core modules of CabloyJS are installed in the directory node_modules, if you want to browser the source codes of any core module, you can install it into the project directory: {project}/src/suite-vendor or {project}/src/module-vendor

  1. 1# install base module: a-base-sync
  2. 2$ npm run cli :store:sync a-base-sync
  3. 3# install cms module: a-cms
  4. 4$ npm run cli :store:sync a-cms
  5. 5# install NodeJS-Workflow-Engine module: a-flow
  6. 6$ npm run cli :store:sync a-flow
  • To browser more core modules, refer to: Cabloy Store

    • The core modules are free, but you still need to generate a free purchase record on Cabloy Store, so that you can download and install it on the command line
  • To learn more about cli commands, refer to: Cli Terminal

Appendix 3. Test Suites/Modules

Test suites/modules Contains a large number of test-cases and kitchen-sink, and continues to add more content. It is not only convenient to quickly learn all aspects of knowledge points of CabloyJS, but also convenient to quickly start the actual business development

  1. 1# install suite: test-party
  2. 2$ npm run cli :store:sync test-party
  3. 3# install module: test-note
  4. 4$ npm run cli :store:sync test-note
  5. 5# install module: test-flow
  6. 6$ npm run cli :store:sync test-flow

Appendix 4. Update

  • Update Cabloy

Open filepackage.json, set cabloy to the latest version, and then reinstall dependencies again:

  1. 1# reinstall dependencies
  2. 2$ lerna bootstrap
  • Update Vendor Suites/Modules

Since third-party suites/modules are located in the source code directory {project}/src/suite-vendor and {project}/src/module-vendor, separate commands are required to update them

  1. 1$ npm run cli :store:sync

Appendix 5. Disable login verification code for development

💐 Further Reading

When you have created the first CabloyJS project, you can refer to the following tutorials to have a preliminary understanding of the out-of-the-box effect and flexible-customization mechanism:

1. Start to out-of-the-box

2. Start to flexible-customization