Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
arvind-balaji committed Dec 26, 2018
1 parent d2b6e31 commit 24d02b9
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 8,457 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ git
node_modules
build
npm-debug.log
yarn-error.log
scrape
.env
.DS_Store
36 changes: 36 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require('dotenv').config();

const express = require('express');
const app = express();
const router = express.Router();
const bodyParser = require('body-parser');
const cors = require('cors')

const fs = require('fs');
const port = process.env.PORT || 8080;

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.set('json spaces', 2);
app.use(cors())


// test route to make sure everything is working
router.get('/', function(req, res) {
res.json({message: 'It Works! Welcome to the CardDB API!'});
});

// dynamically load our routes
fs.readdirSync('./routes/').forEach(function(file) {
if(file.indexOf('.js') > 0){
var route="./routes/"+file;
require(route)(router);
}
});

// all of our routes will be prefixed with /api
app.use('/v1', router);

// start the server
app.listen(port);
console.log('Magic happens on port ' + port);
6 changes: 6 additions & 0 deletions env-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SOLR_DEV_CONN_URL=http://<MY_SOLR_INSTANCE>/solr/<MY_SOLR_CORE>
SOLR_LOCAL_CONN_URL=http://<MY_SOLR_INSTANCE>/solr/<MY_SOLR_CORE>

MONGO_DEV_CONN_URL=mongodb://<MY_MONGO_INSTANCE>
MONGO_LOCAL_CONN_URL=mongodb://<MY_MONGO_INSTANCE>
MONGO_DB_NAME=<MY_DB_NAME>
Loading

0 comments on commit 24d02b9

Please sign in to comment.