dev-luckymhz / currency-portfolio-backend

Portfolio currency API with Node.js and Mongoose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome

LinkedIn e-mail

Currency Portfolio backEnd

Alt Text

Currency Portfolio is a web application that allows users to manage their cryptocurrency portfolio. Users can track their holdings, view current market prices, and analyze their portfolio performance.

Table of Contents

Features

  • User registration and authentication
  • Add, edit, and delete cryptocurrencies from the portfolio
  • View real-time market prices of cryptocurrencies
  • Calculate the total portfolio value
  • Track portfolio performance over time
  • User-friendly and responsive interface

Prerequisites

Before running the app, ensure that you have the following dependencies installed on your machine:

  • Node.js
  • npm (Node package manager)
  • MongoDB

Installation

  1. Clone the repository:
git clone https://github.com/Zo-ambinintsoa/currency-portfolio-backend.git
  1. Navigate to the project directory:
 cd currency-portfolio-backend
  1. Install the package:
 npm install

usage

To start the development server, run the following command:

 npm start

This will start the development server. You can access it at http://localhost:4000.

The app provides a an endpoint for you to consumme using postman or other testing app.

Feel free to customize the app by modifying the code in the src directory.

API Documentation

Currency Portfolio API Documentation

This API documentation provides details about the available routes and their functionalities in the Currency Portfolio application.

Base URL

The base URL for all the routes is:

http://localhost:4000

Authentication Routes

Login

  • URL: /api/login
  • Method: POST
  • Description: Authenticates a user and generates an authentication token.
  • Request Body:
    • email: User's email (string)
    • password: User's password (string)

Register

  • URL: /api/signup
  • Method: POST
  • Description: Registers a new user.
  • Request Body:
    • email: User's email (string)
    • password: User's password (string)

Change Password

  • URL: /api/changePassword
  • Method: POST
  • Description: Changes the password of an authenticated user.
  • Authentication Required: Yes
  • Request Body:
    • oldPassword: User's current password (string)
    • newPassword: User's new password (string)

Get User Profile

  • URL: /api/logout
  • Method: GET
  • Description: Retrieves the user profile.
  • Authentication Required: Yes

Update User Profile

  • URL: /api/logout
  • Method: GET
  • Description: Updates the user profile.
  • Authentication Required: Yes

Logout

  • URL: /api/logout
  • Method: GET
  • Description: Logs out the user.
  • Authentication Required: Yes

Currency Routes

Create a New Currency

  • URL: /currencies
  • Method: POST
  • Description: Creates a new currency.
  • Authentication Required: Yes
  • Admin Access Required: Yes
  • Request Body:
    • ticker: Currency's ticker symbol (string)
    • name: Currency's name (string)
    • APIUrl: Currency's API URL (string)

Get All Currencies

  • URL: /currencies
  • Method: GET
  • Description: Retrieves all currencies.
  • Authentication Required: Yes

Get a Specific Currency

  • URL: /currencies/:id
  • Method: GET
  • Description: Retrieves a specific currency by its ID.
  • Authentication Required: Yes

Update a Currency

  • URL: /currencies/:id
  • Method: PUT
  • Description: Updates a specific currency by its ID.
  • Authentication Required: Yes
  • Admin Access Required: Yes
  • Request Body:
    • ticker: Currency's ticker symbol (string)
    • name: Currency's name (string)
    • APIUrl: Currency's API URL (string)

Delete a Currency

  • URL: /currencies/:id
  • Method: DELETE
  • Description: Deletes a specific currency by its ID.
  • Authentication Required: Yes
  • Admin Access Required: Yes

Authentication and Authorization

  • The authentication routes (/api/login, /api/signup, /api/changePassword, /api/logout) require a valid user account and generate an authentication token.
  • The routes that require authentication (/api/logout, /api/changePassword, /api/logout, /currencies, /currencies/:id) require the authentication token to be included in the request headers.
  • The routes that require admin access (/currencies, /currencies/:id) also require the user to have the isAdmin flag set to true in their profile.

Error Responses

  • Error responses will follow the standard HTTP error status codes and will include a JSON response body with an error property indicating the specific error message.

contributing

Contributions are welcome! If you have any suggestions, bug fixes, or new features to propose, please follow the steps below:

  • Fork the repository.
  • Create a new branch for your feature or bug fix.
  • Make your modifications.
  • Commit your changes and push to your forked repository.
  • Submit a pull request explaining your changes.

Author

LinkedIn e-mail

Ambinintsoa Mananjara Herizo Full Stack Developer

About

Portfolio currency API with Node.js and Mongoose


Languages

Language:JavaScript 100.0%