Skip to content

Commit 9afb3a8

Browse files
authored
Add files via upload
1 parent 13f671c commit 9afb3a8

14 files changed

+1132
-0
lines changed

week_4/app.js

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
var express = require('express');
2+
var path = require('path');
3+
var favicon = require('serve-favicon');
4+
var logger = require('morgan');
5+
var cookieParser = require('cookie-parser');
6+
var bodyParser = require('body-parser');
7+
var mongoose = require('mongoose');
8+
var passport = require('passport');
9+
10+
var authenticate = require('./authenticate');
11+
12+
var config = require('./config');
13+
14+
15+
16+
mongoose.connect(config.mongoUrl);
17+
var db = mongoose.connection;
18+
db.on('error', console.error.bind(console, 'connection error:'));
19+
db.once('open', function () {
20+
// we're connected!
21+
console.log("Connected correctly to server");
22+
});
23+
24+
var routes = require('./routes/index');
25+
var users = require('./routes/users');
26+
var dishRouter = require('./routes/dishRouter');
27+
var promoRouter = require('./routes/promoRouter');
28+
var leaderRouter = require('./routes/leaderRouter');
29+
var favoriteRouter = require('./routes/favoriteRouter');
30+
31+
var app = express();
32+
app.use(passport.initialize());
33+
// Secure traffic only
34+
app.all('*', function(req, res, next){
35+
console.log('req start: ',req.secure, req.hostname, req.url, app.get('port'));
36+
if (req.secure) {
37+
return next();
38+
};
39+
40+
res.redirect('https://'+req.hostname+':'+app.get('secPort')+req.url);
41+
});
42+
43+
// view engine setup
44+
app.set('views', path.join(__dirname, 'views'));
45+
app.set('view engine', 'jade');
46+
// uncomment after placing your favicon in /public
47+
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
48+
49+
app.use(logger('dev'));
50+
app.use(bodyParser.json());
51+
app.use(bodyParser.urlencoded({ extended: false }));
52+
app.use(cookieParser());
53+
54+
app.use(express.static(path.join(__dirname, 'public')));
55+
56+
app.use('/', routes);
57+
app.use('/users', users);
58+
app.use('/dishes',dishRouter);
59+
app.use('/promotions',promoRouter);
60+
app.use('/leadership',leaderRouter);
61+
app.use('/favorites', favoriteRouter);
62+
63+
// catch 404 and forward to error handler
64+
app.use(function(req, res, next) {
65+
var err = new Error('Not Found');
66+
err.status = 404;
67+
next(err);
68+
});
69+
70+
// error handlers
71+
// development error handler
72+
// will print stacktrace
73+
if (app.get('env') === 'development') {
74+
app.use(function(err, req, res, next) {
75+
res.status(err.status || 500);
76+
res.json({
77+
message: err.message,
78+
error: err
79+
});
80+
});
81+
}
82+
83+
// production error handler
84+
// no stacktraces leaked to user
85+
app.use(function(err, req, res, next) {
86+
res.status(err.status || 500);
87+
res.json({
88+
message: err.message,
89+
error: {}
90+
});
91+
});
92+
93+
module.exports = app;

