Fixes to NodeJS version.
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import cors from "cors";
|
||||
import "dotenv/config";
|
||||
import express from "express";
|
||||
import { z } from "zod";
|
||||
import { AzureImageService } from "./azure-service";
|
||||
import { TemplateService } from "./template-service";
|
||||
|
||||
const findAppNewRoot = (): string => {
|
||||
const candidates = [join(__dirname, "../../.."), join(__dirname, "../..")];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (existsSync(join(candidate, "templates.json"))) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("Unable to resolve app-new root");
|
||||
};
|
||||
|
||||
const queryLocation = z.object({ location: z.string().min(1) });
|
||||
const queryOffer = z.object({ location: z.string().min(1), publisher: z.string().min(1) });
|
||||
const querySku = z.object({ location: z.string().min(1), publisher: z.string().min(1), offer: z.string().min(1) });
|
||||
@@ -127,7 +138,7 @@ const makeApp = () => {
|
||||
res.status(500).json({ message });
|
||||
});
|
||||
|
||||
const frontendRoot = join(process.cwd(), "dist/frontend");
|
||||
const frontendRoot = join(findAppNewRoot(), "dist/frontend");
|
||||
if (existsSync(frontendRoot)) {
|
||||
app.use(express.static(frontendRoot));
|
||||
app.get(/^(?!\/api).*/, (_req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user