-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update All files to pass linting. Ensure all server tests pass
- Loading branch information
Showing
17 changed files
with
100 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"extends": "airbnb-base" | ||
"extends": "airbnb-base", | ||
"env": { | ||
"node": true, | ||
"mocha": true, | ||
"jasmine": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
const SECRETS = require('./secrets.json'); // nodejs will auto read json | ||
const SECRETS = require('./secrets.json'); // nodejs will auto read json | ||
|
||
module.exports = { | ||
NODE_ENV: process.env.NODE_ENV || 'development', | ||
HOST: process.env.HOST || 'http://localhost', | ||
PORT: process.env.PORT || 8081, | ||
DB_URL : SECRETS.mongodb_dev.db_url, | ||
GOOGLE_API_KEY: SECRETS.google_maps.api_key | ||
DB_URL: SECRETS.mongodb_dev.db_url, | ||
GOOGLE_API_KEY: SECRETS.google_maps.api_key, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
const http = require('https'); | ||
const {GOOGLE_API_KEY} = require('../config'); | ||
const { GOOGLE_API_KEY } = require('../config'); | ||
|
||
/** | ||
* Geolocation API access | ||
* Geolocation requests are sent using POST to the following URL: | ||
* https://www.googleapis.com/geolocation/v1/geolocate?key=<YOUR_KEY> | ||
*/ | ||
const GEOLOCATION_OPTIONS = { | ||
"method": "POST", | ||
"hostname": "www.googleapis.com", | ||
"port": null, | ||
"path": `/geolocation/v1/geolocate?key=${GOOGLE_API_KEY}`, | ||
"headers": { | ||
"content-type": "application/json", | ||
"cache-control": "no-cache" | ||
} | ||
method: 'POST', | ||
hostname: 'www.googleapis.com', | ||
port: null, | ||
path: `/geolocation/v1/geolocate?key=${GOOGLE_API_KEY}`, | ||
headers: { | ||
'content-type': 'application/json', | ||
'cache-control': 'no-cache', | ||
}, | ||
}; | ||
|
||
/** | ||
* @description Hanlder for Geolocation API call | ||
* @returns {JSON} 'location': estimated 'lat' and 'lng'; 'accuracy': accuracy of | ||
* the estimated location, in meters | ||
*/ | ||
exports.getGeolocation = function(appReq, appRes) { | ||
const req = http.request(GEOLOCATION_OPTIONS, function (res) { | ||
const chunks = []; | ||
res.on("data", function (chunk) { | ||
chunks.push(chunk); | ||
}); | ||
res.on("end", function () { | ||
const body = Buffer.concat(chunks); | ||
console.log(body.toString()); | ||
appRes.send(JSON.parse(body.toString())); | ||
}); | ||
}); | ||
req.write(JSON.stringify({})); | ||
req.end(); | ||
} | ||
exports.getGeolocation = (appReq, appRes) => { | ||
const req = http.request(GEOLOCATION_OPTIONS, (res) => { | ||
const chunks = []; | ||
|
||
res.on('data', (chunk) => { | ||
chunks.push(chunk); | ||
}); | ||
|
||
res.on('end', () => { | ||
const body = Buffer.concat(chunks); | ||
console.log(body.toString()); | ||
appRes.send(JSON.parse(body.toString())); | ||
}); | ||
}); | ||
|
||
req.write(JSON.stringify({})); | ||
req.end(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const Schema = mongoose.Schema; | ||
const savedDirectionsSchema = new Schema({ | ||
origin: {type: Schema.Types.Mixed, required: true}, | ||
destination: {type: Schema.Types.Mixed, required: true}, | ||
geocoded_waypoints: {type: [Schema.Types.Mixed], required: true}, | ||
routes: {type: [Schema.Types.Mixed], required: true}, | ||
save_date: {type: Date, default: Date.now} | ||
origin: { type: Schema.Types.Mixed, required: true }, | ||
destination: { type: Schema.Types.Mixed, required: true }, | ||
geocoded_waypoints: { type: [Schema.Types.Mixed], required: true }, | ||
routes: { type: [Schema.Types.Mixed], required: true }, | ||
save_date: { type: Date, default: Date.now }, | ||
}); | ||
|
||
module.exports = mongoose.model('SavedDirections', savedDirectionsSchema); | ||
module.exports = mongoose.model('SavedDirections', savedDirectionsSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const Schema = mongoose.Schema; | ||
const savedPinsSchema = new Schema({ | ||
lat: {type: Number, min: -90, max: 90, required: true}, | ||
lng: {type: Number, min: -180, max: 180, required: true}, | ||
place_id: {type: String, required: true}, | ||
save_date: {type: Date, default: Date.now}, | ||
}) | ||
lat: { | ||
type: Number, min: -90, max: 90, required: true, | ||
}, | ||
lng: { | ||
type: Number, min: -180, max: 180, required: true, | ||
}, | ||
place_id: { type: String, required: true }, | ||
save_date: { type: Date, default: Date.now }, | ||
}); | ||
|
||
module.exports = mongoose.model('SavedPins', savedPinsSchema); | ||
module.exports = mongoose.model('SavedPins', savedPinsSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const Schema = mongoose.Schema; | ||
const searchHistorySchema = new Schema({ | ||
query: {type: String, required: true}, | ||
save_date: {type: Date, default: Date.now} | ||
query: { type: String, required: true }, | ||
save_date: { type: Date, default: Date.now }, | ||
}); | ||
|
||
module.exports = mongoose.model('SearchHistory', searchHistorySchema); | ||
module.exports = mongoose.model('SearchHistory', searchHistorySchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const Schema = mongoose.Schema; | ||
const usersSchema = new Schema({ | ||
name: {type: String, required: true} | ||
name: { type: String, required: true }, | ||
}); | ||
|
||
module.exports = mongoose.model('Users', usersSchema); | ||
module.exports = mongoose.model('Users', usersSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
let express = require('express'); | ||
|
||
let router = express.Router(); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.send('Hello World!'); | ||
router.get('/', (req, res, next) => { | ||
res.send('Hello World!'); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters