https://github.com/angelomca09/investments-backend
An Investments backend application in Node
https://github.com/angelomca09/investments-backend
backend investments node
Last synced: about 1 month ago
JSON representation
An Investments backend application in Node
- Host: GitHub
- URL: https://github.com/angelomca09/investments-backend
- Owner: angelomca09
- Created: 2025-02-12T19:40:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-11T13:52:39.000Z (10 months ago)
- Last Synced: 2025-09-11T16:34:52.148Z (10 months ago)
- Topics: backend, investments, node
- Language: TypeScript
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Investments Backend
Initialy built with `tsc --init` and `npm init`, this project uses `tsx` to run Typescript files easier (no config).
Prisma was installed with `npx prisma init --datasource-provider sqlite` and then `npx prisma generate` to generate the prisma client.
## Setup
First be sure to have a `.env` file created with the same structure as `.env.example`.
To setup prisma: `npm run db:migrate`.
To run the application: `npm run dev`.
## Routes
| HTTP Method | Endpoint | Description | Request Body | Response Body |
|-|-|-|-|-|
| GET | `/investments` | Fetch all investments | N/A | Array of investments |
| POST | `/investments` | Create a new investment | `{ description, value, date, status, type }` | Created investment object |
| PUT | `/investments/:id` | Update an existing investment| Partial `{ description, value, date, status, type }` | Updated investment object |
| DELETE | `/investments/:id` | Delete an investment | N/A | N/A |
### Examples
**GET** `/investments` : Fetch all investments from the database.
Response:
```json
[
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"description": "Investment",
"value": 1000,
"date": "2025-01-01T00:00:00.000Z",
"status": "DONE",
"type": "BILLS"
}
]
```
**POST** `/investments` : Create a new investment.
Request:
```json
{
"description": "Investment in home",
"value": 500,
"date": "2025-01-01",//"2025-01-01T00:00:00.000Z" would work too.
"status": "PENDING",
"type": "HOME"
}
```
Response:
```json
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"description": "Investment in home",
"value": 500,
"date": "2025-01-01T00:00:00.000Z",
"status": "PENDING",
"type": "HOME"
}
```
**PUT** `/investments:id` : Update an existing investment.
Request:
```json
{
"description": "Updated investment description"
}
```
Response:
```json
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"description": "Updated investment description",
"value": 500,
"date": "2025-01-01T00:00:00.000Z",
"status": "PENDING",
"type": "HOME"
}
```
**DELETE** `/investments:id` : Delete an investment by its ID.