Skip to content

Commit 46fef9e

Browse files
committed
fix: data object structure
1 parent d7d010f commit 46fef9e

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

src/index.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,28 @@ class CoCreateFileSystem {
2727

2828
async send(req, res, crud, organization, valideUrl) {
2929
try {
30+
const hostname = valideUrl.hostname;
31+
32+
let data = {
33+
method: 'object.read',
34+
host: hostname,
35+
array: 'files',
36+
$filter: {
37+
query: {
38+
host: { $in: [hostname, '*'] },
39+
$or: []
40+
},
41+
limit: 1
42+
}
43+
}
44+
3045
if (!organization || organization.error) {
3146
let hostNotFound = await getDefaultFile('/hostNotFound.html')
3247
return sendResponse(hostNotFound.object[0].src, 404, { 'Content-Type': 'text/html' })
3348
}
3449

3550
const organization_id = organization._id
36-
const hostname = valideUrl.hostname;
51+
data.organization_id = organization_id
3752

3853
res.setHeader('organization', organization_id)
3954
res.setHeader('storage', !!organization.storage);
@@ -74,19 +89,20 @@ class CoCreateFileSystem {
7489
pathname += "/index.html";
7590
}
7691

77-
let data = {
78-
method: 'object.read',
79-
host: hostname,
80-
array: 'files',
81-
$filter: {
82-
query: {
83-
host: { $in: [hostname, '*'] },
84-
$or: [{ pathname }, { pathname: wildcard }]
85-
},
86-
limit: 1
87-
},
88-
organization_id
89-
}
92+
// let data = {
93+
// method: 'object.read',
94+
// host: hostname,
95+
// array: 'files',
96+
// $filter: {
97+
// query: {
98+
// host: { $in: [hostname, '*'] },
99+
// $or: [{ pathname }, { pathname: wildcard }]
100+
// },
101+
// limit: 1
102+
// },
103+
// organization_id
104+
// }
105+
data.$filter.query.$or = [{ pathname }, { pathname: wildcard }]
90106

91107
let file
92108
if (pathname.startsWith('/dist') || pathname.startsWith('/admin') || ['/403.html', '/404.html', '/offline.html', '/manifest.webmanifest', '/service-worker.js'].includes(pathname))
@@ -173,7 +189,7 @@ class CoCreateFileSystem {
173189
}
174190

175191
async function getDefaultFile(fileName) {
176-
data.$filter.query.$or[0].pathname = fileName
192+
data.$filter.query.$or[0] = { pathname: fileName }
177193
let defaultFile
178194
if (fileName !== '/hostNotFound.html')
179195
defaultFile = await crud.send(data);

0 commit comments

Comments
 (0)