Skip to content

Commit

Permalink
Basic cleanup
Browse files Browse the repository at this point in the history
Basic CRUD operations implemented
  • Loading branch information
moonpatel committed Aug 16, 2022
1 parent df197ef commit 4923549
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@ app.set('views',path.join(__dirname,'views'))
app.use(express.urlencoded({extended : true}))
app.use(methodOverride('_method'))



// RECEIVE REQUESTS
// main page
app.get('/',(req,res) => {
res.render('home')
})

// campgrounds index
app.get('/campgrounds', async (req,res) => {
const camps = await Campground.find({})
res.render('campgrounds/index', {camps})
})
// add new campgrounds
app.get('/campgrounds/new', (req,res) => {
res.render('new')
})
app.get('/campgrounds/new', (req,res) => res.render('new'))
// add new campground to server
app.post('/campgrounds', async (req,res) => {
const cg = new Campground(req.body.campground)
Expand Down Expand Up @@ -68,7 +67,8 @@ app.delete('/campgrounds/:id', async (req,res) => {
await Campground.findByIdAndDelete(req.params.id)
res.redirect('/campgrounds')
})



// listen for incoming requests
app.listen(port, () => {
console.log(`LISTENING ON PORT ${port}`)
})
app.listen(port,() => console.log(`LISTENING ON PORT ${port}`))

0 comments on commit 4923549

Please sign in to comment.