GithubHelp home page GithubHelp logo

yelpcamp's People

Contributors

colt avatar nax3t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yelpcamp's Issues

Campground New & Create - POST not working

After adding the POST method to make the "Add Campground" button works, nothing happens. No error or anything. I can't find anything wrong with the code. Please help!

`const express = require('express');
const path = require('path');
const mongoose = require('mongoose');
const Campground = require('./models/campground');

mongoose.connect('mongodb://localhost:27017/yelp-camp', {
useNewUrlParser: true,
// useCreateIndex: true, doesn't work in Mongoose 6
useUnifiedTopology: true
})

const db = mongoose.connection;
db.on("error", console.error.bind(console, "connection error:"));
db.once("open", () => {
console.log("Database connected");
});

const app = express();

app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'))

app.use(express.urlencoded( {extended: true}));

app.get('/', (req, res) => {
res.render('home')
});

app.get('/campgrounds', async (req, res) => {
const campgrounds = await Campground.find({});
res.render('campgrounds/index',{ campgrounds })
});

app.get('/campgrounds/new', (req, res) => {
res.render('campgrounds/new');
})

app.post('/campgrounds', async (req, res) => {
const campground = new Campground(req.body.campground);
await campground.save();
res.redirect(/campgrounds/${campground._id})
})

app.get('/campgrounds/:id', async (req, res) => {
const campground = await Campground.findById(req.params.id)
res.render('campgrounds/show', { campground });
})

app.listen(3000, () => {
console.log('Serving on port 3000')
})`

Simplified Passport/Passport-Local Configuration

Hello @Colt

For the app.js file while we are using authentication over passport there is an update.

Starting from version 0.2.1, passport-local-mongoose adds a helper method createStrategy as static method to your schema. The createStrategy is responsible to setup passport-local LocalStrategy with the correct options. Bacuse of this no need to define LocalStrategy and using this lines of code : passport.use(new LocalStrategy(User.authenticate()));

We could update this lines as below:

const User = require('./models/user');

// CHANGE: USE "createStrategy" INSTEAD OF "authenticate"
passport.use(User.createStrategy());

Heroku deploying not working properly.

Invalid Signature 43584e4a95f65d120a2aab4dcbae2b9cde0f5724. String to sign - 'folder=YelpCamp&timestamp=1654175189'.

I am getting this error every time I try to create a new campgound.

Things breaking after deploying the site

warning: LF will be replaced by CRLF in app.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in public/javascripts/validateForms.js.
The file will have its original line endings in your working directory

this is the message I am getting while executing 'git add .' in git bash.
then in the site, some pages are not working like the campground add is not working.

cloudinary display image

in app.js

  •            "https://res.cloudinary.com/douqbebwk/", //SHOULD MATCH YOUR CLOUDINARY ACCOUNT!
    
  •            "https://res.cloudinary.com/"+ process.env.CLOUDINARY_CLOUD_NAME +"/", 
    

in order to match the environment variable of the user.

also a readme with setup explanation would help people who are unfamiliar with environment variables

export MAPBOX_TOKEN=...
export CLOUDINARY_CLOUD_NAME=...
export CLOUDINARY_KEY=...
export CLOUDINARY_SECRET=...
source ~/.zshrc

Home Page Styling

In the Udemy course Colt uses Bootstrap alpha 5, whereas I'm using 5.1.3
How do I get my styling to make the page look the same ?

ReturnTo behavior not working.

The url is there when the site redirects to /login but is removed when the post request is made. So it always redirects to /campgrounds

Mongo connection error

I kept receiving a notification whenever I would run nodemon telling me there was a vulnerability and suggesting I run an audit. I did and it said I should update mongoose to a new version. Ever since the update I'm getting this error and I can't start the server:

