Skip to content

Latest commit

 

History

History
102 lines (72 loc) · 2.74 KB

readme.md

File metadata and controls

102 lines (72 loc) · 2.74 KB

REST API for b.tree Beekeeping Webapplication

Typescript, based on nodejs, express and knex.js, objections.js and datatables.net.

Docker

For ease of development and deploying into production, you can use Docker: https://docs.docker.com/compose/

# Build Local Docker Image
docker-compose -f docker-compose.dev.yml build
# Run Container
docker-compose -f docker-compose.dev.yml up
# Stop Container 
docker-compose -f docker-compose-dev.yml down
# Start Container
docker-compose -f docker-compose-dev.yml start
docker-compose -f docker-compose-dev.yml attach

# Access Container Bash for npm run commands
docker exec -it btree_api /bin/sh
# Start TypeScript Dev
docker exec -it btree_api npm run dev:tsc

Production

Needs already prebuild dist and mails folder to run correctly.

docker-compose -f docker-compose.prod.yml build
docker-compose -f docker-compose.prod.yml up -d
docker exec -it btree_api_production /bin/sh
# Generate Local Image
docker save btree_server_btree_api_production | gzip > btree_server_btree_api_production.tar.gz
# Load Image on Server
docker load < btree_server_btree_api_production.tar.gz

Clear Container

docker-compose -f docker-compose-*.yml rm

Local w/o Docker

Typescript and Nodemon needs to be installed globally.

npm i -g nodemon
npm i -g typescript
  • Create Directories
  • Compile and Watch Typescript
  • Start nodemon
  • Run knex commands (migrate, seed etc.)
npm run create:directories 
npm run dev:tsc 
npm run dev:node
npm run dev:knex <options>

MySQL

I use Docker with MySQL and network to connect multiple docker instances, see GitHub Repo: https://github.com/HannesOberreiter/btree-docker-mysql

You can also install MySQL on your computer and run it locally. On Mac best to install it with Homebrew, you can use the latest or specify the version with @5.7.

brew install mysql
mysql.server start
mysql.server stop

Common problems when authentication fails on local machine:

Datatables

The REST API relies on datatables.net and you will need a licence for it, if you host it for yourself.

Library Version Control

Project uses npm as management tool for libraries version control, look file is available in the repository.

Database Migration

We use knex CLI, http://knexjs.org/#Migrations-API.

npm run dev:knex <options> # eg. migrate:latest

Thanks to

The folder structure is based on https://github.com/konfer-be/ts-express-typeorm-boilerplate.