This is a web application built with Express.js, MongoDB, HTML, CSS, and JavaScript. It serves as a marketplace where users can create accounts, post advertisements for their products, and browse through available products.
- User Authentication: Users can create accounts and log in securely.
- Advertisement Management: Users can create, view, edit, and delete advertisements for their products.
- Image Upload: Users can upload images for their product advertisements.
- Admin Panel: Administrators can approve or delete advertisements before they are displayed publicly.
- Search and Filtering: Users can search for products and filter them based on category and price.
- Clone the repository:
$ git clone https://github.com/BruceICzw/Musika
- Install dependencies
$ cd marketplace-web-app
$ npm install
-
Set up MongoDB
Make sure MongoDB is installed and running on your system.
Update the MongoDB connection string in config/config.js if necessary.
-
Start the server
$ npm run start:dev
- Open your web browser and go to
http://localhost:3000
to access the application.
GET /api/adverts
: Get all approved advertsPOST /api/adverts/upload
: Create a new advert (authenticated)GET /api/adverts/:category
: Get approved adverts by categoryPUT /api/advert/:id
: Update advert by ID (authenticated)DELETE /advert/delete/:id
: Delete advert by ID (authenticated)
GET /api/user/profile
:Get currently logged in userPUT /api/user/profile
: Update profileDELETE /api/user/delete/:id
: Delete profile by ID
GET /api/admin/pending
: Get all adverts (authenticated)PUT /api/admin/approve/:id
: Approve advert by ID (authenticated)DELETE /api/admin/delete/:id
: Delete advert by ID (authenticated)
POST /api/auth/register
: Register a new userPOST /api/auth/login
: Login with username and password to get JWT token
{
"image": "image",
"productName": "String",
"category": "String",
"description": "String",
"price": "Number",
"time": "String",
"advertiserContact": "String",
"approved": "Boolean",
"user": "ObjectId"
}
{
"name": "String",
"surname": "String",
"email": "String",
"username": "String",
"password": "String",
"role": "String"
}
{
"username": "String",
"password": "String"
}
{
"token": "JWT Token"
}
public/
: Contains static assets such as CSS, JavaScript, and images.src/
: Contains server-side code, including controllers, models, routes, and views.config/
: Contains configuration files, such as database connection settings.middleware/
: Contains custom middleware functions.uploads/
: Folder to store uploaded images.server.js
: Entry point of the application.
Express.js
: Web framework for Node.jsMongoose
: MongoDB object modeling toolbcryptjs
: Password hashing libraryjsonwebtoken
: JWT authentication librarymulter
: Middleware for handling file uploadsnodemon
: Library for automatically restarting the server when changes are madecors
: Library for enabling CORS in Express.jscookie-parser
: Library for parsing cookies in Express.jsejs
: Embedded JavaScript templating engine
Contributions are welcome! Feel free to open issues or submit pull requests
This project is licensed under the terms of the MIT license. See the LICENSE file for details.