connection error: MongoParseError: options usecreateindex, usefindandmodify are not supported
at Object.parseOptions (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\connection_string.js:291:15)
at new MongoClient (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\mongo_client.js:62:46)
at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:779:16
at new Promise ()
at NativeConnection.Connection.openUri (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:776:19)
at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:330:10
at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
at new Promise ()
at promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:1151:10)
(node:12200) UnhandledPromiseRejectionWarning: MongoParseError: options usecreateindex, usefindandmodify are not supported
at Object.parseOptions (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\connection_string.js:291:15)
at new MongoClient (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\mongo_client.js:62:46)
at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:779:16
at new Promise ()
at NativeConnection.Connection.openUri (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:776:19)
at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:330:10
at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
at new Promise ()
at promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:1151:10)
(Use node --trace-warnings ... to show where the warning was created)
(node:12200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:12200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejectio

reviews not getting push in to campground review array, getting property of review null error

module.exports.create=async(req,res,next)=>{
const campgrounds= await campGround.findById(req.params.id)
const reviewsss= new reviews(req.body.review)
reviewsss.author= req.user._id
campgrounds.review.push('reviewsss')
console.log(campgrounds.review)
await reviewsss.save()
await campgrounds.save()
req.flash('success','review created')
res.redirect(/campground/${campgrounds._id})
}

Error using Joi Validation Middleware

I used Joi validation and it worked perfectly the last time I worked on the project. The next video had a middleware made from it and nothing works after that. I even reverted back to my previous code and it still doesnt work.

First while using the middleware i got an error saying 'cannot read properties of undefined reading('validate')' at my validateCampground function.

Then I made some changes to the code and it said that " 'campground' is required" .

image

Now, even when all of the inputs pass the validation, it still shows the above error.

I remove the validateCampground middleware, everything works fine. I even checked the documentation and couldnt find the problem anywhere.

ReturnTo behavior not working

I am having trouble implementing the feature that allows you to redirect the user to where they were before they were asked to log in. In an effort to debug the code, I tried console.logging the session twice: once in the login get route (i.e. the route that renders the login page), and once in the login post route (i.e. the route the login form submits to). As seen in the screenshots below, in the login get route, the session does contain returnTo: '/campgrounds/new'. However, the session in the login post route does not. The only piece of code that gets executed between these two console.logs is the passport.authenticate() middleware. It seems like that middleware is responsible for the loss of returnTo: '/campgrounds/new' and I can't seem to figure out how to fix that.
login get route
login post route
`router.get('/login', (req, res) => {
console.log("session inside login get route:");
console.log(req.session);
res.render('users/login');
});

router.post('/login', passport.authenticate('local', { failureFlash: true, failureRedirect: '/login' }), (req, res) => {
console.log("session inside login post route:");
console.log(req.session);
req.flash('success', 'welcome back!');
const redirectUrl = req.session.returnTo || '/campgrounds';
delete req.session.returnTo;
res.redirect(redirectUrl);
});`

heroku not working

Invalid Signature 43584e4a95f65d120a2aab4dcbae2b9cde0f5724. String to sign - 'folder=YelpCamp&timestamp=1654175189'.

i am getting this error every time i try to create a new campgound.

MongoDBStore session broke, needs a clear fix

const MongoDBStore = require("connect-mongo")(session);

const secret = process.env.SECRET || 'thisshouldbeabettersecret!';

const store = new MongoDBStore({
url: dbUrl,
secret,
touchAfter: 24 * 60 * 60
});

store.on("error", function (e) {
console.log("SESSION STORE ERROR", e)
})

const sessionConfig = {
store,
name: 'session',
secret,
resave: false,
saveUninitialized: true,
cookie: {
httpOnly: true,
// secure: true,
expires: Date.now() + 1000 * 60 * 60 * 24 * 7,
maxAge: 1000 * 60 * 60 * 24 * 7
}
}

app.use(session(sessionConfig));

fix all routes

Hi Colt, I have seen some redundancy on the routes of the project, you should exclude the loading of the models from the routes since it is an operation that the controllers do.
Congratulations again for the course ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.