Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fms-faisal/skyview-apartments-server
Skyview Apartments: Building Management System
https://github.com/fms-faisal/skyview-apartments-server
cors dotenv expressjs json-web-token mongodb stripe-payments
Last synced: 23 days ago
JSON representation
Skyview Apartments: Building Management System
- Host: GitHub
- URL: https://github.com/fms-faisal/skyview-apartments-server
- Owner: fms-faisal
- Created: 2024-06-25T18:41:41.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-02T10:09:03.000Z (6 months ago)
- Last Synced: 2024-07-14T19:47:45.685Z (5 months ago)
- Topics: cors, dotenv, expressjs, json-web-token, mongodb, stripe-payments
- Language: JavaScript
- Homepage: https://skyviewapartments-c882f.web.app/
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is the server side github of **https://github.com/fms-faisal/skyview-apartments-client**
# Skyview Apartment Management API## Introduction
This Node.js Express application provides a backend API for managing apartments, reservations, users, announcements, and payments for an apartment complex named "Skyview Apartments."## Technologies Used
- **Express.js**: Web framework for building APIs
- **MongoDB**: NoSQL database for data storage
- **JWT (JSON Web Token)**: Authentication mechanism
- **Stripe**: Payment processing platform## Installation
1. Clone this repository.
```
git clone https://github.com/fms-faisal/skyview-apartments-server.git
```2. Navigate to the project directory.
```
cd skyview-apartments-server
```
3. Install dependencies:
```
npm install
```
4. **Set Up Environment Variables**
Create a `.env` file in the project root directory and set the following environment variables:
- `DB_USER`: Your MongoDB username
- `DB_PASS`: Your MongoDB password
- `ACCESS_TOKEN_SECRET`: A secret key used for generating JWT tokens
- `STRIPE_SECRET_KEY`: Your Stripe secret key5. Start the server:
```
node index.js
```
2. The server will listen on port 5000 by default (configurable via `PORT` environment variable).## API Endpoints
### User Management
- **GET** `/users` (Public): Retrieves all users.
- **GET** `/users/admin/:email` (Protected): Checks if a user is an admin. Requires a valid JWT token in the authorization header.
- **GET** `/users/member/:email` (Protected): Checks if a user is a member. Requires a valid JWT token in the authorization header.
- **POST** `/users` (Public): Creates a new user.
- **DELETE** `/users/:id` (Protected, Admin Only): Deletes a user. Requires a valid JWT token and admin privileges in the authorization header.
- **PATCH** `/users/admin/:id` (Protected, Admin Only): Updates a user's role to "admin." Requires a valid JWT token and admin privileges in the authorization header.### Apartment Management
- **GET** `/apartments` (Public): Retrieves all apartments.### Reservation Management
- **POST** `/reservation`: Creates a new reservation.
- **GET** `/reservation/agreement`: Retrieves pending reservations.
- **DELETE** `/reservation/:id`: Deletes a reservation.### JWT Authentication
- **POST** `/jwt` (Public): Generates a JWT token for a user.### Announcement Management
- **GET** `/announcement`: Retrieves all announcements.
- **POST** `/announcement`: Creates a new announcement.### Payment Management
- **POST** `/create-payment-intent`: Creates a Stripe payment intent for a specific amount.
- **POST** `/payments`: Records a payment and deletes associated reservations.
- **GET** `/payments/:email`: Retrieves payments for a specific user (based on email).