This is the backend for the MyPolls application, a poll management tool built with Node.js and Express. It provides a REST API for managing polls, their options, and user authentication, ensuring secure access to poll data.
- MyPolls Deploy App: https://mypolls-app.onrender.com/
- Mypolls Deploy Api: https://mypolls-api.onrender.com/
- CRUD operations for managing polls.
- Each poll can have multiple response options.
- API follows RESTful principles for easy integration with the frontend.
- User authentication to restrict access to polls.
- API documentation available via Swagger.
- Clone this repository:
git clone https://github.com/taisbronca/mypolls-api.git- Navigate into the project directory:
cd mypolls-api- Install dependencies:
npm install
# Or if using yarn
yarn install- Run the server:
npm run dev
# Or with yarn
yarn devThe API will be accessible at http://localhost:3000.
- View API documentation: Access the Swagger documentation at http://localhost:3000/doc/.
- Node.js and Express for the server-side logic.
- MongoDB for data persistence.
- Swagger for Documentation.
The frontend for the MyPolls application is available here.
- /polls: Create, read, update, and delete polls.
- /users: Create, read, ad update users.
- /auth: User authentication and authorization routes.
- Server running at: http://localhost:3000
- Swagger documentation: http://localhost:3000/doc/
To run the MyPolls API, make sure to set up the following environment variables:
- MONGODB_URI: Your MongoDB connection string from MongoDB Atlas. After mongodb.net/, make sure to add the name of your database.
Example:
MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/<dbname>?retryWrites=true&w=majority- SECRET_JWT: A secret key used for generating JSON Web Tokens (JWT). You can generate a secure key using an MD5 hash generator.
Example:
SECRET_JWT=your-md5-generated-secretCreate a .env file in the root directory of your project and add the variables like this:
MONGODB_URI=<your-mongodb-uri>
SECRET_JWT=<your-secret-jwt>This project is licensed under the MIT License.