refactor: update Dockerfile cache identifiers and clean up console logs across multiple services
This commit is contained in:
+2
-3
@@ -16,7 +16,7 @@ RUN npm config set registry ${NPM_REGISTRY} \
|
|||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
|
RUN --mount=type=cache,id=pnpm-store-build,sharing=locked,target=/pnpm/store \
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -26,9 +26,8 @@ RUN pnpm run build
|
|||||||
FROM base AS prod-deps
|
FROM base AS prod-deps
|
||||||
|
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
|
RUN --mount=type=cache,id=pnpm-store-prod,sharing=locked,target=/pnpm/store \
|
||||||
pnpm install --prod --frozen-lockfile \
|
pnpm install --prod --frozen-lockfile \
|
||||||
&& pnpm store prune \
|
|
||||||
&& rm -rf /root/.npm /root/.cache
|
&& rm -rf /root/.npm /root/.cache
|
||||||
|
|
||||||
FROM node:22-slim AS runtime
|
FROM node:22-slim AS runtime
|
||||||
|
|||||||
@@ -132,19 +132,6 @@ async function main() {
|
|||||||
})
|
})
|
||||||
upserted++
|
upserted++
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
csvPath: absolutePath,
|
|
||||||
totalRows: rows.length,
|
|
||||||
upserted,
|
|
||||||
skipped,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class BusinessActivitiesQueryService {
|
|||||||
async findAllByConsumer(consumer_id: string, select: BusinessActivitySelect) {
|
async findAllByConsumer(consumer_id: string, select: BusinessActivitySelect) {
|
||||||
const businessActivities = await this.prisma.businessActivity.findMany({
|
const businessActivities = await this.prisma.businessActivity.findMany({
|
||||||
where: { consumer_id },
|
where: { consumer_id },
|
||||||
select,
|
select: this.baseSelect,
|
||||||
})
|
})
|
||||||
return businessActivities.map(QUERY_CONSTANTS.BUSINESS_ACTIVITIES.mappedData)
|
return businessActivities.map(QUERY_CONSTANTS.BUSINESS_ACTIVITIES.mappedData)
|
||||||
}
|
}
|
||||||
@@ -34,9 +34,11 @@ export class BusinessActivitiesQueryService {
|
|||||||
|
|
||||||
const businessActivity = await this.prisma.businessActivity.findUnique({
|
const businessActivity = await this.prisma.businessActivity.findUnique({
|
||||||
where: { consumer_id, id },
|
where: { consumer_id, id },
|
||||||
select,
|
select: QUERY_CONSTANTS.BUSINESS_ACTIVITIES.select,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('businessActivity', businessActivity)
|
||||||
|
|
||||||
return QUERY_CONSTANTS.BUSINESS_ACTIVITIES.mappedData(businessActivity)
|
return QUERY_CONSTANTS.BUSINESS_ACTIVITIES.mappedData(businessActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ export function translateEnumValue(
|
|||||||
enumKey: keyof typeof translates.enums,
|
enumKey: keyof typeof translates.enums,
|
||||||
value: string | null | undefined,
|
value: string | null | undefined,
|
||||||
): EnumTranslatedValue {
|
): EnumTranslatedValue {
|
||||||
console.log(enumKey, value)
|
|
||||||
|
|
||||||
const enumsRegistry = translates.enums as EnumsRegistry
|
const enumsRegistry = translates.enums as EnumsRegistry
|
||||||
const enumMap = enumsRegistry[String(enumKey)]
|
const enumMap = enumsRegistry[String(enumKey)]
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ async function bootstrap() {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
: []
|
: []
|
||||||
|
|
||||||
console.log('envOrigins', envOrigins)
|
|
||||||
|
|
||||||
const allowedOrigins = (envOrigins.length ? envOrigins : defaultOrigins).filter(Boolean)
|
const allowedOrigins = (envOrigins.length ? envOrigins : defaultOrigins).filter(Boolean)
|
||||||
|
|
||||||
const isOriginAllowed = (origin: string) => {
|
const isOriginAllowed = (origin: string) => {
|
||||||
@@ -77,8 +75,6 @@ async function bootstrap() {
|
|||||||
const rootDomain = pattern.slice(2)
|
const rootDomain = pattern.slice(2)
|
||||||
return hostname === rootDomain || hostname.endsWith(`.${rootDomain}`)
|
return hostname === rootDomain || hostname.endsWith(`.${rootDomain}`)
|
||||||
}
|
}
|
||||||
console.log('origin', origin, 'pattern', pattern, 'hostname', hostname)
|
|
||||||
console.log(hostname === pattern || origin === pattern)
|
|
||||||
|
|
||||||
return hostname === pattern || origin === pattern
|
return hostname === pattern || origin === pattern
|
||||||
})
|
})
|
||||||
@@ -90,18 +86,14 @@ async function bootstrap() {
|
|||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: (origin, callback) => {
|
origin: (origin, callback) => {
|
||||||
if (!origin) {
|
if (!origin) {
|
||||||
console.log('1')
|
|
||||||
callback(null, true)
|
callback(null, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOriginAllowed(origin)) {
|
if (isOriginAllowed(origin)) {
|
||||||
console.log('2')
|
|
||||||
|
|
||||||
callback(null, true)
|
callback(null, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('3')
|
|
||||||
|
|
||||||
callback(new Error('Not allowed by CORS'), false)
|
callback(new Error('Not allowed by CORS'), false)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ export class BusinessActivitiesService {
|
|||||||
consumer_id,
|
consumer_id,
|
||||||
this.defaultSelect,
|
this.defaultSelect,
|
||||||
)
|
)
|
||||||
return ResponseMapper.list(
|
return ResponseMapper.list(businessActivities)
|
||||||
businessActivities.map(this.prepareBusinessActivityResponse),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOne(consumer_id: string, id: string) {
|
async findOne(consumer_id: string, id: string) {
|
||||||
@@ -72,7 +70,7 @@ export class BusinessActivitiesService {
|
|||||||
id,
|
id,
|
||||||
this.defaultSelect,
|
this.defaultSelect,
|
||||||
)
|
)
|
||||||
return ResponseMapper.single(this.prepareBusinessActivityResponse(businessActivity))
|
return ResponseMapper.single(businessActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(consumer_id: string, id: string, data: any) {
|
async update(consumer_id: string, id: string, data: any) {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { QUERY_CONSTANTS } from '@/common/queryConstants'
|
||||||
|
import { translateEnumValue } from '@/common/utils'
|
||||||
|
import { TspProviderResponseStatus } from '@/generated/prisma/enums'
|
||||||
import { PrismaService } from '@/prisma/prisma.service'
|
import { PrismaService } from '@/prisma/prisma.service'
|
||||||
import { Injectable } from '@nestjs/common'
|
import { Injectable } from '@nestjs/common'
|
||||||
import { ResponseMapper } from 'common/response/response-mapper'
|
import { ResponseMapper } from 'common/response/response-mapper'
|
||||||
@@ -6,6 +9,18 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
|||||||
export class StatisticsService {
|
export class StatisticsService {
|
||||||
constructor(private readonly prisma: PrismaService) {}
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
|
|
||||||
|
private readonly invoiceMapper = (invoice: any) => {
|
||||||
|
const { tsp_attempts, ...rest } = invoice || {}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
status: translateEnumValue(
|
||||||
|
'TspProviderResponseStatus',
|
||||||
|
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getInvoices(consumer_id: string) {
|
async getInvoices(consumer_id: string) {
|
||||||
const startOfToday = new Date()
|
const startOfToday = new Date()
|
||||||
startOfToday.setHours(0, 0, 0, 0)
|
startOfToday.setHours(0, 0, 0, 0)
|
||||||
@@ -20,10 +35,7 @@ export class StatisticsService {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
...QUERY_CONSTANTS.SALE_INVOICE.summarySelect,
|
||||||
code: true,
|
|
||||||
total_amount: true,
|
|
||||||
created_at: true,
|
|
||||||
consumer_account: {
|
consumer_account: {
|
||||||
select: {
|
select: {
|
||||||
role: true,
|
role: true,
|
||||||
@@ -54,6 +66,6 @@ export class StatisticsService {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return ResponseMapper.list(invoices)
|
return ResponseMapper.list(invoices.map(this.invoiceMapper))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ export class PosService {
|
|||||||
constructor(private readonly prisma: PrismaService) {}
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
|
|
||||||
async getInfo(pos_id: string) {
|
async getInfo(pos_id: string) {
|
||||||
console.log('pos_id', pos_id)
|
|
||||||
|
|
||||||
const pos = await this.prisma.pos.findUniqueOrThrow({
|
const pos = await this.prisma.pos.findUniqueOrThrow({
|
||||||
where: {
|
where: {
|
||||||
id: pos_id,
|
id: pos_id,
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
|||||||
): Promise<TspProviderSendItemResultDto> {
|
): Promise<TspProviderSendItemResultDto> {
|
||||||
const mappedRequest = this.namaProviderUtils.mapToNamaRequestDto(payload)
|
const mappedRequest = this.namaProviderUtils.mapToNamaRequestDto(payload)
|
||||||
try {
|
try {
|
||||||
console.log(mappedRequest)
|
|
||||||
|
|
||||||
const response = await this.httpClient.request(
|
const response = await this.httpClient.request(
|
||||||
this.buildSendUrl(),
|
this.buildSendUrl(),
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user