# EMI Backend service This is the code for the backend of the EMI website. ## Getting Started These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. ### Prerequisites What things you need to install the software and how to install them: ``` node.js npm mongodb ``` ### Installing A step by step series of examples that tell you how to get a development env running: 1. Clone the repo 2. Install NPM packages ``` npm install ``` 3. Create a `.env` file with the necessary environment variables (`PORT`, `MONGO_URL`, `STRIPE`, etc.) 4. Run the server ``` npm start ``` ### API Documentation Once the server is running, you can access the interactive API documentation powered by Swagger UI at: `http://localhost:3000/api-docs` This page allows you to view all available endpoints, their parameters, and test them directly from your browser. ## API Endpoints The API is divided into several sections based on functionality. Most routes under `/user`, `/post`, `/bible`, and `/songs` require authentication via a session cookie. ### Authentication - `POST /signup`: Creates a new user account. - `POST /login`: Logs in a user and creates a session. - `GET /logout`: Logs out the current user. - `POST /resetPassword`: Sends a password reset link to the user's email. ### General - `GET /`: Returns basic information about the logged-in user. - `GET /invite/:email`: Checks if an invitation exists for a given email. - `POST /changeProfile`: Changes the active profile for the logged-in user. - `POST /token`: Refreshes the push notification token for a profile. - `POST /subscribe`: Subscribes a profile to web push notifications. ### Profiles (`/user`) - `GET /mine`: Get all profiles for the logged-in user. - `POST /`: Creates a new profile. - `POST /invite`: Invites a new user by email. - `GET /invite/:email`: Get invitation details for an email. - `GET /groups`: Get a list of all groups. - `GET /groups/following`: Get a list of groups the current profile is following. - `POST /groups`: Create a new group. - `GET /courses`: Get a list of all courses. - `POST /groups/accept`: Accept a request to join a private group. - `POST /groups/reject`: Reject a request to join a private group. - `GET /groups/search`: Search for groups. - `GET /groups/:id`: Get details for a specific group. - `GET /groups/:id/subscribe`: Subscribe to a group. - `GET /groups/:id/unsubscribe`: Unsubscribe from a group. - `GET /search`: Search for profiles. - `POST /setData`: Set custom data for a profile. - `POST /myProfile`: Update the current user's profile. - `GET /:id`: Get a specific profile by ID. - `DELETE /:id`: Delete a profile. - `GET /:id/follow`: Follow a profile. - `GET /:id/unfollow`: Unfollow a profile. ### Posts (`/post`) - `GET /organic`: Get the organic feed for the current user. - `GET /`: Get the feed with promotional content. - `GET /tag/:tag`: Get posts with a specific tag. - `GET /usr/:id`: Get posts from a specific user. - `GET /usr/:id/images`: Get all image posts from a user. - `GET /usr/:id/embedded`: Get all embedded posts from a user. - `GET /usr/:id/media`: Get all media posts from a user. - `POST /`: Create a new post. - `POST /react`: React to a post. - `POST /unreact`: Remove a reaction from a post. - `POST /bookmark`: Bookmark a post. - `POST /unbookmark`: Remove a bookmark from a post. - `POST /comment`: Add a comment to a post. - `POST /comment/react`: React to a comment. - `POST /comment/unreact`: Remove a reaction from a comment. - `GET /images`: Get all image posts for the current user. - `GET /embedded`: Get all embedded posts for the current user. - `GET /media`: Get all media posts for the current user. - `GET /course/recent`: Get recently watched media from courses. - `GET /:id`: Get a specific post by ID. - `DELETE /:id`: Delete a post. - `POST /:id`: Update a post. ### Payments (`/payments`) - `POST /create-payment-intent`: Creates a Stripe Payment Intent. - `POST /intent`: (Alias for /create-payment-intent) - `POST /register`: Registers a payment after a successful Stripe transaction. ### Songs (`/songs`) - `GET /`: Get all songs. - `POST /`: Create a new song. - `GET /:id`: Get a specific song by ID. - `DELETE /:id`: Delete a song. - `POST /:id`: Update a song. ### Bible (`/bible`) - `GET /`: Get a list of available Bibles. - `GET /books`: Get the books of a Bible. - `GET /books/:bookId`: Get details for a specific book. - `GET /books/:bookId/chapters`: Get the chapters of a book. - `GET /chapters/:chapterId`: Get the content of a chapter. - `GET /chapters/:chapterId/verses`: Get the verses of a chapter. - `GET /search`: Search the Bible. ### Subsplash (`/subsplash`) - `GET /events/:calendarId`: Get events from a Subsplash calendar. - `GET /media/:seriesId`: Get media from a Subsplash media series. ### TODO - [ ] Define nodes schema - [ ] Implement basic login/registration