A NestJS-based RESTful API , using TypeORM with PostgreSQL. This README provides instructions for contributors to set up the project and details the available API endpoints.
| Method | Endpoint | Description | Request Body | Response |
|---|---|---|---|---|
| POST | /users |
Create a new user | CreateUserDto (name, email, password) |
UserResponseDto (name, email, message) |
| GET | /users/:id |
Get a user by ID | None | UserResponseDto (name, email, message) |
| GET | /users |
Get all users | None | UserResponseDto[] |
| PUT | /users/:id |
Update a user by ID | UpdateUserDto (name?, email?, password?) |
UserResponseDto (name, email, message) |
| DELETE | /users/:id |
Delete a user by ID | None | string (success message) |
curl -X POST http://localhost:3000/users -H "Content-Type: application/json" -d '{ "name": "Oladele20", "email": "samuel@mailto.com","password": "password3" }'Response:
{
"name": "Oladele20",
"email": "samuel@mailto.com",
"message": "user created successfully..."
}curl http://localhost:3000/users/1Response:
{
"name": "Oladele20",
"email": "samuel@mailto.com",
}curl http://localhost:3000/usersResponse:
[
{
"name": "Oladele1",
"email": "stringing20@mail.com"
},
{
"name": "Oladele20",
"email": "samuel@mailto.com"
}
]curl -X PUT http://localhost:3000/users/1 -H "Content-Type: application/json" -d '{"name":"blurbeast"}'Response:
{
"name": "blurbeast",
"email": "samuel@mailto.com",
"message": "user updated successfully"
}curl -X DELETE http://localhost:3000/users/1Response:
"User deleted successfully"- Node.js: v20.x (install via
nvm):curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash nvm install 20 nvm use 20 - PostgreSQL: Install and ensure it’s running:
sudo apt update sudo apt install postgresql postgresql-contrib sudo service postgresql start
- Git: Installed for cloning the repository.
-
Clone the Repository:
git clone https://github.com/your-username/my-fans-backend.git cd my-fans-backend -
Install Dependencies:
npm install
-
Configure Environment: Create a
.envfile in the root directory with the following:DB_HOST=localhost DB_PORT=5432 DB_NAME=my_fans_db DB_USERNAME=postgres DB_PASSWORD=password
-
Start the Application:
npm run start:dev
-
Test APIs: Use the
curlcommands in the API Documentation section to verify endpoints.
- Fork the repository.
- Clone your fork locally:
git clone https://github.com/your-username/my-fans-backend.git
- Create a feature branch:
git checkout -b feature/your-feature
- Make changes and commit:
If Husky linting blocks the commit, bypass temporarily:
git commit -m "Add your feature or fix"git commit -m "Add your feature or fix" --no-verify - Push to your fork:
git push origin feature/your-feature
- Open a Pull Request on the main repository.
- Not-Null Constraint Errors:
- Ensure
CreateUserDtohas valid data forname,email, andpassword. - Check migrations for correct
Usertable schema (NOT NULLconstraints).
- Ensure
- Database Connection Issues:
- Verify
.envvariables (DB_HOST,DB_PORT,DB_NAME,DB_USERNAME,DB_PASSWORD). - Check PostgreSQL status:
sudo service postgresql status
- Verify
MIT License# MyFanss_Backend