Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Project/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const MongoStore = require("connect-mongo");

// Connects the mongo uri to maintain the same naming structure
const MONGO_URI =
process.env.MONGODB_URI || "mongodb://localhost:27017/project2";
process.env.MONGODB_URI || "mongodb://localhost:27017/appetito";

// Middleware configuration
module.exports = (app) => {
Expand All @@ -51,15 +51,23 @@ module.exports = (app) => {
favicon(path.join(__dirname, "..", "public", "images", "favicon.ico"))
);


// ℹ️ Middleware that adds a "req.session" information and later to check that you are who you say you are 😅
app.use(
session({
secret: process.env.SESSION_SECRET || "super hyper secret key",
resave: false,
saveUninitialized: false,
/* cookie: {
sameSite: process.env.NODE_ENV === 'production' ? 'none' : 'lax',
secure: process.env.NODE_ENV === 'production',
httpOnly: true,
maxAge: 60000
},
*/
store: MongoStore.create({
mongoUrl: MONGO_URI,
}),
})
mongoUrl: process.env.MONGODB_URI || 'mongodb://localhost:27017/project2'
})
})
);
};
2 changes: 1 addition & 1 deletion Project/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const mongoose = require("mongoose");
// If no env has been set, we dynamically set it to whatever the folder name was upon the creation of the app

const MONGO_URI =
process.env.MONGODB_URI || "mongodb://localhost:27017/project2";
process.env.MONGODB_URI || "mongodb://localhost:27017/appetito";

mongoose
.connect(MONGO_URI)
Expand Down
7 changes: 6 additions & 1 deletion Project/models/User.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const userSchema = new Schema(
{
username: {
type: String,
required: false,
required: true,
unique: true,
trim: true,
},
Expand All @@ -20,6 +20,11 @@ const userSchema = new Schema(
type: String,
required: true,
},

favorites: {
type: [{type: Schema.Types.ObjectId, ref:"Restaurant"}]
},

},
{
// this second object adds extra properties: `createdAt` and `updatedAt`
Expand Down
25 changes: 25 additions & 0 deletions Project/models/favorite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { Schema, model } = require("mongoose");

// TODO: Please make sure you edit the User model to whatever makes sense in this case
const favoriteSchema = new Schema(
{
user: {
type: {type: Schema.Types.ObjectId, ref:"User"},

},

restaurant: {
type: [{type: Schema.Types.ObjectId, ref:"Restaurant"}]
},

},

{
// this second object adds extra properties: `createdAt` and `updatedAt`
timestamps: true,
}
);

const Favorite = model("Favorite", favoriteSchema);

module.exports = Favorite;
29 changes: 29 additions & 0 deletions Project/models/rate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { Schema, model } = require("mongoose");

// TODO: Please make sure you edit the User model to whatever makes sense in this case
const rateSchema = new Schema(
{
user: {
type: {type: Schema.Types.ObjectId, ref:"User"},

},

rate: {
type: Boolean,
},

review: {
type: String,
},

},

{
// this second object adds extra properties: `createdAt` and `updatedAt`
timestamps: true,
}
);

const Rate = model("Rate", rateSchema);

module.exports = Rate;
65 changes: 65 additions & 0 deletions Project/models/restaurant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const { Schema, model } = require("mongoose");

// TODO: Please make sure you edit the User model to whatever makes sense in this case
const restaurantSchema = new Schema(
{
name: {
type: String,
required: true,
unique: true
},
// duda en style si poner solo los estilos que queremos (ENUM)
style: {
type: String,
required: true,
enum: ["Arabic", "Argentinian", "Bar", "Brazilian", "Burgers", "Chinese", "Korean", "Creperie",
"Brunch", "Fusion", "Greek", "Galician", "Halal", "Kosher", "Ice Cream", "Indian", "Mediterranean",
"Lebanese", "Japanese", "Indian", "Kebab", "Malasian", "Mexican", "Italian", "Poke", "Sirian", "Sushi", "Vegan", "Vegetarian", "Vietnamese", "Coffee Shop"]
},

address: {
type: String,
unique: true
},

price: {
type: Number,
required: true
},
phonenumber: {
type: Number,
unique: true
},

picture: {
type: String,
},
instagram: {
type: String,
unique: true
},
// como poder hacer si o no (poner el si y el no en HBS)
wifi: {
type: Boolean,
},

coworking: {
type: Boolean,
},

delivery: {
type: Boolean,
}

},


{
// this second object adds extra properties: `createdAt` and `updatedAt`
timestamps: true,
}
);

const Restaurant = model("Restaurant", userSchema);

module.exports = User;
Loading