week_4/db.json

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
{
2+
"dishes": [
3+
{
4+
"name": "Uthapizza",
5+
"image": "images/uthapizza.png",
6+
"category": "mains",
7+
"label": "Hot",
8+
"price": "4.99",
9+
"description": "A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.",
10+
"comments": [
11+
{
12+
"rating": 5,
13+
"comment": "Imagine all the eatables, living in conFusion!",
14+
"author": "John Lemon"
15+
},
16+
{
17+
"rating": 4,
18+
"comment": "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
19+
"author": "Paul McVites"
20+
},
21+
{
22+
"rating": 3,
23+
"comment": "Eat it, just eat it!",
24+
"author": "Michael Jaikishan"
25+
},
26+
{
27+
"rating": 4,
28+
"comment": "Ultimate, Reaching for the stars!",
29+
"author": "Ringo Starry"
30+
},
31+
{
32+
"rating": 2,
33+
"comment": "It's your birthday, we're gonna party!",
34+
"author": "25 Cent"
35+
}
36+
]
37+
},
38+
{
39+
"name": "Zucchipakoda",
40+
"image": "images/zucchipakoda.png",
41+
"category": "appetizer",
42+
"label": "",
43+
"price": "1.99",
44+
"description": "Deep fried Zucchini coated with mildly spiced Chickpea flour batter accompanied with a sweet-tangy tamarind sauce",
45+
"comments": [
46+
{
47+
"rating": 5,
48+
"comment": "Imagine all the eatables, living in conFusion!",
49+
"author": "John Lemon"
50+
},
51+
{
52+
"rating": 4,
53+
"comment": "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
54+
"author": "Paul McVites"
55+
},
56+
{
57+
"rating": 3,
58+
"comment": "Eat it, just eat it!",
59+
"author": "Michael Jaikishan"
60+
},
61+
{
62+
"rating": 4,
63+
"comment": "Ultimate, Reaching for the stars!",
64+
"author": "Ringo Starry"
65+
},
66+
{
67+
"rating": 2,
68+
"comment": "It's your birthday, we're gonna party!",
69+
"author": "25 Cent"
70+
}
71+
]
72+
},
73+
{
74+
"name": "Vadonut",
75+
"image": "images/vadonut.png",
76+
"category": "appetizer",
77+
"label": "New",
78+
"price": "1.99",
79+
"description": "A quintessential ConFusion experience, is it a vada or is it a donut?",
80+
"comments": [
81+
{
82+
"rating": 5,
83+
"comment": "Imagine all the eatables, living in conFusion!",
84+
"author": "John Lemon"
85+
},
86+
{
87+
"rating": 4,
88+
"comment": "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
89+
"author": "Paul McVites"
90+
},
91+
{
92+
"rating": 3,
93+
"comment": "Eat it, just eat it!",
94+
"author": "Michael Jaikishan"
95+
},
96+
{
97+
"rating": 4,
98+
"comment": "Ultimate, Reaching for the stars!",
99+
"author": "Ringo Starry"
100+
},
101+
{
102+
"rating": 2,
103+
"comment": "It's your birthday, we're gonna party!",
104+
"author": "25 Cent"
105+
}
106+
]
107+
},
108+
{
109+
"name": "ElaiCheese Cake",
110+
"image": "images/elaicheesecake.png",
111+
"category": "dessert",
112+
"label": "",
113+
"price": "2.99",
114+
"description": "A delectable, semi-sweet New York Style Cheese Cake, with Graham cracker crust and spiced with Indian cardamoms",
115+
"comments": [
116+
{
117+
"rating": 5,
118+
"comment": "Imagine all the eatables, living in conFusion!",
119+
"author": "John Lemon"
120+
},
121+
{
122+
"rating": 4,
123+
"comment": "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
124+
"author": "Paul McVites"
125+
},
126+
{
127+
"rating": 3,
128+
"comment": "Eat it, just eat it!",
129+
"author": "Michael Jaikishan"
130+
},
131+
{
132+
"rating": 4,
133+
"comment": "Ultimate, Reaching for the stars!",
134+
"author": "Ringo Starry"
135+
},
136+
{
137+
"rating": 2,
138+
"comment": "It's your birthday, we're gonna party!",
139+
"author": "25 Cent"
140+
}
141+
]
142+
}
143+
],
144+
"promotions": [
145+
{
146+
"name": "Weekend Grand Buffet",
147+
"image": "images/buffet.png",
148+
"label": "New",
149+
"price": "19.99",
150+
"description": "Featuring mouthwatering combinations with a choice of five different salads, six enticing appetizers, six main entrees and five choicest desserts. Free flowing bubbly and soft drinks. All for just $19.99 per person "
151+
}
152+
],
153+
"leadership": [
154+
{
155+
"name": "Peter Pan",
156+
"image": "images/alberto.png",
157+
"designation": "Chief Epicurious Officer",
158+
"abbr": "CEO",
159+
"description": "Our CEO, Peter, credits his hardworking East Asian immigrant parents who undertook the arduous journey to the shores of America with the intention of giving their children the best future. His mother's wizardy in the kitchen whipping up the tastiest dishes with whatever is available inexpensively at the supermarket, was his first inspiration to create the fusion cuisines for which The Frying Pan became well known. He brings his zeal for fusion cuisines to this restaurant, pioneering cross-cultural culinary connections."
160+
},
161+
{
162+
"name": "Dhanasekaran Witherspoon",
163+
"image": "images/alberto.png",
164+
"designation": "Chief Food Officer",
165+
"abbr": "CFO",
166+
"description": "Our CFO, Danny, as he is affectionately referred to by his colleagues, comes from a long established family tradition in farming and produce. His experiences growing up on a farm in the Australian outback gave him great appreciation for varieties of food sources. As he puts it in his own words, Everything that runs, wins, and everything that stays, pays!"
167+
},
168+
{
169+
"name": "Agumbe Tang",
170+
"image": "images/alberto.png",
171+
"designation": "Chief Taste Officer",
172+
"abbr": "CTO",
173+
"description": "Blessed with the most discerning gustatory sense, Agumbe, our CFO, personally ensures that every dish that we serve meets his exacting tastes. Our chefs dread the tongue lashing that ensues if their dish does not meet his exacting standards. He lives by his motto, You click only if you survive my lick."
174+
},
175+
{
176+
"name": "Alberto Somayya",
177+
"image": "images/alberto.png",
178+
"designation": "Executive Chef",
179+
"abbr": "EC",
180+
"description": "Award winning three-star Michelin chef with wide International experience having worked closely with whos-who in the culinary world, he specializes in creating mouthwatering Indo-Italian fusion experiences. He says, Put together the cuisines from the two craziest cultures, and you get a winning hit! Amma Mia!"
181+
}
182+
],
183+
"feedback": [
184+
185+
]
186+
}

