This microservice consists of user-related services. It is responsible for user authentication and authorization. It uses JWT for authentication and authorization. It also uses Prisma as ORM to interact with the database.
-
Express with Typescript
-
Postgres as Database
-
Prisma as ORM
- Copy the sample env file and modify according to your need.
- Run the command to install all dependencies:
npm i
- Run the command to generate migration files:
npx prisma generate
- Run the command to run the migrations:
npx prisma migrate dev
- Run the command to start the server:
npx run dev
-
GET: /ping
{
"response": {
"message": "pong",
}
}
-
POST: /api/auth/signup
{
"body": {
"name": "John Doe",
"email": "[email protected]",
"password": "password"
}
}
{
"response": {
"message": "User created successfully",
"payload": "jwt token"
}
}
-
POST: /api/auth/login
{
"body": {
"email": "[email protected]",
"password": "password",
}
}
{
"response": {
"message": "User logged in successfully",
"payload": "jwt token",
}
}
-
POST: /api/auth/validate
{
"body": {
"token": "jwt token",
}
}
{
"response": {
"message": "Token validated successfully",
"payload": "new jwt token"
}
}
-
GET: /api/auth/user/:token
{
"message": "User data retrieved successfully",
"payload": {
"id": "user_id",
"name": "John Doe",
"email": "[email protected]"
}
}