|
| 1 | +var express = require('express'); |
| 2 | +var cors = require ('cors'); |
| 3 | +var bodyParser = require('body-parser'); |
| 4 | +var path = require('path'); |
1 | 5 | var request = require('request');
|
2 |
| -var host = 'localhost'; |
3 |
| -var port = 7474; |
4 |
| -var urlForPosting = 'http://' + host + ':' + port + '/db/data/transaction/commit'; |
5 | 6 |
|
6 |
| -var neo4j = require('neo4j'); |
7 |
| -var db = new neo4j.GraphDatabase('http://localhost:7474'); |
| 7 | +var app = express(); |
| 8 | +var port = process.env.PORT || 3000; |
| 9 | +app.listen(port); |
| 10 | + |
| 11 | +//Logger for dev environment |
| 12 | +if (process.env.NODE_ENV !== 'production') { |
| 13 | + var morgan = require('morgan'); |
| 14 | + app.use(morgan('dev')); |
| 15 | +} |
8 | 16 |
|
| 17 | +//Middleware |
| 18 | +app.use(cors()); |
| 19 | +//parse application/x-www-form-urlencoded |
| 20 | +app.use(bodyParser.urlencoded({extended: false})); |
| 21 | +//parse application/json |
| 22 | +app.use(bodyParser.json()); |
| 23 | +//serve up static files in production |
| 24 | +//app.use('/', express.static(path.resolve(__dirname, '../build'))); |
| 25 | +app.use(express.static(__dirname + '/../client')); |
9 | 26 |
|
10 |
| -var node = db.createNode({hello: 'world'}); |
11 |
| -node.save((err,node) => { |
12 |
| - if (err) { |
13 |
| - console.log('Error saving new node to database: ', err); |
14 |
| - } else { |
15 |
| - console.log('Node saved to database with id: ', node.id); |
16 |
| - } |
17 |
| -}) |
| 27 | +//Neo4j setup |
| 28 | +var neo4j = require('neo4j'); |
| 29 | +var db = new neo4j.GraphDatabase('http://localhost:7474'); |
0 commit comments