week_4/models/dishes.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var mongoose = require('mongoose');
2+
var Schema = mongoose.Schema;
3+
4+
require('mongoose-currency').loadType(mongoose);
5+
var Currency = mongoose.Types.Currency;
6+
7+
var commentSchema = new Schema({
8+
rating: {
9+
type: Number,
10+
min: 1,
11+
max: 5,
12+
required: true
13+
},
14+
comment: {
15+
type: String,
16+
required: true
17+
},
18+
postedBy: {
19+
type: mongoose.Schema.Types.ObjectId,
20+
ref: 'User'
21+
}
22+
}, {
23+
timestamps: true
24+
});
25+
26+
var dishSchema = new Schema({
27+
name: {
28+
type: String,
29+
required: true,
30+
unique: true
31+
},
32+
image: {
33+
type: String,
34+
required: true
35+
},
36+
category: {
37+
type: String,
38+
required: true
39+
},
40+
label: {
41+
type: String,
42+
required: true,
43+
default: ""
44+
},
45+
price: {
46+
type: Currency,
47+
required: true
48+
},
49+
description: {
50+
type: String,
51+
},
52+
comments:[commentSchema]
53+
}, {
54+
timestamps: true
55+
});
56+
57+
var Dishes = mongoose.model('Dish', dishSchema);
58+
59+
module.exports = Dishes;

week_4/models/favorites.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var mongoose = require('mongoose');
2+
var Schema = mongoose.Schema;
3+
4+
var favoriteSchema = new Schema({
5+
postedBy:{
6+
type: mongoose.Schema.Types.ObjectId,
7+
ref: 'User'
8+
},
9+
dishes: [{
10+
type:mongoose.Schema.Types.ObjectId,
11+
ref: 'Dish'
12+
}]
13+
14+
}, {
15+
timestamps: true
16+
});
17+
18+
module.exports = mongoose.model('Favorites', favoriteSchema);

week_4/models/leadership.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var mongoose = require('mongoose');
2+
var Schema = mongoose.Schema;
3+
4+
var leadershipSchema = new Schema({
5+
name: {
6+
type: String,
7+
required: true,
8+
unique: true
9+
},
10+
image: {
11+
type: String,
12+
required: true
13+
},
14+
designation: {
15+
type: String,
16+
required: true
17+
},
18+
abbr: {
19+
type: String,
20+
required: true
21+
},
22+
description: {
23+
type: String,
24+
required: true
25+
}
26+
}, {
27+
timestamps: true
28+
});
29+
30+
31+
var leaderships = mongoose.model('leadership', leadershipSchema);
32+
33+
module.exports = leaderships;

0 commit comments

Comments
 (0)