This is the Eventslap backend (express API) repo.
- Backend live server: Backend live server
Eventslap is Full-stack application using the MERN stack (MongoDB, Express, React, and Node.JS) This repository contains the backend code for the server of this application. It is a REST API built with ExpressJS, MongoDB, and Mongoose.
It allows logged-in users to manage all the events and venues that they own in the database doing full CRUD. Anonymous users can see venues, events and free events, and also doing search by name or date. Logged-in users can create new venues and events, and view all existing ones.
-
REST API backend built with ExpressJS, MongoDB, and Mongoose.
-
REST API backend with routes that perform all CRUD actions for two models (excluding the user model).
-
Backend validation and centralized error handling the REST API.
-
SPA frontend, built with React, consisting of multiple views and implementing all CRUD actions.
-
Include sign-up, log-in, and log-out functionality with encrypted passwords and authorization (logged-in users can do additional things).
-
Deployed live version: Live demo
-
Frontend client repo: Frontend Client Repo
To run on your computer, follow these steps:
- Clone the repository.
- Install dependencies:
npm install
. - Create a
.env
file with the following environment variables:PORT=<your-port>
(5005)ORIGIN=http:/http://localhost:5173/
TOKEN_SECRET=<your-token-secret>
- Run the application:
node server.js
.
Add the following environment variables in .env
files:
PORT=<your-port>
(5005)ORIGIN=http:/http://localhost:5173/
TOKEN_SECRET=<your-token-secret>
CLOUDINARY_NAME = add-your-cloudinary-name
CLOUDINARY_KEY = add-your-cloudinary-key
CLOUDINARY_SECRET = add-your-cloudinary-secret
VITE_APP_URL=http://localhost:5005
-
TOKEN_SECRET=<your-token-secret>
-
MONGODB_URI=mongodb+srv://<your-mongodb-atlas-password-+-name-of-db>
-
ORIGIN=<your-netlify-app-domain>
-
CLOUDINARY_NAME = add-your-cloudinary-name
-
CLOUDINARY_KEY = add-your-cloudinary-key
-
CLOUDINARY_SECRET = add-your-cloudinary-secret
-
CI=false
(required for SPA applications deployed on this service to redirect requests to index.html) -
VITE_API_URL=<your-adaptable-app-domain>
-
CLOUDINARY_NAME = add-your-cloudinary-name
-
CLOUDINARY_KEY = add-your-cloudinary-key
-
CLOUDINARY_SECRET = add-your-cloudinary-secret
HTTP verb | URL | Request body | Action |
---|---|---|---|
GET | /events |
(empty) | Returns all the events |
POST | /events |
JSON | Adds a new event |
GET | /events/:eventId |
(empty) | Returns the specified event |
PUT | /events/:eventId |
JSON | Edits the specified event |
DELETE | /events/:eventId |
(empty) | Deletes the specified evet |
HTTP verb | URL | Request body | Action |
---|---|---|---|
GET | /venues |
(empty) | Returns all the venues |
POST | /venues |
JSON | Adds a new venue |
GET | /venues/:venueId |
(empty) | Returns the specified venue |
PUT | /venues/:venueId |
JSON | Edits the specified venue |
DELETE | /venues/:venueId |
(empty) | Deletes the specified venue |
HTTP verb | URL | Request body | Action |
---|---|---|---|
GET | /user/:userId |
(empty) | Returns the specified user |
PUT | /user/:userId |
JSON | Edits the specified user |
DELETE | /user/:userId |
(empty) | Deletes the specified user |
HTTP verb | URL | Request Headers | Request Body |
---|---|---|---|
POST | /auth/signup |
-- | { email, password, name } |
POST | /auth/login |
-- | { email, password } |
GET | /auth/verify |
Authorization: Bearer < JWT > | -- |
HTTP verb | URL | Request Headers | Request Body |
---|---|---|---|
POST | /api/upload |
JSON | Route that receives the image, |
sends it to Cloudinary via the | |||
fileUploader and returns the | |||
image URL |
{
title: { type: String, required: true, unique: true },
eventType: {
type: [String],
enum: [
"Concert",
"Exhibition",
"Market",
"Party",
"Theatre",
"Other",
],
required: true,
},
imageUrl: {
type: String,
default: "https://www.format.com/wp-content/uploads/celebrate-event-photography.jpg",
},
description: { type: String, required: true },
date: { type: Date, required: true, default: Date.now },
isEighteen: { type: Boolean},
isFree: { type: Boolean},
price: { type: Number},
venue: {
type: mongoose.Schema.Types.ObjectId,
ref: "Venue",
},
author: {
type: mongoose.Schema.Types.ObjectId,
ref: "User"
}
}
name: {type: String, required: true, unique: true},
venueType: {
type: String,
enum: ["Outdoor", "Indoor", "Other"], required: true},
capacity: {type: Number},
isFoodAvailable: {type: Boolean},
isDrinksAvailable: {type: Boolean},
event: {
type: mongoose.Schema.Types.ObjectId,
ref: "Event"
},
imageUrl: {
type: String,
default: "https://memo.thevendry.com/wp-content/uploads/2022/06/iStock-13447299461.jpg",
},
address: {
type: String,
required: true
},
latitude: {
type: Number,
},
longitude: {
type: Number,
},
author: {
type: mongoose.Schema.Types.ObjectId,
ref: "User"
}
{
email: {
type: String,
required: [true, "Email is required."],
unique: true,
lowercase: true,
trim: true,
},
password: {
type: String,
required: [true, "Password is required."],
},
name: {
type: String,
required: [true, "Name is required."],
},
username: {
type: String,
unique: true,
},
avatar: {
type: String,
default: "https://variety.com/wp-content/uploads/2021/04/Avatar.jpg?w=800&h=533&crop=1",
},
about: {
type: String,
default: "I am using EventSlap.",
}