Online auction platform
Prettier is configured to format the staged files and commit. using husky pre-commit hook
to skip the formatting use the git commit with -n or --no-verify flag also add files to .prettierignore file to ignore the formatting
- Java 21
- Maven
- Docker
- Change directory to backend
cd backend- Setup the environment variables and Firebase credentials json
Copy the .env.example and rename the copy to .env
cp .env.example .envEdit the .env by the placeholder values with your actual configurations for your database, mail server, and other environment settings
Note: for mail server you can use any SMTP server or a service like mailtrap for testing
Configure Firebase:
- Go to the Firebase Console.
- Select your Firebase project.
- Navigate to Project settings > Service accounts.
- Under Firebase Admin SDK, click Generate new private key. This will download a JSON file containing your service account credentials.
- Add Firebase credentials to the backend .env, the environment variables corresponding to each key in the JSON file are in the format
FIREBASE_{KEY_NAME}. For example, if your JSON file has a key calledproject_id, you would set it in the .env asFIREBASE_PROJECT_ID. refer to env.example for the env variable formats
- Start the docker container for the database
docker compose up- Run the backend
### without wrapper
mvn spring-boot:runFlyway is used to manage the database migrations in AuctiX application.
The migrations are stored in the backend/src/main/resources/db/migration directory.
The migrations should be created in the following format:
V{version}__{description}.sql
Example:
-
V1__create_user_table.sqlCREATE TABLE user ( id SERIAL PRIMARY KEY, username VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL );
-
V2__add_profile_pic_url_col_to_user_table.sqlALTER TABLE user ADD COLUMN profile_pic_url VARCHAR(255);
The migrations will be applied to the database when the application is started.
Endpoint:
POST /api/auth/register
Request Body:
{
"email": "user@example.com",
"username": "exampleUser",
"password": "securePassword",
"role": "SELLER"
}Response:
200 OK → User registered successfully
400 Bad Request → Invalid request
Endpoint:
POST /api/auth/login
Request Body:
{
"email": "user@example.com",
"password": "securePassword"
}Response:
200 OK → Returns JWT token
401 Unauthorized → Email or password incorrect
Include the token in the Authorization header for protected routes.
Example:
Authorization: Bearer <your-jwt-token>
Use the pre-configured axios instance as follows. This will automatically handle signing out the user if the JWT token is expired or invalid.
import { AxiosInstance } from 'axios';
import AxiosReqest from '@/services/axiosInspector';
export function FunctionalComponent(){
const axiosInstance: AxiosInstance = AxiosReqest()
.axiosInstance;
axiosInstance
.get('/user/getUsers', {
//set params, headers...
})
.then((data) => {
// after fetch data
})
}import { AxiosInstance } from 'axios';
import AxiosReqest from '@/services/axiosInspector';
exprot function FunctionalComponent(){
const axiosInstance: AxiosInstance = AxiosReqest()
.axiosInstance;
axiosInstance
.get('/user/getUsers', {
//set params, headers...
})
.then((data) => {
// after fetch data
console.log(data);
})
}