/edge-clj-rest-api-example

Project for learning of Clojure, Postrgress, RESTfull api

Primary LanguageClojureMIT LicenseMIT

REST api clj example

This simple app aim to train construction using juxt’s edge (yada) web solution

start up

dev/testing workflow

Prepare env

  cd ./wiz.blog.api
  touch .env
  echo "\
  PORT=5757          \
PROTOCOL=http      \
HOST=localhost     \
DB_USER=<db-user>  \
DB_PASSWORD=<db-pass> \
DB_NAME=<db-name>  \
DB_HOST=<db-host>  \
DB_PORT=<db-port   \
" >> .env

currently same info have to be repeated in config.edn and revolt.edn

Start db

# start DB
docker-compose up -d 

Run migration

Scheme only
# by default only schema applied, data seed should be thrown separately
clj -A:dev:migrate -t revolt.migrations.task/flyway:action=migrate
Data seed and interactive migrations withing repl
clj -A:dev:repl-migration
(info) 
+-----------+---------+---------------+------+---------------------+---------+
| Category  | Version | Description   | Type | Installed On        | State   |
+-----------+---------+---------------+------+---------------------+---------+
| Versioned | 1       | Create tables | SQL  | 2019-11-28 23:25:45 | Success |
+-----------+---------+---------------+------+---------------------+---------+
;; Also overrides to config are possible
(info {:locations ["db/migrations" "db/seed"]})
+-----------+---------+------------------+------+---------------------+---------+
| Category  | Version | Description      | Type | Installed On        | State   |
+-----------+---------+------------------+------+---------------------+---------+
| Versioned | 1       | Create tables    | SQL  | 2019-11-28 23:25:45 | Success |
| Versioned | 2       | Insert test data | SQL  |                     | Pending |
+-----------+---------+------------------+------+---------------------+---------+
(migrate {:locations ["db/migrations" "db/seed"]})
;; to seed db with test data

Start development

clj -A:dev:test:repl   
M-x -> cider-connect 
;; alternatively
, s c ;; in Spacemacs
(go)      ;; starts web server
(reset)   ;; reset all app namespaces (like HMR on front-end)

Run end-to-end tests

If application have been started as suggested in Start development section then it’s just , t a in Spacemacs which runs cider-test-run-all-tests function underneath