Niwas is a web application for listing and browsing rental properties. Built with Node.js, Express, MongoDB, and EJS, it demonstrates CRUD operations, RESTful routing, and server-side rendering.
- View all property listings
- Create new listings
- Edit existing listings
- Delete listings
- Leave and manage reviews for listings
- Responsive UI with Bootstrap 5
- Data stored in MongoDB
- Server-side rendering with EJS & ejs-mate
- RESTful API design
- Flash messages for user feedback
- Node.js
- Express.js
- MongoDB & Mongoose
- EJS & ejs-mate
- Bootstrap 5
- Joi (validation)
Niwas/
├── .git/
├── app.js
├── cloud-config.js
├── package.json
├── package-lock.json
├── README.md
├── schema.js
├── .env
├── .gitignore
├── controllers/
│ ├── listingControllers.js
│ ├── reviewControllers.js
│ └── userControllers.js
├── init/
│ ├── index.js
│ └── sampleData.js
├── models/
│ ├── listing.js
│ ├── reviews.js
│ └── user.js
├── public/
│ ├── favicon.svg
│ ├── css/
│ │ ├── style.css
│ │ └── rating.css
│ └── js/
│ └── script.js
├── routes/
│ ├── listingRoutes.js
│ ├── reviewRoutes.js
│ └── userRoutes.js
├── utils/
│ ├── ExpressError.js
│ ├── middlewares.js
│ └── wrapAsync.js
├── views/
│ ├── error/
│ │ └── error.ejs
│ ├── includes/
│ │ ├── footer.ejs
│ │ └── navbar.ejs
│ ├── layouts/
│ │ └── boilerplate.ejs
│ ├── listings/
│ │ ├── edit.ejs
│ │ ├── flash.ejs
│ │ ├── index.ejs
│ │ ├── new.ejs
│ │ └── show.ejs
│ └── users/
│ ├── login.ejs
│ └── signup.ejs
Create a .env file in the root directory to store environment variables:
PORT=8080
MONGO_URI=mongodb://127.0.0.1:27017/db_name
SECRET=your_secret_key_for_sessions
CLOUD_NAME=your_mongoDB_cloud_name
CLOUD_API_KEY=your_cloudinary_API_KEY
CLOUD_API_SECRET=your_cloudinary_API_SECRET
- Clone the repository:
git clone git@github.com:developershivam-sudo/GharExpress.git cd GharExpress - Install dependencies:
npm install
- Start MongoDB locally (default port 27017).
- (Optional) Seed the database with sample data:
node init/index.js
- Start the application:
node app.js
- Visit the app: http://localhost:8080
- Home Page: View all listings.
- Add New Listing: Click "Add New Listing" in the navbar to create a new property.
- Edit/Delete: On a listing's detail page, use the Edit or Delete buttons.
- Reviews: Leave reviews for listings and manage them.
GET /listings— View all listingsGET /listings/new— Render form to create a new listingPOST /listings/create— Create a new listingGET /listings/:id— View details of a listingGET /listings/:id/edit— Edit a listingPUT /listings/:id— Update a listingDELETE /listings/:id— Delete a listing
POST /listings/:id/reviews— Add a review to a listingDELETE /listings/:id/reviews/:reviewId— Delete a review
- Server-side validation: Implemented using Joi schemas for listings and reviews.
- Client-side validation: Bootstrap validation for forms.
This project is licensed under the ISC License.
SHIVAM