Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marketplace Request and settelment APIs #6

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1a02871
Request APIs created
Ajay-Maury Sep 20, 2023
085aa3a
Response return and logger messages implemented
Ajay-Maury Sep 21, 2023
3f91ed6
Added comments and minor updates
Ajay-Maury Sep 21, 2023
8465b0e
Added the Model for Settlement in Prisma Module
prashantesmagico Sep 21, 2023
70cc0bd
created the API to create new settlement request, get all the settlem…
prashantesmagico Sep 22, 2023
9a75b98
Added the API to update the status of a settlement request
prashantesmagico Sep 22, 2023
da17c35
Removing unnecessary modules and files.
prashantesmagico Sep 25, 2023
9d9d3ca
Dockerfile and it's config added
Ajay-Maury Sep 26, 2023
a57d184
Settlement sevice revert
prashantesmagico Sep 27, 2023
71f56bf
Added the Dummy Admin model and relation in prisma schema and changes…
prashantesmagico Sep 27, 2023
43dd043
Added the error handler across the API
prashantesmagico Sep 28, 2023
724bba8
Fix: Removing "Refund" capability from the app.
Oct 3, 2023
771a3ac
Request APIs created
Ajay-Maury Sep 20, 2023
a12142c
Response return and logger messages implemented
Ajay-Maury Sep 21, 2023
11a129f
Added comments and minor updates
Ajay-Maury Sep 21, 2023
df648e8
Fix: Removing "Refund" capability from the app.
Oct 3, 2023
59e3aef
Merge pull request #4 from COMPASS-DPG/feature/added-dockerfile
Ajay-Maury Oct 3, 2023
da79a85
Error handling modified
Ajay-Maury Oct 3, 2023
4490fd7
Error handling modified
Ajay-Maury Oct 3, 2023
5eea7e7
added filter dto
Ajay-Maury Oct 3, 2023
f5262f5
Changes as per PR review
prashantesmagico Oct 4, 2023
5701773
Refactor and changes as per PR review
prashantesmagico Oct 4, 2023
93f129d
Refactor and changes as per review
prashantesmagico Oct 4, 2023
f74854e
Merge pull request #5 from COMPASS-DPG/feature/marketplace-settlement…
Ajay-Maury Oct 4, 2023
c7868c2
updated
Ajay-Maury Oct 4, 2023
5bc4c96
Merge pull request #2 from COMPASS-DPG/feature/marketplace-request
Ajay-Maury Oct 4, 2023
93f4286
custom decorator IsSwaggerEnum created and implemented
Ajay-Maury Oct 4, 2023
daae902
updated IsSwaggerEnum decorator for optional fields
Ajay-Maury Oct 4, 2023
d1f6477
updated swagger endpoint
Ajay-Maury Oct 5, 2023
3379cd2
Resolved review changes
Ajay-Maury Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
DATABASE_URL=
PORT = 4000
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use the official Node.js image as the base image
FROM node:16

# Set the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install project dependencies
RUN npm install

# Copy the rest of the application code to the container
COPY . .

# Expose the PORT environment variable (default to 4000 if not provided)
ARG PORT=4000
ENV PORT=$PORT

# Build your Nest.js application
RUN npm run build

# Start the Nest.js application using the start:prod script
CMD ["npm", "run", "start:prod"]
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
image: marketplace-request-service
container_name: marketplace
environment:
- PORT=${PORT:-4000}
ports:
- '${PORT:-4000}:4000'
depends_on:
- db
networks:
- nest-network

db:
image: postgres:13
container_name: postgres-container
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- '5432:5432'
volumes:
- pg-data:/var/lib/postgresql/data
networks:
- nest-network

volumes:
pg-data:

networks:
nest-network:
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"@nestjs/platform-express": "^9.0.0",
"@nestjs/swagger": "^7.1.11",
"@prisma/client": "^5.3.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
Expand Down
16 changes: 0 additions & 16 deletions prisma/migrations/20230919071959_init/migration.sql

This file was deleted.

