fix
This commit is contained in:
parent
5bbd20176f
commit
5c70e2f3d7
|
|
@ -178,5 +178,5 @@ dist
|
|||
app/web/.parcel-cache
|
||||
app/static
|
||||
app/static/*
|
||||
.data
|
||||
.data/*
|
||||
data
|
||||
data/*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"schemaVersion": 2,
|
||||
"dockerfileLines": [
|
||||
"FROM node:lts-alpine",
|
||||
"RUN mkdir -p /usr/src/app",
|
||||
"WORKDIR /usr/src/app",
|
||||
"COPY ./ /usr/src/app/",
|
||||
"RUN curl -fsSL https://bun.sh/install | bash"
|
||||
"RUN bun i",
|
||||
"ENV PORT 4550",
|
||||
"EXPOSE 4550",
|
||||
"CMD [ \"bun\", \"prod\" ]"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { g } from "utils/global";
|
||||
import { apiContext } from "../server/api-ctx";
|
||||
import { dir } from "../utils/dir";
|
||||
|
||||
|
|
@ -6,7 +7,7 @@ export const _ = {
|
|||
async api() {
|
||||
const { req } = apiContext(this);
|
||||
const rpath = decodeURIComponent(req.params._);
|
||||
const path = dir.path(`../data/upload/${rpath}`);
|
||||
const path = dir.path(`${g.datadir}/upload/${rpath}`);
|
||||
|
||||
try {
|
||||
return new Response(Bun.file(path) as any);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import mp from "@surfy/multipart-parser";
|
||||
|
||||
import { writeAsync } from "fs-jetpack";
|
||||
import { g } from "utils/global";
|
||||
import { apiContext } from "../server/api-ctx";
|
||||
import { dir } from "../utils/dir";
|
||||
export const _ = {
|
||||
|
|
@ -21,7 +23,7 @@ export const _ = {
|
|||
.toLowerCase()}`;
|
||||
|
||||
url = `/_file/${path}`;
|
||||
await writeAsync(dir.path(`../data/upload/${path}`), part.buffer);
|
||||
await writeAsync(dir.path(`${g.datadir}/upload/${path}`), part.buffer);
|
||||
}
|
||||
|
||||
return url;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
import { startDevWatcher } from "./utils/dev-watcher";
|
||||
import { ensureNotRunning } from "./utils/ensure";
|
||||
import { preparePrisma } from "./utils/prisma";
|
||||
import { parcelBuild } from "utils/parcel";
|
||||
import { generateAPIFrm } from "./server/api-frm";
|
||||
import { prepareApiRoutes } from "./server/api-scan";
|
||||
import { createServer } from "./server/create";
|
||||
import { prepareAPITypes } from "./server/prep-api-ts";
|
||||
import { config } from "./utils/config";
|
||||
import { startDevWatcher } from "./utils/dev-watcher";
|
||||
import { ensureNotRunning } from "./utils/ensure";
|
||||
import { g } from "./utils/global";
|
||||
import { createLogger } from "./utils/logger";
|
||||
import { parcelBuild } from "utils/parcel";
|
||||
import { prepareApiRoutes } from "./server/api-scan";
|
||||
import { preparePrisma } from "./utils/prisma";
|
||||
|
||||
g.status = "init";
|
||||
|
||||
await createLogger();
|
||||
g.api = {};
|
||||
g.datadir = g.mode === "dev" ? ".data" : "../data";
|
||||
g.datadir = "data";
|
||||
g.port = parseInt(process.env.PORT || "4550");
|
||||
g.mode = process.argv.includes("dev") ? "dev" : "prod";
|
||||
g.log.info(g.mode === "dev" ? "DEVELOPMENT" : "PRODUCTION");
|
||||
|
|
@ -24,7 +23,6 @@ if (g.mode === "dev") {
|
|||
|
||||
await preparePrisma();
|
||||
await ensureNotRunning();
|
||||
await config.init();
|
||||
|
||||
if (g.db) {
|
||||
g.db.$connect().catch((e: any) => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
declare module "@surfy/multipart-parser";
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import { dirAsync, readAsync } from "fs-jetpack";
|
||||
import { dir } from "./dir";
|
||||
|
||||
const _internal = { config: {} as any, writeTimeout: null as any };
|
||||
|
||||
export const config = {
|
||||
init: async () => {
|
||||
await dirAsync(dir.path("../data/config"));
|
||||
await dirAsync(dir.path("../data/files"));
|
||||
|
||||
_internal.config =
|
||||
(await readAsync(dir.path("../data/config/conf.json"), "json")) || {};
|
||||
},
|
||||
get all() {
|
||||
return _internal.config;
|
||||
},
|
||||
get(key: string) {
|
||||
if (key.endsWith("url")) {
|
||||
if (!(_internal.config[key] instanceof URL)) {
|
||||
_internal.config[key] = new URL(_internal.config[key] || "");
|
||||
}
|
||||
}
|
||||
|
||||
return _internal.config[key];
|
||||
},
|
||||
set(key: string, value: any) {
|
||||
_internal.config[key] = value;
|
||||
clearTimeout(_internal.writeTimeout);
|
||||
_internal.writeTimeout = setTimeout(() => {
|
||||
Bun.write(dir.path("../data/config/conf.json"), _internal.config);
|
||||
}, 100);
|
||||
},
|
||||
};
|
||||
|
|
@ -3,5 +3,3 @@ import { PrismaClient } from "./app/db/db";
|
|||
declare global {
|
||||
const db: PrismaClient;
|
||||
}
|
||||
|
||||
declare module "@surfy/multipart-parser";
|
||||
|
|
|
|||
Loading…
Reference in New Issue