Migrated to NodeJS/Vite/Express/Material UI 2 #1
@@ -2,12 +2,12 @@ FROM node:24-trixie-slim AS build
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY app-new/backend/package*.json backend/
|
COPY backend/package*.json backend/
|
||||||
COPY app-new/frontend/package*.json frontend/
|
COPY frontend/package*.json frontend/
|
||||||
RUN cd backend && npm ci
|
RUN cd backend && npm ci
|
||||||
RUN cd frontend && npm ci
|
RUN cd frontend && npm ci
|
||||||
|
|
||||||
COPY app-new .
|
COPY . .
|
||||||
|
|
||||||
RUN cd backend && npm run build
|
RUN cd backend && npm run build
|
||||||
RUN cd frontend && npm run build
|
RUN cd frontend && npm run build
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { z } from "zod";
|
|||||||
import { AzureImageService } from "./azure-service";
|
import { AzureImageService } from "./azure-service";
|
||||||
import { TemplateService } from "./template-service";
|
import { TemplateService } from "./template-service";
|
||||||
|
|
||||||
const findAppNewRoot = (): string => {
|
const findAppRoot = (): string => {
|
||||||
const candidates = [join(__dirname, "../../.."), join(__dirname, "../..")];
|
const candidates = [join(__dirname, "../../.."), join(__dirname, "../..")];
|
||||||
|
|
||||||
for (const candidate of candidates) {
|
for (const candidate of candidates) {
|
||||||
@@ -15,7 +15,7 @@ const findAppNewRoot = (): string => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("Unable to resolve app-new root");
|
throw new Error("Unable to resolve app root");
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryLocation = z.object({ location: z.string().min(1) });
|
const queryLocation = z.object({ location: z.string().min(1) });
|
||||||
@@ -143,7 +143,7 @@ const makeApp = () => {
|
|||||||
res.status(500).json({ message });
|
res.status(500).json({ message });
|
||||||
});
|
});
|
||||||
|
|
||||||
const frontendRoot = join(findAppNewRoot(), "dist/frontend");
|
const frontendRoot = join(findAppRoot(), "dist/frontend");
|
||||||
if (existsSync(frontendRoot)) {
|
if (existsSync(frontendRoot)) {
|
||||||
app.use(express.static(frontendRoot));
|
app.use(express.static(frontendRoot));
|
||||||
app.get(/^(?!\/api).*/, (_req, res) => {
|
app.get(/^(?!\/api).*/, (_req, res) => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { join } from "node:path";
|
|||||||
import nunjucks from "nunjucks";
|
import nunjucks from "nunjucks";
|
||||||
import type { ImageSelection, UsageTemplate } from "./types";
|
import type { ImageSelection, UsageTemplate } from "./types";
|
||||||
|
|
||||||
const findAppNewRoot = (): string => {
|
const findAppRoot = (): string => {
|
||||||
const candidates = [join(__dirname, "../../.."), join(__dirname, "../..")];
|
const candidates = [join(__dirname, "../../.."), join(__dirname, "../..")];
|
||||||
|
|
||||||
for (const candidate of candidates) {
|
for (const candidate of candidates) {
|
||||||
@@ -12,19 +12,19 @@ const findAppNewRoot = (): string => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("Unable to resolve app-new template root");
|
throw new Error("Unable to resolve app template root");
|
||||||
};
|
};
|
||||||
|
|
||||||
export class TemplateService {
|
export class TemplateService {
|
||||||
private readonly appNewRoot = findAppNewRoot();
|
private readonly appRoot = findAppRoot();
|
||||||
|
|
||||||
private readonly env = nunjucks.configure(join(this.appNewRoot, "templates"), {
|
private readonly env = nunjucks.configure(join(this.appRoot, "templates"), {
|
||||||
autoescape: false,
|
autoescape: false,
|
||||||
noCache: true
|
noCache: true
|
||||||
});
|
});
|
||||||
|
|
||||||
private readonly templates: UsageTemplate[] = JSON.parse(
|
private readonly templates: UsageTemplate[] = JSON.parse(
|
||||||
readFileSync(join(this.appNewRoot, "templates.json"), "utf8")
|
readFileSync(join(this.appRoot, "templates.json"), "utf8")
|
||||||
) as UsageTemplate[];
|
) as UsageTemplate[];
|
||||||
|
|
||||||
public getTemplates(): UsageTemplate[] {
|
public getTemplates(): UsageTemplate[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user