feat(frontend): migrated old > new silo adjustments
moved the apps around so we can use 1 url for cors bs
This commit is contained in:
28
app/main.ts
28
app/main.ts
@@ -4,6 +4,7 @@ import { toNodeHandler } from "better-auth/node";
|
||||
import cors from "cors";
|
||||
import express from "express";
|
||||
import { createServer } from "http";
|
||||
import { createProxyMiddleware, fixRequestBody } from "http-proxy-middleware";
|
||||
import morgan from "morgan";
|
||||
import os from "os";
|
||||
import { dirname, join } from "path";
|
||||
@@ -81,6 +82,24 @@ const main = async () => {
|
||||
);
|
||||
}
|
||||
|
||||
// old app prox temp stuff
|
||||
app.use(
|
||||
basePath + "/old",
|
||||
createProxyMiddleware({
|
||||
target: `http://localhost:3000`,
|
||||
changeOrigin: true,
|
||||
pathRewrite: (path, req) => {
|
||||
// Remove the basePath + '/old' prefix from the path dynamically
|
||||
return path.replace(`${basePath}/old`, "");
|
||||
},
|
||||
|
||||
headers: {
|
||||
// forward auth headers if needed
|
||||
"X-Forwarded-By": "express-proxy",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
// global middleware
|
||||
app.set("trust proxy", true);
|
||||
app.use(apiHitMiddleware);
|
||||
@@ -93,6 +112,8 @@ const main = async () => {
|
||||
/^https?:\/\/.*\.alpla\.net$/,
|
||||
"http://localhost:4173",
|
||||
"http://localhost:4200",
|
||||
"http://localhost:3000",
|
||||
"http://localhost:4000",
|
||||
env.BETTER_AUTH_URL, // prod
|
||||
];
|
||||
|
||||
@@ -124,7 +145,12 @@ const main = async () => {
|
||||
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
||||
credentials: true,
|
||||
exposedHeaders: ["set-cookie"],
|
||||
allowedHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
|
||||
allowedHeaders: [
|
||||
"Content-Type",
|
||||
"Authorization",
|
||||
"X-Requested-With",
|
||||
"XMLHttpRequest",
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* When we pass over the edi data we want to now store it so we can see the day to day
|
||||
* id
|
||||
* itemNumber // customer code
|
||||
* date requested
|
||||
* qty requested
|
||||
* av - what av this is linked to
|
||||
* add_date
|
||||
*/
|
||||
|
||||
type IncomingForecastData = {
|
||||
CustomerArticleNumber: number;
|
||||
};
|
||||
|
||||
export const forecastData = async (data: IncomingForecastData) => {};
|
||||
@@ -12,5 +12,19 @@
|
||||
"description": "What is the db server",
|
||||
"moduleName": "system",
|
||||
"roles": ["systemAdmin"]
|
||||
},
|
||||
{
|
||||
"name": "v1Server",
|
||||
"value": "localhost",
|
||||
"description": "What is the port the v1app is on",
|
||||
"moduleName": "system",
|
||||
"roles": ["systemAdmin"]
|
||||
},
|
||||
{
|
||||
"name": "v1Port",
|
||||
"value": "3000",
|
||||
"description": "What is the port the v1app is on",
|
||||
"moduleName": "system",
|
||||
"roles": ["systemAdmin"]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
import { Router } from "express";
|
||||
import { and, asc, eq } from "drizzle-orm";
|
||||
import type { Request, Response } from "express";
|
||||
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
||||
import { Router } from "express";
|
||||
import { db } from "../../../../pkg/db/db.js";
|
||||
import { serverData } from "../../../../pkg/db/schema/servers.js";
|
||||
import { and, asc, eq } from "drizzle-orm";
|
||||
import { settings } from "../../../../pkg/db/schema/settings.js";
|
||||
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
const token = req.query.token;
|
||||
const token = req.query.token;
|
||||
|
||||
const conditions = [];
|
||||
const conditions = [];
|
||||
|
||||
if (token !== undefined) {
|
||||
conditions.push(eq(serverData.plantToken, `${token}`));
|
||||
}
|
||||
if (token !== undefined) {
|
||||
conditions.push(eq(serverData.plantToken, `${token}`));
|
||||
}
|
||||
|
||||
conditions.push(eq(serverData.active, true));
|
||||
conditions.push(eq(serverData.active, true));
|
||||
|
||||
const { data, error } = await tryCatch(
|
||||
db
|
||||
.select()
|
||||
.from(serverData)
|
||||
.where(and(...conditions))
|
||||
.orderBy(asc(serverData.name))
|
||||
);
|
||||
const { data, error } = await tryCatch(
|
||||
db
|
||||
.select()
|
||||
.from(settings)
|
||||
//.where(and(...conditions))
|
||||
.orderBy(asc(settings.name)),
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error });
|
||||
}
|
||||
res.status(200).json({ message: "Current Active server", data: data });
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error });
|
||||
}
|
||||
res.status(200).json({ message: "Current Active server", data: data });
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
29
app/src/pkg/db/schema/forecastEDIData.ts
Normal file
29
app/src/pkg/db/schema/forecastEDIData.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
boolean,
|
||||
integer,
|
||||
jsonb,
|
||||
pgTable,
|
||||
real,
|
||||
text,
|
||||
timestamp,
|
||||
uuid,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const forecastData = pgTable("forecast_Data", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
customerArticleNumber: text("customer_article_number"),
|
||||
dateRequested: timestamp("date_requested").defaultNow(),
|
||||
quantity: real("quantity"),
|
||||
requestDate: timestamp("request_date").notNull(),
|
||||
article: integer("article"),
|
||||
customerID: integer("customer_id").notNull(),
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
});
|
||||
|
||||
export const forecastDataSchema = createSelectSchema(forecastData);
|
||||
export const newForecastDataSchema = createInsertSchema(forecastData);
|
||||
|
||||
export type ForecastData = z.infer<typeof forecastDataSchema>;
|
||||
export type NewForecastData = z.infer<typeof newForecastDataSchema>;
|
||||
Reference in New Issue
Block a user