Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

WanderLust

WanderLust is a simple accommodation-listings web application built with Node.js, Express, EJS, and MongoDB. It lets visitors browse listings and create, view, edit, and delete them.

Features

  • Browse all listings and view an individual listing
  • Create, edit, and delete listings
  • Store listing data in MongoDB with Mongoose
  • Render pages with EJS and shared layouts
  • Use a default placeholder image when a listing has no image URL

Requirements

  • Node.js m express and npm
  • MongoDB, running locally or available through a MongoDB connection URI

Getting started

  1. Install the dependencies:

    npm install
  2. Start MongoDB locally, or set MONGO_URI to your MongoDB connection URI. If unset, the app connects to:

    mongodb://127.0.0.1:27017/wanderlust
    

    In PowerShell, for example:

    $env:MONGO_URI = "mongodb://127.0.0.1:27017/wanderlust"
  3. Start the application from the project directory:

    node app.js

    The server listens on port 8080 by default. Set the PORT environment variable to use another port.

  4. Open http://localhost:8080 in your browser. Visit /listings to browse the listings.

Routes

Method Path Description
GET / Home route
GET /listings Show all listings
GET /listings/new Show the create-listing form
POST /listings Create a listing
GET /listings/:id Show a listing
GET /listings/:id/edit Show the edit form
PUT /listings/:id Update a listing
DELETE /listings/:id Delete a listing

The edit and delete forms use method-override to submit PUT and DELETE requests from HTML forms.

Listing data

Listings include a title, description, image URL, price, location, and country. The title and price are required. The image URL defaults to a placeholder if none is supplied.

Seed sample listings

To populate the database with the sample listings in init/data.js, run:

node init/index.js

Warning: The seed script deletes all existing listings in the selected database before inserting the sample data. Set MONGO_URI first if you intend to seed a different database.

Project structure

app.js              Express application and routes
models/listings.js  Mongoose listing model
init/               Sample data and database seeding script
views/              EJS pages, layouts, and shared includes
public/             Stylesheets and image assets

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages