-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
566 additions
and
33 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "smart-shop", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rheajain/smartShop.git" | ||
}, | ||
"keywords": [ | ||
"shopping", | ||
"malls", | ||
"shops", | ||
"market" | ||
], | ||
"author": "Rhea Jain", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/rheajain/smartShop/issues" | ||
}, | ||
"homepage": "https://github.com/rheajain/smartShop#readme", | ||
"dependencies": { | ||
"geo-nearby": "^2.0.1", | ||
"mongoose-geojson-schema": "^2.1.2" | ||
} | ||
} |
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,30 +1,26 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var app = require('../app'); | ||
var customer = require('../schemas/customer'); | ||
var Customer = require('../schemas/customer'); | ||
var mongoose = require('mongoose'); | ||
|
||
router.route('/login') | ||
router.route('/') | ||
|
||
// show the form (GET http://localhost:8080/login) | ||
.get(function(req, res) { | ||
console.log("Came to this page"); | ||
res.send('this is the login form'); | ||
}) | ||
// .get(function(req, res) { | ||
// console.log("Came to this page"); | ||
// res.send('this is the login form'); | ||
// }) | ||
|
||
// process the form (POST http://localhost:8080/login) | ||
.post(function(req, res) { | ||
console.log('processing'); | ||
res.send('processing the login form!'); | ||
var person = new customer(req.body); | ||
customer.create(req.body, function(err, r){ | ||
if(err){ | ||
console.log(err); | ||
|
||
} else{ | ||
console.log(req.body); | ||
console.log(r); | ||
} | ||
}); | ||
if(req.body){ | ||
Customer.findOne({ phoneNo : req.body.phoneNo}).exec().then(function(result){ | ||
res.send(result); | ||
}).catch( function(e){ | ||
res.status(400).send(e); | ||
}); | ||
} else{ | ||
res.status(404).send("No details found."); | ||
} | ||
}); | ||
|
||
module.exports =router; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var app = require('../app'); | ||
var Mall = require('../schemas/mall'); | ||
|
||
router.get("/search", function(req, res) { | ||
console.log("Searching mall"); | ||
Mall.find({name :req.query.name}).exec().then( function(result){ | ||
if(result){ | ||
res.send(result); | ||
} else{ | ||
res.status(404).send("Resource not found."); | ||
} | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}); | ||
}); | ||
|
||
router.get("/:id", function(req, res) { | ||
console.log("Getting information of mall with id- ", req.params.id); | ||
Mall.findById(req.params.id).exec().then( function(result){ | ||
if(result){ | ||
res.send(result); | ||
} else{ | ||
res.status(404).send("Resource not found."); | ||
} | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}); | ||
}); | ||
|
||
router.route('/') | ||
|
||
.get(function(req, res){ | ||
//dump all malls | ||
Mall.find().exec().then( function(result){ | ||
if(result){ | ||
res.send(result); | ||
} else{ | ||
res.status(404).send("Resource not found."); | ||
} | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}); | ||
}) | ||
|
||
.post(function(req, res) { | ||
console.log('Creating a new mall'); | ||
if(req.body){ | ||
var mall = new Mall(req.body); | ||
Mall.create(mall).then(function(result){ | ||
res.send(result); | ||
}).catch( function(e){ | ||
res.status(400).send(e); | ||
}); | ||
} | ||
}) | ||
|
||
/*.put("/:id", function(req, res){ | ||
res.send(); | ||
})*/ | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var app = require('../app'); | ||
var Product = require('../schemas/product'); | ||
|
||
router.get("/search", function(req, res) { | ||
console.log("Searching product"); | ||
Product.find({name :req.query.name}).exec().then( function(result){ | ||
if(result){ | ||
res.send(result); | ||
} else{ | ||
res.status(404).send("Resource not found."); | ||
} | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}); | ||
}); | ||
|
||
router.get("/:id", function(req, res) { | ||
console.log("Getting information of product with id- ", req.params.id); | ||
Product.findById(req.params.id).exec().then( function(result){ | ||
if(result){ | ||
res.send(result); | ||
} else{ | ||
res.status(404).send("Resource not found."); | ||
} | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}); | ||
}); | ||
|
||
router.route('/') | ||
|
||
|
||
|
||
.get(function(req, res){ | ||
//dump all products | ||
Product.find().exec().then( function(result){ | ||
if(result){ | ||
res.send(result); | ||
} else{ | ||
res.status(404).send("Resource not found."); | ||
} | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}); | ||
}) | ||
|
||
.post(function(req, res) { | ||
console.log('Creating a new product'); | ||
if(req.body){ | ||
var product = new Product(req.body); | ||
Product.create(product).then(function(result){ | ||
res.send(result); | ||
}).catch( function(e){ | ||
res.status(400).send(e); | ||
}); | ||
} | ||
}) | ||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
router.get("/", function(req, res){ | ||
if(req.user.latitude && req.user.longitude){ | ||
|
||
} | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var mongoose = require('mongoose'); | ||
var GeoJSON = require('mongoose-geojson-schema'); | ||
var Shop = require('../schemas/shop'); | ||
var Mall = require('../schemas/mall'); | ||
var Product = require('../schemas/product'); | ||
const Geo = require('geo-nearby'); | ||
|
||
//var loc = mongoose.Schema.Types.Point; | ||
|
||
// const data = [ | ||
// [-35.30278, 149.14167, 'Canberra'], | ||
// [-33.86944, 151.20833, 'Sydney'], | ||
// [-37.82056, 144.96139, 'Melbourne'], | ||
// [-34.93333, 138.58333, 'Adelaide'], | ||
// [-27.46778, 153.02778, 'Brisbane'], | ||
// [-31.95306, 115.85889, 'Perth'] | ||
// ]; | ||
|
||
|
||
|
||
router.get("/nearby", function(req, res){ | ||
//if(loc){ | ||
// var dataSet = [ | ||
// { i: 'Perth', g: 3149853951719405 }, | ||
// { i: 'Adelaide', g: 3243323516150966 }, | ||
// { i: 'Melbourne', g: 3244523307653507 }, | ||
// { i: 'Canberra', g: 3251896081369449 }, | ||
// { i: 'Sydney', g: 3252342838034651 }, | ||
// { i: 'Brisbane', g: 3270013708086451 }, | ||
// { i: 'Sydney', g: 3252342838034651 } | ||
// ]; | ||
// var geo = new Geo(dataSet); | ||
// var a = geo.nearBy(-33.87, 151.2, 5000); | ||
// console.log(a); | ||
|
||
const data = [ | ||
[12.933192, 77.612205, 'Big bazaar'], | ||
[12.933579, 77.612419, 'Shopers Stop'], | ||
[12.934029, 77.611175, 'More supermarket'], | ||
[12.934298, 77.610859, 'KFC'], | ||
[12.934570, 77.611771, 'Westside'], | ||
[12.934560, 77.611288, 'The Forum'], | ||
[12.934445, 77.613434, 'Gramin'], | ||
[12.935020, 77.608799, 'Punjabi by Nature'], | ||
[12.936808, 77.610441, 'Start Bazaar'], | ||
[12.935177, 77.613491, 'Startbucks'], | ||
[12.933823, 77.612300, 'Bata'], | ||
[12.934215, 77.611195, 'Puma'], | ||
[12.935328, 77.612847, "Baby's Dayout"], | ||
[12.934680, 77.612455, 'State Bank ATM'], | ||
[12.934680, 77.613496, 'Citi Bank ATM'], | ||
[12.935213, 77.614483, 'ICICI Bank'], | ||
[12.936531, 77.616049, 'Sapna Book House'], | ||
[12.935595, 77.614385, 'Bowling Machine and ames'], | ||
[12.933934, 77.621245, 'Escape room'], | ||
[12.930758, 77.622640, 'Cafe coffe Day'], | ||
[12.937575, 77.628006, 'Oasis mall'] | ||
|
||
]; | ||
const dataSet = Geo.createCompactSet(data); | ||
const geo = new Geo(dataSet, { sorted: true }); | ||
|
||
console.log(geo.nearBy(12.934607, 77.625298, 2000)); | ||
res.send(geo.nearBy(12.934607, 77.625298, 2000)); | ||
//} | ||
}); | ||
|
||
router.post('/route', function(req, res){ | ||
if(req.body.list){ | ||
|
||
} else{ | ||
res.status(404).send("Wishlist not found."); | ||
} | ||
}); | ||
|
||
router.get('/:keyword', function(req, res){ | ||
if(req.params.keyword!==""){ | ||
var promise1 = Product.find({name: req.params.keyword}).exec(); | ||
var promise2 = Mall.find({name: req.params.keyword}).exec(); | ||
var promise3 = Shop.find({name : req.params.keyword}).exec(); | ||
Promise.all([promise1, promise2, promise3]).then( function(result){ | ||
res.send(result); | ||
}).catch( function(err){ | ||
res.status(400).send(err); | ||
}) | ||
} | ||
}); | ||
|
||
module.exports = router; |
Oops, something went wrong.