Skip to content

About

Backend API for My Polls, built with Node.js and Express. Provides CRUD operations for managing polls and their options, with optional user authentication.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

Repository files navigation

MyPolls API

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.

Features

  • 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.

Getting Started

  1. Clone this repository:
git clone https://github.com/taisbronca/mypolls-api.git
  1. Navigate into the project directory:
cd mypolls-api
  1. Install dependencies:
npm install
# Or if using yarn
yarn install
  1. Run the server:
npm run dev
# Or with yarn
yarn dev

The API will be accessible at http://localhost:3000.

  1. View API documentation: Access the Swagger documentation at http://localhost:3000/doc/.

Technologies

  • Node.js and Express for the server-side logic.
  • MongoDB for data persistence.
  • Swagger for Documentation.

Frontend Repository

The frontend for the MyPolls application is available here.

API Endpoints Overview

  • /polls: Create, read, update, and delete polls.
  • /users: Create, read, ad update users.
  • /auth: User authentication and authorization routes.

Development Environment

Environment Variables

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-secret

Create 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>

License

This project is licensed under the MIT License.

tags: back-end Node.js MongoDB Express

About

Backend API for My Polls, built with Node.js and Express. Provides CRUD operations for managing polls and their options, with optional user authentication.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages