Code Monkey home page Code Monkey logo

drivine-inspiration's Introduction

DrivineSplash

⚠️ Drivine website has moved: here.

What is It?

This sample app quick start template for drivine. The intention is that you can get rolling as quickly as possible.

Running the App

  • Set up either Neo4j or AgensGraph on your workstation.
  • Copy the .env.example to .env. Uncomment either the Neo4j or AgensGraph settings. Edit if necessary.
  • Start the app with npm start.

Traffic Routes

⚠️ Please load this gist before running the tests or the app.

Neo4j

Consult the Neo4j quick start guide for instructions getting set up.

Open localhost:7474 and paste the query above in the browser console.

AgensGraph

Consult the AgensGraph quick start Guide to get set up.

  • create vlabel Metro;
  • create elabel HAS_ROUTE;
cd src/traffic
~/$AGENSGRAPH_HOME/bin/agens --dbname $DATABASE_NAME < ./test-data.cypher
# For example: ~/liberation-data/agensgraph/bin/agens movies < ./test-data.cypher

List routes between two cities

GET /routes/between/:start/:dest

Lists the routes between two cities, ordered by fastest to slowest.

Example: GET /routes/between/Pigalle/NYC

Results:

[{"destination":"NYC","via":[],"travelTime":8.5},{"destination":"NYC","via":["China Town"],"travelTime":18.5},{"destination":"NYC","via":["NYC","Sta Isabel","Puerto del Postigo"],"travelTime":24},{"destination":"NYC","via":["NYC","Puerto del Postigo","Sta Isabel"],"travelTime":24},{"destination":"NYC","via":["China Town","Ermita","Puerto del Postigo","Sta Isabel"],"travelTime":24.5},{"destination":"NYC","via":["China Town","Ermita","Puerto del Postigo"],"travelTime":30},{"destination":"NYC","via":["China Town","Divisoria","Bastille","Puerto del Postigo","Sta Isabel"],"travelTime":31},{"destination":"NYC","via":["China Town","NYC","Sta Isabel","Puerto del Postigo"],"travelTime":34},{"destination":"NYC","via":["China Town","NYC","Puerto del Postigo","Sta Isabel"],"travelTime":34},{"destination":"NYC","via":["China Town","Divisoria","Bastille","Puerto del Postigo"],"travelTime":36.5},{"destination":"NYC","via":["NYC","Sta Isabel","Puerto del Postigo","Ermita","China Town"],"travelTime":39.5},{"destination":"NYC","via":["NYC","China Town","Ermita","Puerto del Postigo","Sta Isabel"],"travelTime":39.5},{"destination":"NYC","via":["China Town","St Germain","Intramuros","China Town"],"travelTime":44.1},{"destination":"NYC","via":["China Town","Intramuros","St Germain","China Town"],"travelTime":44.1},{"destination":"NYC","via":["China Town","Intramuros","Bastille","Puerto del Postigo","Sta Isabel"],"travelTime":44.5},{"destination":"NYC","via":["NYC","Puerto del Postigo","Ermita","China Town"],"travelTime":45},{"destination":"NYC","via":["NYC","China Town","Ermita","Puerto del Postigo"],"travelTime":45},{"destination":"NYC","via":["China Town","Intramuros","Bastille","Puerto del Postigo"],"travelTime":50},{"destination":"NYC","via":["NYC","Puerto del Postigo","Bastille","Divisoria","China Town"],"travelTime":51.5},{"destination":"NYC","via":["NYC","China Town","Divisoria","Bastille","Puerto del Postigo"],"travelTime":51.5},{"destination":"NYC","via":["China Town","St Germain","Intramuros","Bastille","Puerto del Postigo"],"travelTime":53.6},{"destination":"NYC","via":["China Town","Divisoria","Bastille","Intramuros","China Town"],"travelTime":60},{"destination":"NYC","via":["China Town","Intramuros","Bastille","Divisoria","China Town"],"travelTime":60},{"destination":"NYC","via":["NYC","Puerto del Postigo","Bastille","Intramuros","China Town"],"travelTime":65},{"destination":"NYC","via":["NYC","China Town","Intramuros","Bastille","Puerto del Postigo"],"travelTime":65}]

Exercises

  • Create an endpoint to mark a route between two cities as blocked.
  • Modify the routing query to handle road closures. There is a tutorial for that here.

Movies

⚠️ Please load this gist before running the tests or the app.

Neo4j

Consult the Neo4j quick start guide for instructions getting set up.

Open localhost:7474 and paste the query above in the browser console.

AgensGraph

Consult the AgensGraph quick start Guide to get set up.

  • create vlabel Person;
  • create vlabel Movie;
  • create elabel ACTED_IN;
  • create elabel PRODUCED;
  • create elabel REVIEWED
  • create elabel WROTE;
cd src/movies
~/$AGENSGRAPH_HOME/bin/agens --dbname $DATABASE_NAME < ./test-data.cypher
# For example: ~/liberation-data/agensgraph/bin/agens traffic < ./test-data.cypher

List Movies for Actor

