Skip to content

API for My-Wallet project. It was the 13ᵗʰ project of the Driven Full Stack Bootcamp and the 1ˢᵗ full stack.

Notifications You must be signed in to change notification settings

lemoscaio/my-wallet-api

Repository files navigation


My Wallet - API

Built With


Description

API for the My Wallet web app. My Wallet is a financial controller application that uses NodeJS, Express and MongoDB to manage transactions.

It was the 1ˢᵗ full stack and the 13ᵗʰ project of the Driven Full Stack Bootcamp.

Features

  • Authentication routes for registering and logging in
    • Users created with an encrypted password and persisted to the database
    • Password strength validation
    • User session persisted to the database and validated with UUID
    • Session validation via middleware
  • Full financial statements CRUD (create, read, update, delete) with authentication headers
  • All data stored on a MongoDB database
  • All the entries are validated against schemas
  • Add withdraws or deposits, as well as the value and the description of a transaction
  • Project divided into controllers, routes, schemas, and middlewares

API Reference

Users

  • Create new user

    POST /sign-up
    Request body:
    Body Type Description
    name string Required - Valid name
    email string Required - Valid email
    password string Required - Valid password

    password length: from 6 to 20 characters

    Example:
    {
      "name": "string",
      "email": "string",
      "password": "string"
    } 
  • Login user

    POST /sign-in
    Request:
    Body Type Description
    email string Required - Valid email
    password string Required - Valid password

    password length: from 6 to 20 characters

    Example:
    {
      "email": "string",
      "password": "string"
    } 

    Response:

    { 
      "name": "string", 
      "token": "string"
    }

Financial Statements

  • Get all entries

    GET /statements

    Headers:

    Name Description
    authorization Required - "Bearer {{token}}"

    Response:

    [
      {
        "_id": "string",
        "userId": "string",
        "description": "string",
        "value": "number",
        "type": "string"
      },
      {
        "_id": "string",
        "userId": "string",
        "description": "string",
        "value": "number",
        "type": "string"
      }
    ]

    type: "withdraw" | "deposit"

  • Post a new entry

    POST /statements
    Request:
    Body Type Description
    description string Description for the entry
    type enum Required - withdraw or deposit
    value number Required - Value > 0

    type: "withdraw" | "deposit"

    Request body:

    {
      "description": "string",
      "type": "withdraw",
      "value": 1250
    }  

    Headers:

    Name Description
    authorization Required - "Bearer {{token}}"
  • Delete message

    DELETE /statements/{entryId}

    Path parameters:

    Parameter Description
    entryId Required - ID of entry to delete

    Headers:

    Name Description
    authorization Required - "Bearer {{token}}"
  • Edit message

    PUT /statements/{entryId}
    Request:
    Body Type Description
    description string Description for the entry
    type enum Required - withdraw or deposit
    value number Required - Value > 0

    type: "withdraw" | "deposit"

    Request body:

    {
      "description": "string",
      "type": "withdraw",
      "value": 1250
    }  

    Path parameters:

    Parameter description
    entryId Required - ID of entry to edit

    Headers:

    Name Description
    authorization Required - "Bearer {{token}}"

Run Locally

Clone the project:

  git clone https://github.com/lemoscaio/my-wallet-api.git

Go to the project directory:

  cd my-wallet-api

Install dependencies:

  npm install

Set up the environment variables in the .env file, using the .env.example.

Make sure the MongoDB server is running and available.

Start the server:

  node server.js

Lessons Learned

In this project I learned the following:

  • to build a secure app with encrypted data persisted in the database
  • to organize the project in some layers such as controllers, middlewares, routers, and schemas
  • to use middleware to reuse some logic and to isolate responsibilities of functions that might occur before the controller
  • to deploy the back-end on some platforms such as Heroku and MongoDB Atlas (for the database)

Acknowledgements

About

API for My-Wallet project. It was the 13ᵗʰ project of the Driven Full Stack Bootcamp and the 1ˢᵗ full stack.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published