Skip to content

Commit 66675bc

Browse files
Copilothotlong
andcommitted
Fix race condition and URL construction issues
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 2213295 commit 66675bc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/runtime/server/src/adapters/node.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export function createNodeHandler(app: IObjectQL, options?: NodeHandlerOptions)
2525
const routes = resolveApiRoutes(options?.routes);
2626

2727
// Initialize file storage
28+
const filesPath = routes.files.startsWith('/') ? routes.files : `/${routes.files}`;
29+
const defaultBaseUrl = process.env.OBJECTQL_BASE_URL || `http://localhost:3000${filesPath}`;
2830
const fileStorage = options?.fileStorage || new LocalFileStorage({
2931
baseDir: process.env.OBJECTQL_UPLOAD_DIR || './uploads',
30-
baseUrl: process.env.OBJECTQL_BASE_URL || `http://localhost:3000${routes.files}`
32+
baseUrl: defaultBaseUrl
3133
});
3234

3335
// Create file handlers

packages/runtime/server/test/custom-routes.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ class MockDriver implements Driver {
6666
}
6767

6868
async createMany(objectName: string, data: any[]) {
69-
return Promise.all(data.map(item => this.create(objectName, item)));
69+
const results = [];
70+
for (const item of data) {
71+
results.push(await this.create(objectName, item));
72+
}
73+
return results;
7074
}
7175

7276
async updateMany(objectName: string, filters: any, data: any) {

0 commit comments

Comments
 (0)