Skip to content

Commit

Permalink
new pull
Browse files Browse the repository at this point in the history
  • Loading branch information
vinntt committed Feb 17, 2022
1 parent c3d2049 commit f9fd2f5
Show file tree
Hide file tree
Showing 17 changed files with 583 additions and 244 deletions.
12 changes: 10 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const capitalized = (string) => string[0].toUpperCase() + string.slice(1).toLowe
app.locals.title = `${capitalized(projectName)} created with IronLauncher`;

// https://cloudinary.com/documentation/resizing_and_cropping#scale.
hbs.registerHelper('cloudinaryResize', function (url, transform) {
hbs.registerHelper('cloudinaryResize', function(url, transform) {
if (typeof url === 'undefined' || !url) {
return "";
}
Expand All @@ -34,6 +34,11 @@ hbs.registerHelper('cloudinaryResize', function (url, transform) {
}
return url.replace(/image\/upload\/v[0-9]+/g, `image/upload/${transform}`);
});

hbs.registerHelper('dateNow', () => {
return (new Date()).toISOString().slice(0, 10);
})

// session configuration
const session = require('express-session')
const MongoStore = require('connect-mongo')
Expand All @@ -49,7 +54,7 @@ app.use(
})
)

app.use(function (req, res, next) {
app.use(function(req, res, next) {
res.locals.session = req.session;

next();
Expand All @@ -66,6 +71,9 @@ app.use("/recipe", recipes);
const auth = require("./routes/auth");
app.use("/auth", auth);

const events = require("./routes/events");
app.use("/event", events);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
require("./error-handling")(app);

Expand Down
14 changes: 12 additions & 2 deletions config/cloudinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ const storage2 = new CloudinaryStorage({
}
})

const storage3 = new CloudinaryStorage({
cloudinary: cloudinary,
params: {
folder: 'event-images',
allowed_formats: 'jpg, png'
}
})

const uploadRecipeImages = multer({ storage: storage2 })
const uploadEventImages = multer({ storage: storage3 })
const uploader = multer({ storage })


module.exports = {
uploader,
uploadRecipeImages,
cloudinary
}
cloudinary,
uploadEventImages
}
44 changes: 44 additions & 0 deletions models/Event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const eventSchema = new Schema({
title: {
type: String,
required: true
},

creater: {
type: Schema.Types.ObjectId,
ref: 'User'
},
startDate: {
type: String,
required: true
},
startTime: {
type: String,
required: true
},
endTime: {
type: String,
required: true
},
location: {
type: String,
required: true
},
description: {
type: String,
required: true
},
img: {
type: String,
required: true
},

tags: [String],
publicId: String,
tags: [String]
});

const Event = mongoose.model('Event', eventSchema);
module.exports = Event;
1 change: 0 additions & 1 deletion public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ document.addEventListener(

instructionSteps.appendChild(htmlToElement(`<textarea class="form-control" name="instructions" rows="3" placeholder="Add next steps"></textarea>`));
})

},
false);

Expand Down
Loading

0 comments on commit f9fd2f5

Please sign in to comment.