Revie is a platform where users can sign up, post reviews about apartments they've lived in, including optional videos and/or images. Users can review landlords, the environment, and the quality of amenities. Reviews can be marked as helpful by visitors and can be sorted by helpfulness or recency.
- User registration and authentication
- Posting reviews with text, images, and videos
- Marking reviews as helpful
- Sorting reviews by helpfulness or recency
-
Clone the repository:
git clone https://github.com/isaac0yen/revie.git cd revie
-
Install dependencies:
npm install
-
Set up the database:
- Ensure you have MySQL installed and running.
- Create a database for the project.
-
Set up environment variables:
- Create a
.env
file in the root directory and add the following variables:
DB_HOST=your_database_host DB_USER=your_database_user DB_PASSWORD=your_database_password DB_NAME=your_database_name JWT_SECRET=your_jwt_secret
- Create a
-
Run the database setup script to create tables:
node setupDatabase.js
Make sure to create a .env
file in the root directory with the following content:
DB_HOST=your_database_host
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_NAME=your_database_name
JWT_SECRET=your_jwt_secret
Start the server:
npm start
The server will start on the port specified in your environment variables (default is 3000
).
The API documentation is generated using Swagger. Once the server is running, you can access the documentation at:
http://localhost:3000/api-docs
- POST /api/users/register
- Registers a new user.
- POST /api/users/login
- Logs in a user.
- POST /api/reviews
- Creates a new review.
- GET /api/reviews
- Retrieves all reviews.
- PATCH /api/reviews/{id}/helpful
- Marks a review as helpful.
- GET /api/reviews/sort
- Sorts reviews by helpfulness or recency.
curl -X POST http://localhost:3000/api/users/register \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "john.doe@example.com", "password": "password123"}'
curl -X POST http://localhost:3000/api/users/login \
-H "Content-Type: application/json" \
-d '{"email": "john.doe@example.com", "password": "password123"}'
curl -X POST http://localhost:3000/api/reviews \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_jwt_token>" \
-d '{"landlord": "Good landlord", "environment": "Nice environment", "amenities": "Great amenities", "images": ["image1.jpg"], "videos": ["video1.mp4"]}'
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE reviews (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
landlord VARCHAR(255) NOT NULL,
environment TEXT NOT NULL,
amenities TEXT NOT NULL,
images TEXT NULL,
videos TEXT NULL,
helpful_count INT DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
-
Ensure you have set up the environment variables on your server.
-
Clone the repository on your server:
git clone https://github.com/isaac0yen/revie.git cd revie
-
Install dependencies:
npm install
-
Start the server:
npm start
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature-branch
- Open a pull request.