3 changes: 0 additions & 3 deletions prisma/migrations/migration_lock.toml

This file was deleted.

80 changes: 75 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,82 @@ datasource db {

// Dummy user model
model User {
id Int @id @default(autoincrement())
email String @unique
userCategory String
id Int @id @default(autoincrement())
Ajay-Maury marked this conversation as resolved.
Show resolved Hide resolved
email String @unique
role String
username String
password String
profilePicture String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
requests Request[]
Settlement Settlement[]
}

// Dummy Admin Model
model Admin {
id Int @id @default(autoincrement())
email String @unique
role String
username String
password String
profilePicture String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Settlement Settlement[]
}

model Request {
requestId Int @id @default(autoincrement())
userId Int
title String
type RequestTypeEnum
description String
status RequestStatusEnum
requestContent Json?
responseContent Json?
remark String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id]) // Specify fields and references here
Settlement Settlement?
}

model Settlement {
settlementId Int @id @default(autoincrement())
requestId Int @unique
userId Int
adminId Int
requestStatus SettlementStatusEnum
thirdPartyResponseStatus thirdPartyResponseStatusEnum
transactionId Int
content Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id]) // Specify fields and references here
admin Admin @relation(fields: [adminId], references: [id]) // Specify Admin field reference here
request Request @relation(fields: [requestId], references: [requestId])
}

enum RequestTypeEnum {
CREDIT
INVOICE_REQUEST
SETTLEMENT
}

enum RequestStatusEnum {
PENDING
IN_PROGRESS
APPROVED
REJECTED
}

enum SettlementStatusEnum {
APPROVED
REJECTED
}

enum thirdPartyResponseStatusEnum {
PENDING
VERIFIED
}
6 changes: 4 additions & 2 deletions src/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ describe('AppController', () => {
});

describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
it('should return "marketplace query service running successfully"', () => {
expect(appController.getHealth()).toBe(
'marketplace query service running successfully',
);
});
});
});
5 changes: 3 additions & 2 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Controller, Get, HttpStatus } from '@nestjs/common';
import { AppService } from './app.service';
import { ApiOperation, ApiResponse } from '@nestjs/swagger';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';

@Controller()
@ApiTags('get service health')
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
@ApiOperation({ summary: 'default route for health check' }) // Describes the operation for Swagger.
@ApiOperation({ summary: 'default route for service health check' }) // Describes the operation for Swagger.
@ApiResponse({ status: HttpStatus.OK, type: String }) // Describes the response for Swagger.
getHealth(): string {
return this.appService.getHealth();
Expand Down
4 changes: 4 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PrismaModule } from './prisma/prisma.module';
import { ConfigModule } from '@nestjs/config';
import { RequestModule } from './request/request.module';
import { SettlementModule } from './settlement/settlement.module';

@Module({
imports: [
Expand All @@ -11,6 +13,8 @@ import { ConfigModule } from '@nestjs/config';
isGlobal: true, // Make the configuration available globally
}),
PrismaModule,
RequestModule,
SettlementModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function bootstrap() {
.addApiKey(
{
type: 'apiKey',
name: 'x-thats-my-college-api-config-key',
name: 'x-marketplace-request-service-api-config-key',
in: 'header',
},
SWAGGER_CONSTANTS.SWAGGER_AUTH_SECURITY_SCHEMA_API_KEY, // API key security scheme name
Expand All @@ -52,7 +52,8 @@ async function bootstrap() {
.setTitle(SWAGGER_CONSTANTS.TITLE)
.setDescription(SWAGGER_CONSTANTS.DESCRIPTION)
.setVersion(SWAGGER_CONSTANTS.VERSION)
// .addTag(SWAGGER_TAGS. ) // Add a tag for API grouping
.addTag(SWAGGER_TAGS.REQUEST) // Add a tag for API grouping
.addTag(SWAGGER_TAGS.SETTLEMENT) // Add a tag for API grouping

.build();

Expand Down
2 changes: 1 addition & 1 deletion src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { INestApplication, Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';

@Injectable()
Expand Down
Loading