@muhgholy/next-drive 4.16.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-PFIAZK57.js → chunk-N3C7IKRK.js} +27 -17
- package/dist/chunk-N3C7IKRK.js.map +1 -0
- package/dist/{chunk-HNLXZW5G.cjs → chunk-XIUFYDVE.cjs} +27 -17
- package/dist/chunk-XIUFYDVE.cjs.map +1 -0
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/express.cjs +11 -11
- package/dist/server/express.js +2 -2
- package/dist/server/index.cjs +13 -13
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HNLXZW5G.cjs.map +0 -1
- package/dist/chunk-PFIAZK57.js.map +0 -1
|
@@ -238,21 +238,30 @@ var runMigrations = async (storagePath) => {
|
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
// src/server/config.ts
|
|
241
|
-
var
|
|
242
|
-
var
|
|
243
|
-
|
|
241
|
+
var GLOBAL_KEY = "__nextDrive";
|
|
242
|
+
var getGlobal = () => {
|
|
243
|
+
if (!globalThis[GLOBAL_KEY]) {
|
|
244
|
+
globalThis[GLOBAL_KEY] = {
|
|
245
|
+
config: null,
|
|
246
|
+
migrationPromise: null,
|
|
247
|
+
initialized: false
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return globalThis[GLOBAL_KEY];
|
|
251
|
+
};
|
|
244
252
|
var driveConfiguration = async (config) => {
|
|
253
|
+
const g = getGlobal();
|
|
245
254
|
if (mongoose.connection.readyState !== 1) {
|
|
246
255
|
throw new Error("Database not connected. Please connect to Mongoose before initializing next-drive.");
|
|
247
256
|
}
|
|
248
|
-
if (
|
|
249
|
-
if (migrationPromise) await migrationPromise;
|
|
250
|
-
return
|
|
257
|
+
if (g.initialized && g.config) {
|
|
258
|
+
if (g.migrationPromise) await g.migrationPromise;
|
|
259
|
+
return g.config;
|
|
251
260
|
}
|
|
252
261
|
const resolvedPath = config.storage?.path || path.join(os3.tmpdir(), "next-drive-data");
|
|
253
262
|
const mode = config.mode || "NORMAL";
|
|
254
263
|
if (mode === "ROOT") {
|
|
255
|
-
|
|
264
|
+
g.config = {
|
|
256
265
|
...config,
|
|
257
266
|
mode: "ROOT",
|
|
258
267
|
storage: {
|
|
@@ -271,7 +280,7 @@ var driveConfiguration = async (config) => {
|
|
|
271
280
|
if (!config.information) {
|
|
272
281
|
throw new Error("information callback is required in NORMAL mode");
|
|
273
282
|
}
|
|
274
|
-
|
|
283
|
+
g.config = {
|
|
275
284
|
...config,
|
|
276
285
|
mode: "NORMAL",
|
|
277
286
|
storage: {
|
|
@@ -287,16 +296,17 @@ var driveConfiguration = async (config) => {
|
|
|
287
296
|
information: config.information
|
|
288
297
|
};
|
|
289
298
|
}
|
|
290
|
-
|
|
291
|
-
if (!migrationPromise) {
|
|
292
|
-
migrationPromise = runMigrations(resolvedPath);
|
|
299
|
+
g.initialized = true;
|
|
300
|
+
if (!g.migrationPromise) {
|
|
301
|
+
g.migrationPromise = runMigrations(resolvedPath);
|
|
293
302
|
}
|
|
294
|
-
await migrationPromise;
|
|
295
|
-
return
|
|
303
|
+
await g.migrationPromise;
|
|
304
|
+
return g.config;
|
|
296
305
|
};
|
|
297
306
|
var getDriveConfig = () => {
|
|
298
|
-
|
|
299
|
-
|
|
307
|
+
const g = getGlobal();
|
|
308
|
+
if (!g.config) throw new Error("Drive configuration not initialized");
|
|
309
|
+
return g.config;
|
|
300
310
|
};
|
|
301
311
|
var getDriveInformation = async (req) => {
|
|
302
312
|
const config = getDriveConfig();
|
|
@@ -2391,5 +2401,5 @@ var driveAPIHandler = async (req, res) => {
|
|
|
2391
2401
|
};
|
|
2392
2402
|
|
|
2393
2403
|
export { driveAPIHandler, driveConfiguration, driveDelete, driveFilePath, driveFileSchemaZod, driveGetUrl, driveInfo, driveList, driveReadFile, driveUpload, getDriveConfig, getDriveInformation };
|
|
2394
|
-
//# sourceMappingURL=chunk-
|
|
2395
|
-
//# sourceMappingURL=chunk-
|
|
2404
|
+
//# sourceMappingURL=chunk-N3C7IKRK.js.map
|
|
2405
|
+
//# sourceMappingURL=chunk-N3C7IKRK.js.map
|