/sharing-service-neo4j

A demo sharing service running with neo4j

Primary LanguageJavaScript

How to run locally

Run only Neo4j: sudo docker-compose up neo4j

Run both webapp and db: sudo docker-compose up

Stop container(s): sudo docker-compose down

Neo4j browser: http://localhost:7474/browser/

Handy Cypher queries

Show everything: MATCH (n) RETURN n

Remove everything: MATCH (n) DETACH DELETE n

Add constraint: CREATE constraint ON (a:Asset) ASSERT a.assetRefId IS UNIQUE

TODO List (MVP):

In order of priority:

  • Setup docker compose with Neo4j image in one container and node app in another
  • Test connection between Node and Neo4j
  • Build db query and prototype endpoint for creating the share + tests
  • Build db query and prototype endpoint for getting assets shared with me + tests
  • Build db query and prototype endpoint for deleting assets I own + tests
  • Add district constraint to all queries
  • Add input data validation
  • Move from common.js to es modules with babel
  • Use logger in place of console.logs
  • Read settings from env vars (dotenv only for dev env loaded with babel)
  • Add linter and prettier and use precommit hooks
  • Refactor koa app, organize routes, create db abstraction
  • Add CI with Jenkins pipeline
  • Add unit / functional / integration tests

Notes:

  • Tests should be independent from each other - use beforeAll/Each to populate db with seed data

Ref Links:

Handy tips

Jest

Run jest for just one test file

$ npm run test:unit -- -- app/db/__tests__/connection.unit.test.js

Get console.log output in jest report

Add --verbose flag when running jest