bugs
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.git
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
*.log
|
||||||
|
*.tar.gz
|
||||||
|
*.tar
|
||||||
|
coverage
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.DS_Store
|
||||||
+4
-1
@@ -55,4 +55,7 @@ pids
|
|||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
/react/*
|
/react/*
|
||||||
|
|
||||||
|
*.tar
|
||||||
|
*.tar.gz
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
registry=https://mirror-npm.runflare.com
|
# registry=https://mirror-npm.runflare.com
|
||||||
# registry=https://package-mirror.liara.ir/repository/npm/
|
# registry=https://package-mirror.liara.ir/repository/npm/
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
# Stage 1: Base
|
||||||
|
FROM node:22-alpine AS base
|
||||||
|
|
||||||
|
# Timezone (Node 22 respects TZ without needing tzdata installed)
|
||||||
|
ENV TZ=Asia/Tehran
|
||||||
|
|
||||||
|
# Set workdir for clarity
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Stage 2: Dependencies
|
||||||
|
FROM base AS deps
|
||||||
|
WORKDIR /temp-deps
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm config set registry https://registry.npmjs.org/ && npm ci
|
||||||
|
|
||||||
|
# Stage 3: Production dependencies
|
||||||
|
FROM base AS prod-deps
|
||||||
|
WORKDIR /temp-prod-deps
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm config set registry https://registry.npmjs.org/ && npm ci --omit=dev --ignore-scripts
|
||||||
|
|
||||||
|
# Stage 4: Build
|
||||||
|
FROM base AS builder
|
||||||
|
WORKDIR /build
|
||||||
|
COPY package*.json ./
|
||||||
|
COPY --from=deps /temp-deps/node_modules ./node_modules
|
||||||
|
COPY . ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 5: Runner
|
||||||
|
FROM base AS runner
|
||||||
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder --chown=appuser:appgroup /build/ ./
|
||||||
|
COPY --from=prod-deps --chown=appuser:appgroup /temp-prod-deps/node_modules ./node_modules
|
||||||
|
|
||||||
|
USER appuser
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
EXPOSE 4000
|
||||||
|
|
||||||
|
CMD ["npm", "start"]
|
||||||
|
|
||||||
-79
@@ -1,79 +0,0 @@
|
|||||||
# Stage 1: Base
|
|
||||||
FROM node:22-alpine AS base
|
|
||||||
|
|
||||||
# Install timezone support
|
|
||||||
RUN apk add --no-cache tzdata
|
|
||||||
RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
|
|
||||||
|
|
||||||
# Set workdir for clarity
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Stage 2: Dependencies
|
|
||||||
FROM base AS deps
|
|
||||||
WORKDIR /temp-deps
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm ci --ignore-scripts
|
|
||||||
|
|
||||||
# Stage 3: Build
|
|
||||||
FROM base AS builder
|
|
||||||
WORKDIR /build
|
|
||||||
COPY . ./
|
|
||||||
COPY --from=deps /temp-deps/node_modules ./node_modules
|
|
||||||
RUN if [ -f package.json ] && grep -q '"build":' package.json; then npm run build; fi
|
|
||||||
|
|
||||||
# Stage 4: Runner
|
|
||||||
FROM base AS runner
|
|
||||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY . ./
|
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/ ./
|
|
||||||
RUN chown -R appuser:appgroup /app
|
|
||||||
|
|
||||||
USER appuser
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
EXPOSE 4000
|
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
|
||||||
|
|
||||||
# # Stage 1: Build Stage
|
|
||||||
# FROM node:22-alpine AS base
|
|
||||||
|
|
||||||
# RUN npm install -g corepack@latest
|
|
||||||
# RUN corepack enable && corepack prepare pnpm@9 --activate
|
|
||||||
|
|
||||||
# # Install tzdata to support timezone settings
|
|
||||||
# RUN apk add --no-cache tzdata
|
|
||||||
|
|
||||||
# # Set the timezone to Asia/Tehran
|
|
||||||
# RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
|
|
||||||
|
|
||||||
|
|
||||||
# FROM base AS deps
|
|
||||||
# WORKDIR /temp-deps
|
|
||||||
# COPY package*.json pnpm-lock.yaml ./
|
|
||||||
# RUN pnpm install --frozen-lockfile --loglevel info
|
|
||||||
|
|
||||||
|
|
||||||
# FROM base AS builder
|
|
||||||
# WORKDIR /build
|
|
||||||
# COPY . ./
|
|
||||||
# COPY --from=deps /temp-deps/node_modules ./node_modules
|
|
||||||
# RUN if [ -f package.json ] && grep -q '"build":' package.json; then pnpm run build; fi
|
|
||||||
# RUN pnpm install --prod --frozen-lockfile --loglevel info
|
|
||||||
|
|
||||||
# FROM base AS runner
|
|
||||||
# RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
||||||
# WORKDIR /app
|
|
||||||
|
|
||||||
# COPY . ./
|
|
||||||
# COPY --from=builder --chown=appuser:appgroup /build/ ./
|
|
||||||
|
|
||||||
# RUN chown -R appuser:appgroup /app
|
|
||||||
|
|
||||||
# USER appuser
|
|
||||||
|
|
||||||
# ENV NODE_ENV=production
|
|
||||||
# EXPOSE 3000
|
|
||||||
|
|
||||||
# CMD ["npm", "start"]
|
|
||||||
Generated
+3704
-5231
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
"start:0": "nest start dist/main",
|
"start:0": "nest start dist/main",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "nest start --watch",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch",
|
||||||
"start": "node --max-old-space-size=2048 dist/main",
|
"start": "node --max-old-space-size=2048 dist/src/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
|
|||||||
@@ -16,14 +16,17 @@ import { BusinessModule } from '../business/business.module';
|
|||||||
UtilsModule,
|
UtilsModule,
|
||||||
JwtModule.registerAsync({
|
JwtModule.registerAsync({
|
||||||
useFactory: (configService: ConfigService) => {
|
useFactory: (configService: ConfigService) => {
|
||||||
const expiresIn = configService.getOrThrow<number>('JWT_EXPIRATION_TIME');
|
const expiresIn = parseInt(
|
||||||
|
String(configService.getOrThrow('JWT_EXPIRATION_TIME')),
|
||||||
|
10,
|
||||||
|
);
|
||||||
|
if (!Number.isFinite(expiresIn) || expiresIn <= 0) {
|
||||||
|
throw new Error('JWT_EXPIRATION_TIME must be a positive number of seconds');
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
global: true,
|
global: true,
|
||||||
secret: configService.getOrThrow<string>('JWT_SECRET'),
|
secret: configService.getOrThrow<string>('JWT_SECRET'),
|
||||||
signOptions: {
|
signOptions: { expiresIn },
|
||||||
// Use string format with time unit for explicit expiration (value should be in seconds)
|
|
||||||
expiresIn: `${expiresIn}s`,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ export class TokensService {
|
|||||||
businessId: string,
|
businessId: string,
|
||||||
em?: EntityManager,
|
em?: EntityManager,
|
||||||
) {
|
) {
|
||||||
const refreshExpire = this.configService.getOrThrow<number>('REFRESH_TOKEN_EXPIRE');
|
const refreshExpire = this.getEnvNumber('REFRESH_TOKEN_EXPIRE');
|
||||||
const accessExpire = this.configService.getOrThrow<number>('JWT_EXPIRATION_TIME');
|
const accessExpire = this.getEnvNumber('JWT_EXPIRATION_TIME');
|
||||||
|
|
||||||
const payload: IAdminTokenPayload = { adminId, businessId }
|
const payload: IAdminTokenPayload = { adminId, businessId }
|
||||||
|
|
||||||
@@ -41,10 +41,7 @@ export class TokensService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generateAccessToken(payload: IAdminTokenPayload, expiresIn: number) {
|
private generateAccessToken(payload: IAdminTokenPayload, expiresIn: number) {
|
||||||
// Ensure expiresIn is passed as a string with time unit for reliability
|
return this.jwtService.signAsync(payload, { expiresIn });
|
||||||
// JWT library accepts: number (seconds) or string with unit (e.g., "3600s", "1h")
|
|
||||||
// Using string format is more explicit and prevents unit confusion
|
|
||||||
return this.jwtService.signAsync(payload, { expiresIn: `${expiresIn}s` });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async storeRefreshToken(
|
async storeRefreshToken(
|
||||||
@@ -54,7 +51,7 @@ export class TokensService {
|
|||||||
em?: EntityManager,
|
em?: EntityManager,
|
||||||
) {
|
) {
|
||||||
const entityManager = em || this.em;
|
const entityManager = em || this.em;
|
||||||
const refreshExpire = this.configService.getOrThrow<number>('REFRESH_TOKEN_EXPIRE');
|
const refreshExpire = this.getEnvNumber('REFRESH_TOKEN_EXPIRE');
|
||||||
const expiresAt = dayjs().add(refreshExpire, 'day').toDate();
|
const expiresAt = dayjs().add(refreshExpire, 'day').toDate();
|
||||||
|
|
||||||
const hashedToken = this.hashToken(refreshToken);
|
const hashedToken = this.hashToken(refreshToken);
|
||||||
@@ -126,4 +123,13 @@ export class TokensService {
|
|||||||
private hashToken(token: string): string {
|
private hashToken(token: string): string {
|
||||||
return createHash('sha256').update(token).digest('hex');
|
return createHash('sha256').update(token).digest('hex');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Env vars are strings; parseInt tolerates stray text from Docker --env-file. */
|
||||||
|
private getEnvNumber(key: string): number {
|
||||||
|
const value = parseInt(String(this.configService.getOrThrow(key)), 10);
|
||||||
|
if (!Number.isFinite(value) || value <= 0) {
|
||||||
|
throw new Error(`${key} must be a positive number`);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class CatalogueController {
|
|||||||
|
|
||||||
// ============= Public Routes ==============
|
// ============= Public Routes ==============
|
||||||
|
|
||||||
@Get('public/catalogue/slug/:slug')
|
@Get('public/catalogue/business/slug/:slug')
|
||||||
findAllAsPublic(@Param('slug') slug: string, @Query() queryDto: FindCataloguesDto) {
|
findAllAsPublic(@Param('slug') slug: string, @Query() queryDto: FindCataloguesDto) {
|
||||||
return this.catalogueService.findAll(slug, queryDto);
|
return this.catalogueService.findAll(slug, queryDto);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user