fix some bug
This commit is contained in:
@@ -5,6 +5,8 @@ WORKDIR /app
|
|||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV TZ=Asia/Tehran
|
ENV TZ=Asia/Tehran
|
||||||
|
ENV PORT=9292
|
||||||
|
ENV GLOBAL_PREFIX=server/api
|
||||||
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
|
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
|
||||||
|
|
||||||
COPY runtime ./runtime
|
COPY runtime ./runtime
|
||||||
|
|||||||
+3
-1
@@ -5,6 +5,8 @@ WORKDIR /app
|
|||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV TZ=Asia/Tehran
|
ENV TZ=Asia/Tehran
|
||||||
|
ENV PORT=9292
|
||||||
|
ENV GLOBAL_PREFIX=server/api
|
||||||
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
|
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
|
||||||
|
|
||||||
COPY runtime ./runtime
|
COPY runtime ./runtime
|
||||||
@@ -13,5 +15,5 @@ RUN chmod +x /app/docker-entrypoint.sh \
|
|||||||
&& test -f /app/runtime/server.cjs \
|
&& test -f /app/runtime/server.cjs \
|
||||||
&& test -f /app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
|
&& test -f /app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 9292
|
||||||
ENTRYPOINT ["./docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|
||||||
|
|||||||
+11
-3
@@ -18,9 +18,9 @@ import * as bcrypt from 'bcryptjs';
|
|||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const existingAdmins = await prisma.adminUser.count();
|
const existingOrders = await prisma.order.count();
|
||||||
if (existingAdmins > 0 && process.env.RUN_SEED !== 'force') {
|
if (existingOrders > 0 && process.env.RUN_SEED !== 'force') {
|
||||||
console.log('Seed skipped; admin users already exist');
|
console.log('Seed skipped; data already exists');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,6 +479,8 @@ async function main() {
|
|||||||
color: 'آبی',
|
color: 'آبی',
|
||||||
requestedMeterage: 2000,
|
requestedMeterage: 2000,
|
||||||
confirmedMeterage: 2000,
|
confirmedMeterage: 2000,
|
||||||
|
companyId: 'company-par',
|
||||||
|
companyName: 'شرکت پَر',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'oi-2',
|
id: 'oi-2',
|
||||||
@@ -489,6 +491,8 @@ async function main() {
|
|||||||
color: 'مشکی',
|
color: 'مشکی',
|
||||||
requestedMeterage: 1500,
|
requestedMeterage: 1500,
|
||||||
confirmedMeterage: 1000,
|
confirmedMeterage: 1000,
|
||||||
|
companyId: 'company-par',
|
||||||
|
companyName: 'شرکت پَر',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'oi-3',
|
id: 'oi-3',
|
||||||
@@ -499,6 +503,8 @@ async function main() {
|
|||||||
color: 'آبی پشت سفید',
|
color: 'آبی پشت سفید',
|
||||||
requestedMeterage: 750,
|
requestedMeterage: 750,
|
||||||
confirmedMeterage: 750,
|
confirmedMeterage: 750,
|
||||||
|
companyId: 'company-par',
|
||||||
|
companyName: 'شرکت پَر',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -570,6 +576,8 @@ async function main() {
|
|||||||
confirmedMeterage: 3200,
|
confirmedMeterage: 3200,
|
||||||
unitPrice: 250000,
|
unitPrice: 250000,
|
||||||
lineTotal: 800_000_000,
|
lineTotal: 800_000_000,
|
||||||
|
companyId: 'company-fam-baft',
|
||||||
|
companyName: 'فامبافت',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
+15
-7
@@ -8674,9 +8674,9 @@ __name(_hash, "_hash");
|
|||||||
// prisma/seed.ts
|
// prisma/seed.ts
|
||||||
var prisma = new import_client.PrismaClient();
|
var prisma = new import_client.PrismaClient();
|
||||||
async function main() {
|
async function main() {
|
||||||
const existingAdmins = await prisma.adminUser.count();
|
const existingOrders = await prisma.order.count();
|
||||||
if (existingAdmins > 0 && process.env.RUN_SEED !== "force") {
|
if (existingOrders > 0 && process.env.RUN_SEED !== "force") {
|
||||||
console.log("Seed skipped; admin users already exist");
|
console.log("Seed skipped; data already exists");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("Seeding fabric_trade database...");
|
console.log("Seeding fabric_trade database...");
|
||||||
@@ -9123,7 +9123,9 @@ async function main() {
|
|||||||
productCode: "377-BL",
|
productCode: "377-BL",
|
||||||
color: "\u0622\u0628\u06CC",
|
color: "\u0622\u0628\u06CC",
|
||||||
requestedMeterage: 2e3,
|
requestedMeterage: 2e3,
|
||||||
confirmedMeterage: 2e3
|
confirmedMeterage: 2e3,
|
||||||
|
companyId: "company-par",
|
||||||
|
companyName: "\u0634\u0631\u06A9\u062A \u067E\u064E\u0631"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "oi-2",
|
id: "oi-2",
|
||||||
@@ -9133,7 +9135,9 @@ async function main() {
|
|||||||
productCode: "377-BK",
|
productCode: "377-BK",
|
||||||
color: "\u0645\u0634\u06A9\u06CC",
|
color: "\u0645\u0634\u06A9\u06CC",
|
||||||
requestedMeterage: 1500,
|
requestedMeterage: 1500,
|
||||||
confirmedMeterage: 1e3
|
confirmedMeterage: 1e3,
|
||||||
|
companyId: "company-par",
|
||||||
|
companyName: "\u0634\u0631\u06A9\u062A \u067E\u064E\u0631"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "oi-3",
|
id: "oi-3",
|
||||||
@@ -9143,7 +9147,9 @@ async function main() {
|
|||||||
productCode: "378-BLW",
|
productCode: "378-BLW",
|
||||||
color: "\u0622\u0628\u06CC \u067E\u0634\u062A \u0633\u0641\u06CC\u062F",
|
color: "\u0622\u0628\u06CC \u067E\u0634\u062A \u0633\u0641\u06CC\u062F",
|
||||||
requestedMeterage: 750,
|
requestedMeterage: 750,
|
||||||
confirmedMeterage: 750
|
confirmedMeterage: 750,
|
||||||
|
companyId: "company-par",
|
||||||
|
companyName: "\u0634\u0631\u06A9\u062A \u067E\u064E\u0631"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -9213,7 +9219,9 @@ async function main() {
|
|||||||
requestedMeterage: 3200,
|
requestedMeterage: 3200,
|
||||||
confirmedMeterage: 3200,
|
confirmedMeterage: 3200,
|
||||||
unitPrice: 25e4,
|
unitPrice: 25e4,
|
||||||
lineTotal: 8e8
|
lineTotal: 8e8,
|
||||||
|
companyId: "company-fam-baft",
|
||||||
|
companyName: "\u0641\u0627\u0645\u200C\u0628\u0627\u0641\u062A"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
+14
-7
@@ -140206,18 +140206,23 @@ var require_run_seed = __commonJS({
|
|||||||
console.log("No runtime/seed.cjs; skipping seed");
|
console.log("No runtime/seed.cjs; skipping seed");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
const child = (0, node_child_process_1.spawn)(process.execPath, [seedFile], {
|
const child = (0, node_child_process_1.spawn)(process.execPath, [seedFile], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
env: process.env
|
env: process.env
|
||||||
});
|
});
|
||||||
child.on("exit", (code) => {
|
child.on("exit", (code) => {
|
||||||
if (code === 0)
|
if (code === 0) {
|
||||||
resolve();
|
resolve();
|
||||||
else
|
return;
|
||||||
reject(new Error(`seed exited ${code}`));
|
}
|
||||||
|
console.error(`Seed failed (${code}); API will still start`);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
child.on("error", (err) => {
|
||||||
|
console.error("Seed error; API will still start", err);
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
child.on("error", reject);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
__name(runBundledSeed, "runBundledSeed");
|
__name(runBundledSeed, "runBundledSeed");
|
||||||
@@ -140236,13 +140241,15 @@ var run_seed_1 = require_run_seed();
|
|||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
await (0, apply_migrations_1.applyPendingMigrations)();
|
await (0, apply_migrations_1.applyPendingMigrations)();
|
||||||
await (0, run_seed_1.runBundledSeed)();
|
if (process.env.RUN_SEED === "true" || process.env.RUN_SEED === "force") {
|
||||||
|
await (0, run_seed_1.runBundledSeed)();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
||||||
const bodyLimit = process.env.BODY_LIMIT || "25mb";
|
const bodyLimit = process.env.BODY_LIMIT || "25mb";
|
||||||
app.use((0, express_1.json)({ limit: bodyLimit }));
|
app.use((0, express_1.json)({ limit: bodyLimit }));
|
||||||
app.use((0, express_1.urlencoded)({ extended: true, limit: bodyLimit }));
|
app.use((0, express_1.urlencoded)({ extended: true, limit: bodyLimit }));
|
||||||
const globalPrefix = process.env.GLOBAL_PREFIX || "api";
|
const globalPrefix = process.env.GLOBAL_PREFIX || "server/api";
|
||||||
app.setGlobalPrefix(globalPrefix);
|
app.setGlobalPrefix(globalPrefix);
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: true,
|
origin: true,
|
||||||
|
|||||||
+4
-2
@@ -9,7 +9,9 @@ import { runBundledSeed } from './run-seed';
|
|||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
await applyPendingMigrations();
|
await applyPendingMigrations();
|
||||||
await runBundledSeed();
|
if (process.env.RUN_SEED === 'true' || process.env.RUN_SEED === 'force') {
|
||||||
|
await runBundledSeed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
@@ -20,7 +22,7 @@ async function bootstrap() {
|
|||||||
app.use(urlencoded({ extended: true, limit: bodyLimit }));
|
app.use(urlencoded({ extended: true, limit: bodyLimit }));
|
||||||
|
|
||||||
// پشت LiteSpeed روی /server → GLOBAL_PREFIX=server/api
|
// پشت LiteSpeed روی /server → GLOBAL_PREFIX=server/api
|
||||||
const globalPrefix = process.env.GLOBAL_PREFIX || 'api';
|
const globalPrefix = process.env.GLOBAL_PREFIX || 'server/api';
|
||||||
app.setGlobalPrefix(globalPrefix);
|
app.setGlobalPrefix(globalPrefix);
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: true,
|
origin: true,
|
||||||
|
|||||||
+11
-4
@@ -9,15 +9,22 @@ export function runBundledSeed(): Promise<void> {
|
|||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
const child = spawn(process.execPath, [seedFile], {
|
const child = spawn(process.execPath, [seedFile], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
env: process.env,
|
env: process.env,
|
||||||
})
|
})
|
||||||
child.on('exit', (code) => {
|
child.on('exit', (code) => {
|
||||||
if (code === 0) resolve()
|
if (code === 0) {
|
||||||
else reject(new Error(`seed exited ${code}`))
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.error(`Seed failed (${code}); API will still start`)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
child.on('error', (err) => {
|
||||||
|
console.error('Seed error; API will still start', err)
|
||||||
|
resolve()
|
||||||
})
|
})
|
||||||
child.on('error', reject)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user