GET /actors/:name/movies

Returns the movies for an actor.

Example:

GET /actors/Tom%20Hanks/movies

Results:

{"actor":{"name":"Tom Hanks","born":1956},"movies":[{"title":"Apollo 13","tagline":"Houston, we have a problem.","released":1995},{"title":"The Da Vinci Code","tagline":"Break The Codes","released":2006},{"title":"Sleepless in Seattle","tagline":"What if someone you never met, someone you never saw, someone you never knew was the only someone for you?","released":1993},{"title":"That Thing You Do","tagline":"In every life there comes a time when that thing you dream becomes that thing you do","released":1996},{"title":"The Polar Express","tagline":"This Holiday Season… Believe","released":2004},{"title":"You've Got Mail","tagline":"At odds in life... in love on-line.","released":1998},{"title":"Joe Versus the Volcano","tagline":"A story of love, lava and burning desire.","released":1990},{"title":"A League of Their Own","tagline":"Once in a lifetime you get a chance to do something different.","released":1992},{"title":"Cast Away","tagline":"At the edge of the world, his journey begins.","released":2000},{"title":"The Green Mile","tagline":"Walk a mile you'll never forget.","released":1999},{"title":"Charlie Wilson's War","tagline":"A stiff drink. A little mascara. A lot of nerve. Who said they couldn't bring down the Soviet empire.","released":2007},{"title":"Cloud Atlas","tagline":"Everything is connected","released":2012}]}

Exercises

  • Add an endpoint to list the actors that a given actor has worked with, historically.
  • Add an endpoint: Given two actors who have not worked together, calculate someone who can introduce them.
  • Try the Neo4j movies tutorial - :play movies in your Neo4j browser.

Troubleshooting!

The number one first-timer's mistake is to use the wrong database driver. It happens. Here's how to fix:

  • Copy env.example to .env
  • ⚠️ Make sure you uncomment the correct section for your database. The AgensGraph driver won't work for Neo4j and vice-versa.

Feedback

I'm not sure how to do [xyz]

If you can't find what you need in the Quick Start or User Guides, please post a question on StackOverflow, using the Drivine tag.

I've found a bug, or have a feature request

Please raise a GitHub issue.

License

Copyright (c) 2019 Liberation Data

This quick start is released under Apache 2.0.

drivine-inspiration's People

Contributors

dependabot[bot] avatar jasperblues avatar xnor104 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

drivine-inspiration's Issues

.cypher files missing after transpilation

After the build step there are no .cypher files in the dist directory. That is because of tsc behaviour to only include ts/js files. How did you manage to get it to work?

Cannot find module '/****/api/dist/user/repository/userById.cypher'
Require stack:

  • /****/api/node_modules/@liberation-data/drivine/DrivineInjectionDecorators.js

Cannot start application because of PersistenceManager injection

Local neo4j instance running at v4.1

docker run \     
    --publish=7474:7474 --publish=7687:7687 \
    --volume=$HOME/neo4j/data:/data \
    neo4j

.env confirguration

SERVER_PORT=3000

NODE_ENV=dev

#Valid options are [VERBOSE, DEBUG, INFO, WARN, ERROR, NONE]
DRIVINE_LOG_LEVEL=VERBOSE

NEO_DATABASE_TYPE=NEO4J
NEO_DATABASE_USER=neo4j
NEO_DATABASE_PASSWORD=neo4j
NEO_DATABASE_HOST=localhost
NEO_DATABASE_PORT=7687

Logs

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[Nest] 37857   - 10/10/2020, 17:17:39   [NestFactory] Starting Nest application...
[Nest] 37857   - 10/10/2020, 17:17:39   [InstanceLoader] AppModule dependencies initialized +18ms
[Nest] 37857   - 10/10/2020, 17:17:39   [ExceptionHandler] Nest can't resolve dependencies of the HealthRepository (?). Please make sure that the argument PersistenceManager:default at index [0] is available in the HealthModule context.

Potential solutions:
- If PersistenceManager:default is a provider, is it part of the current HealthModule?
- If PersistenceManager:default is exported from a separate @Module, is that module imported within HealthModule?
  @Module({
    imports: [ /* the Module containing PersistenceManager:default */ ]
  })
 +3ms
Error: Nest can't resolve dependencies of the HealthRepository (?). Please make sure that the argument PersistenceManager:default at index [0] is available in the HealthModule context.

Potential solutions:
- If PersistenceManager:default is a provider, is it part of the current HealthModule?
- If PersistenceManager:default is exported from a separate @Module, is that module imported within HealthModule?
  @Module({
    imports: [ /* the Module containing PersistenceManager:default */ ]
  })

New to nest not entirely sure where the issue is, PersistenceManager isnt injected into the Health module directly.
Two injection points I think are the HealthRepository and the root instantiation of Drivine

Is there a need to inject PersistenceManager into each module?

Note

Removed the ^ from all the deps in the package.json and deleted to package-lock.json and did a clean npm i still ran into the same issue.
Wanted to make sure some other dependencies weren't causing the issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.