Skip to content

Commit 7964778

Browse files
committed
feat: routing logic per host
1 parent 12c5edd commit 7964778

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/index.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class CoCreateFileSystem {
8080
array: 'files',
8181
$filter: {
8282
query: [
83-
{ key: "host", value: [hostname, '*'], operator: "$in" },
83+
{ key: "host", value: [hostname, '*'], operator: "$elemMatch" },
84+
// { key: "host", value: [hostname, '*'], operator: "$in" },
8485
{ key: "pathname", value: pathname, operator: "$eq" },
8586
// { key: "pathname", value: wildcard, operator: "$eq", logicalOperator: "or" }
8687
],
@@ -89,16 +90,18 @@ class CoCreateFileSystem {
8990
organization_id
9091
}
9192

92-
if (organization.fileSystem) {
93-
let fileSystem = organization.fileSystem.find(element => element.name === hostname)
94-
for (let i = 0; i < fileSystem; i++) {
95-
if (fileSystem[i].name === hostname) {
96-
if (fileSystem[i].storage)
97-
data.storage = fileSystem[i].storage
98-
if (fileSystem[i].database)
99-
data.database = fileSystem[i].database
100-
if (fileSystem[i].array)
101-
data.array = fileSystem[i].array
93+
if (organization.host) {
94+
let host = organization.host
95+
for (let i = 0; i < host; i++) {
96+
if (host[i].name === hostname) {
97+
if (host[i].storage)
98+
data.storage = host[i].storage
99+
if (host[i].database)
100+
data.database = host[i].database
101+
if (host[i].array)
102+
data.array = host[i].array
103+
if (host[i].files)
104+
data = { ...data, ...host[i].files }
102105
break
103106
}
104107
}

0 commit comments

Comments
 (0)