Home

Awesome

                              .   ..  . . .... ....... ........ .... ....................
   ___________    _______  ___________  _________    ______  __________  ______ .::::::::
   _\ ___.   /_____\_   /_ _\ ___.   /  _\      /___ _\ __/_ _\       /  _\   / :::::::::
   |"   /   / | __      "| |"   /   /__ !__    ____/ |"    / |"  /___/__ |"  /____  .::::
   | \_____/  | /        | |  \_      /   |"    /    |    /  |  /      / |  /    / .:::::
   !_____|    !_______/__| !____\____/    !____/     !___/   !________/  !______/ .::::::
                                        .   . ..:.::. .....::. . . ....::.........:::::::
           ________     _______  ___________  _____ . ..::. __________ _________ .:::::::
    ______ /  _.  / _____\_   /_ _\ ___.   /  _\  /______ . _\ _.    / _\      /___  ::::
   __\ _  /   /  /_ | __      "| |"   /   /__ |" /   ___/___|" /    /__|__   _____/ .::::
   |"   \ `  /  / | | /        | |  \_      / |    \       /|  ____/  |  |"    /  .::::::
   !_____\__/_____| !_______/__| !____\____/  !_____\_____/ !_________|  !____/ .::::::::
                                                             . .. . ...........::::::::l!

Getting Started

Step 1: Set up the Development Environment

You need to set up your development environment before you can do anything.

Install Node.js and NPM

Then install yarn globally

npm install yarn -g 

And finally install Docker

Step 2: Set up the Project

Fork this project.

Then copy the .env.example file and rename it to .env. In this file you can edit your database connection information among other stuff, but everything should really work out of the box.

Then setup your application environment.

npm run setup

This installs all dependencies with yarn. After that it migrates the database and seeds some test data into it. So after that your development environment is ready to use.

Step 3: Serve your App

Go to the project dir and start your app with this npm script.

npm run serve

This starts a local server using nodemon, which will watch for any file changes and will restart the server according to these changes. The server address will be displayed to you as http://0.0.0.0:3000.

Step 3b: Or serve your App using Docker

Build the docker image defined in Dockerfile and start the services.

docker-compose build
docker-compose up

This starts two marketplace applications and two particl daemons for you. app1 cli: http://localhost:3100/cli, connecting to particl1 on port 52935 app2 cli: http://localhost:3200/cli, connecting to particl2 on port 53935

Scripts / Tasks

All script are defined in the package.json file, but the most important ones are listed here.

Install

Linting

Tests

Black-box tests are run against the applications rpc-api, so you need to start the application for those to work. Integration tests start the application container and do not require the application to be running.

Running in dev mode

Building the project and run it

Database

Console

Scaffolding Commands

All the templates for the commands are located in src/console/templates.

Example

$ npm run console make:service ExampleService
// -> creates `api/services/ExampleService.ts

$ npm run console make:model user
// -> creates `api/models/User.ts

WEB CLI

Documentation

Build

Compile markdown to static site from ./src/docs to ./docs:

npm run docs:build

Serve

Run a dev documentation server that live-reloads at http://localhost:4567:

npm run docs:serve [PORT] [ROOT]

IoC

Our IoC automatically looks through the controllers, listeners , middlewares, services, repositories, commands, factories, messageprocessors and models folders in src/api/ for files to bound automatically into the IoC - Container, so you have nothing to do.

However it is very important to keep the naming right, because otherwise our IoC will not find your created files!!

API Routes

The route prefix is /api by default, but you can change this in the .env file. The route for the RPC API is /api/rpc.

RouteDescription
/api/infoShows us the name, description and the version of the package.json
/statusShows a small monitor page for the server
/cliWeb based CLI to use the RPC commands
/api/rpcRPC Server endpoint

Project Structure

NameDescription
.vscode/VSCode tasks, launch configuration and some other settings
dist/Compiled source files will be placed here
src/Source files
src/api/commands/RPC Commands
src/api/controllers/REST API Controllers
src/api/exceptions/Exceptions like 404 NotFound
src/api/factories/Factories
src/api/listeners/Event listeners
src/api/messageprocessors/Marketplace messageprocessors
src/api/messages/Marketplace messages
src/api/middlewares/Express Middlewares
src/api/models/Bookshelf Models
src/api/repositories/Repository / DB layer
src/api/requests/Request bodys with validations
src/api/services/Service layer
src/console/Command line scripts
src/config/Configurations like database or logger
src/constants/Global Constants
src/core/The core framework
src/database/factories/Model factories to generate database records
src/database/migrations/Migrations scripts to build up the database schema
src/database/seeds/Seed scripts to fake sample data into the database
src/public/Static assets (fonts, css, js, img).
src/types/ *.d.tsCustom type definitions and files that aren't on DefinitelyTyped
testTests
test/black-box/ *.test.tsBlack-Box tests (rpc endpoint tests)
test/integration/ *.test.tsIntegration tests
test/unit/ *.test.tsUnit tests
.env.exampleEnvironment configurations
test/ .env.test.exampleTest environment configurations
knexfile.tsThis file is used for the migrations and seed task of knex

About

This project is based on Express Typescript Boilerplate Dependency Status Build Status Build status