Before you need install follow tools in your machine: Git, Node.js, Docker. Beyond is good to has an editor for to work with the code like VSCode
- 1. Overview
- 2. How To Run
- 3. Prisma Local Database
- 4. How to create a new branch
- 5. Software Architecture
- 6. Documentation
- 7. Recommended Extensions
Bank is an API to open a new "current account" of already existing customers
Result:
# Clone this repository
$ git clone https://github.com/LucasJunio/bank
# Acces the project folder in your terminal/cmd
$ cd bank
# Copy base.env to .env
$ cp base.env .env
# Build the image docker
$ docker build -t bank .
# Run tests
$ docker run -e CI=true bank npm run test
# Build the container docker
$ docker run -p 3000:3000 bank
# Access SWAGGER documentation in:
http://localhost:3000/api
# The aplication going to open in port:3000 - access http://localhost:3000
Run the development server local with "yarn", "npm", "pnpm" or manager package your preference:
# Create .env file
$ cp base.env .env
# Install dependencies
$ yarn install
# Generate the TypeScript code associated with your database models
$ npx prisma generate
# Building migrations
$ npx prisma migrate dev
# Building mock data
$ npx prisma db seed
# Run the project
$ yarn start
The aplication going to open in port:3000 - access http://localhost:3000
You can login by sending a POST request to the /current-account/
endpoint. Here's an example using cURL:
curl -X POST \
-H "Content-Type: application/json" \
-d '{
{
"custumerId": 1,
"initialCredit": 25.51
}
}' \
http://localhost:3000/current-account/
The response will be status code 201 created and informations about the new account.
You can evaluate the basic info route by sending a GET request to the http://localhost:3000/current-account/basic-info/:id
endpoint. Here's an example using cURL:
curl -X GET
-H "Content-Type: application/json" \
http://localhost:3000/current-account/basic-info/:id
The response will be status code 200 success and informations about the account {:id}.
POST http://localhost:3000/current-account/
:GET http://localhost:3000/current-account/basic-info/1
:
You can see the local database Prisma Studio is up on http://localhost:5555.
# Running local database
$ npx prisma studio
Result:
Ever that's necessary to create a new branch feature, create by [main]branch, implement your development, merge this feature/branch to develop, when all it's ok, give a merge of this feature/branch to main[branch].
Let's go to follow the git flow patterns to create a new branch, to more info browse in link below to learn more how to implement in simple way.
Workflow gitflow: https://www.atlassian.com/br/git/tutorials/comparing-workflows/gitflow-workflow
# Example creating a new branch
$ git checkout -b feature/TASK-1
For commit your changes, you can follow the suggestion to use conventional commits [https://www.conventionalcommits.org/en/v1.0.0/] for to improve your commit descriptions and help the understand of the team. Exist a extension in vscode that can help you with this mission.
vscode extension id in .vscode/extensions.json:
"recommendations": ["vivaxy.vscode-conventional-commits"]
Main folder tree.
C:.
- src
- ├───core
- ├───modules
- │ ├───controller
- │ ├───inputs
- │ ├───repository
- │ ├───schema
- │ ├───service
- │ └───validators
Diagram:
see diagram entity relationship for documentation
You can check out a list of recommended extensions in the file .vscode/extensions.json
, or by opening the "Extensions" Tab in the "Recommended" pane.
Lucas Junio 🚀
Made with ❤️ by Lucas Junio 👋🏽 Contact