ThinBlock's core API is built on restify framework. It depends on NodeJS server v8.11.2
and tests are written with chai
and runner is mocha
. The database is PostgreSQL with Sequelize ORM. We use TypeScript langauge to write strongly typed code which has less chances of breaking and better intellisense support in VS Code.
We use yarn
to install the packages. Do
yarn install
in the project's directory. After installing you need to set up environment variables. In Unix based systems you can do:
export TB_CORE_API_DB="Postgresql db string here"
export TB_ETH_NODE="Ethereum node string here"
Contact the collaborators to get remote db string and node string.
To start the development server do
yarn start
To watch the typescript files you can use nodemon
, if you don't have nodemon
installed you can install it via
yarn add nodemon -g
// now start watching, do this in project's directory
nodemon
- app
- interfaces (interfaces gives better intellisense and strong type)
- utils (typescript interfaces for utils goes here)
models.ts (interfaces for model goes here)
- middlewares (middlewares go here)
- models (add models here, it should contain .model at the end of the file)
- modules
- some_module (modules go here, it should be abstracted as domain)
- some_module.controller.ts
- some_module.route.ts
- some_module.unit.spec.ts
- config (Config related stuff)
- types (When types for certain package doesn't exist, add that package here)
- utils (Utilities and helpers
server.ts
package.json
When adding new libraries/packages, you should install its types too. If its types don't exist then you should add that package to types/types.ts
yarn add some-package @types/some-package
Every module should be battle tested so that we avoid any bugs. We have CI integrated, whenever introducing new feature. We'll run the tests before merging any stuff. You should make sure all tests pass. You can run tests by doing
yarn run test
It'll run all the tests, if you want to run your specific test. You can do this
describe.only()
or
it.only()