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.
- 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
-
Create new user
POST /sign-up
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
{ "name": "string", "email": "string", "password": "string" }
-
Login user
POST /sign-in
Body Type Description email
string
Required - Valid email password
string
Required - Valid password password length: from 6 to 20 characters
{ "email": "string", "password": "string" }
{ "name": "string", "token": "string" }
-
Get all entries
GET /statements
Name Description authorization
Required - "Bearer {{token}}" [ { "_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
Body Type Description description
string
Description for the entry type
enum
Required - withdraw or deposit value
number
Required - Value > 0 type: "withdraw" | "deposit"
{ "description": "string", "type": "withdraw", "value": 1250 }
Name Description authorization
Required - "Bearer {{token}}" -
Delete message
DELETE /statements/{entryId}
Parameter Description entryId
Required - ID of entry to delete Name Description authorization
Required - "Bearer {{token}}" -
Edit message
PUT /statements/{entryId}
Body Type Description description
string
Description for the entry type
enum
Required - withdraw or deposit value
number
Required - Value > 0 type: "withdraw" | "deposit"
{ "description": "string", "type": "withdraw", "value": 1250 }
Parameter description entryId
Required - ID of entry to edit Name Description authorization
Required - "Bearer {{token}}"
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
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)