aboutsummaryrefslogtreecommitdiff
path: root/web/routes
diff options
context:
space:
mode:
authorKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-27 22:58:32 +0000
committerKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-27 22:58:32 +0000
commit73d4c7c7f01f2d730668b926deb57921b8dfdc54 (patch)
tree245dec90116830749bfa4559f7afd3374ab416a0 /web/routes
parent5189458c68f326ba01d803ac515ab222c211cc8f (diff)
parent197f2f42091b691feb7c31308dbfc9ddde07a10f (diff)
pulled in latest master
Diffstat (limited to 'web/routes')
-rw-r--r--web/routes/index.js68
1 files changed, 32 insertions, 36 deletions
diff --git a/web/routes/index.js b/web/routes/index.js
index 6c87660..32a5890 100644
--- a/web/routes/index.js
+++ b/web/routes/index.js
@@ -6,13 +6,13 @@ var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var JsonSchema = new Schema({
- name: String,
- type: Schema.Types.Mixed,
- coordinates: Array,
- ageRange: String,
- clothingDescription: String,
- isInjured: Boolean,
- reasonForHelp: String
+ name: String,
+ type: Schema.Types.Mixed,
+ coordinates: Array,
+ ageRange: String,
+ clothingDescription: String,
+ isInjured: Boolean,
+ reasonForHelp: String
});
// Mongoose Model definition
@@ -20,42 +20,38 @@ var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection');
/* GET home page. */
router.get('/', function(req, res, next) {
- // for now just redirect to /map
- //res.render('index', { title: 'Welcome' });
- res.redirect('/map');
+ // for now just redirect to /map
+ //res.render('index', { title: 'Welcome' });
+ res.redirect('/map');
});
/* GET Map page. */
router.get('/map', function(req,res) {
- // we can use the database to fetch a point, SELECT coordinates
- Json.findOne({name: "points"}, 'coordinates', function(e,point){
- if (e) return e;
- // send the view lat, and long.
- res.render('map', {
- lat : point.coordinates[1],
- lng : point.coordinates[0]
- });
- });
+ // send the view lat, and long. city center
+ res.render('map', {
+ lat : 43.654127,
+ lng : -79.383370
+ });
});
router.post('/mobilerequest', function(req, res) {
- var data = {
- 'coordinates': req.body.coordinates,
- 'type': req.body.type,
- 'isInjured': req.body.isInjured,
- 'reasonForHelp': req.body.reasonForHelp,
- 'ageRange': req.body.ageRange,
- 'clothingDescription': req.body.clothingDescription
- }
- Json.create(data, function(err, result) {
- if (err) {
- console.log(`err inserting mobile request into db: ${err}`);
- res.status(500).send({ error: "boo:(" });
- } else {
- console.log(result);
- res.status(200).send({'status': 'success', 'data': data});
- }
- });
+ var data = {
+ 'coordinates': req.body.coordinates,
+ 'type': req.body.type,
+ 'isInjured': req.body.isInjured,
+ 'reasonForHelp': req.body.reasonForHelp,
+ 'ageRange': req.body.ageRange,
+ 'clothingDescription': req.body.clothingDescription
+ }
+ Json.create(data, function(err, result) {
+ if (err) {
+ console.log(`err inserting mobile request into db: ${err}`);
+ res.status(500).send({ error: "boo:(" });
+ } else {
+ console.log(result);
+ res.status(200).send({'status': 'success', 'data': data});
+ }
+ });
});
module.exports = router;