@joystick.js/node-canary 0.0.0-canary.76 → 0.0.0-canary.78
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.
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const createIndex = async (collectionName = "", index = {}) => {
|
|
2
|
+
return process.databases._users?.collection(collectionName).createIndex(index);
|
|
3
|
+
};
|
|
4
|
+
var createAccountsIndexes_default = async () => {
|
|
5
|
+
await createIndex("users", { _id: 1 });
|
|
6
|
+
await createIndex("users", { emailAddress: 1 });
|
|
7
|
+
await createIndex("users", { username: 1 });
|
|
8
|
+
await createIndex("users", { "sessions.token": 1 });
|
|
9
|
+
await createIndex("users", { "passwordResetTokens.token": 1 });
|
|
10
|
+
await createIndex("users", { "passwordResetTokens.token": 1, _id: 1 });
|
|
11
|
+
await createIndex("users", { roles: 1 });
|
|
12
|
+
await createIndex("users", { roles: 1, _id: 1 });
|
|
13
|
+
await createIndex("roles", { role: 1 });
|
|
14
|
+
await createIndex("roles", { role: 1, userId: 1 });
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
createAccountsIndexes_default as default
|
|
18
|
+
};
|
package/dist/app/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import runUploader from "./runUploader";
|
|
|
25
25
|
import generateId from "../lib/generateId.js";
|
|
26
26
|
import getOutput from "./getOutput.js";
|
|
27
27
|
import defaultUserOutputFields from "./accounts/defaultUserOutputFields.js";
|
|
28
|
+
import createMongoDBAccountsIndexes from "./databases/mongodb/createAccountsIndexes";
|
|
28
29
|
import createPostgreSQLAccountsTables from "./databases/postgresql/createAccountsTables";
|
|
29
30
|
import createPostgreSQLAccountsIndexes from "./databases/postgresql/createAccountsIndexes";
|
|
30
31
|
import loadSettings from "../settings/load.js";
|
|
@@ -93,6 +94,9 @@ class App {
|
|
|
93
94
|
const hasQueuesDatabase = settings?.config?.databases?.some((database = {}) => {
|
|
94
95
|
return !!database?.queues;
|
|
95
96
|
});
|
|
97
|
+
const hasMongoDBUsersDatabase = settings?.config?.databases?.some((database = {}) => {
|
|
98
|
+
return database?.provider === "mongodb" && database?.users;
|
|
99
|
+
});
|
|
96
100
|
const hasPostgreSQLUsersDatabase = settings?.config?.databases?.some((database = {}) => {
|
|
97
101
|
return database?.provider === "postgresql" && database?.users;
|
|
98
102
|
});
|
|
@@ -139,6 +143,9 @@ class App {
|
|
|
139
143
|
if (hasQueuesDatabase) {
|
|
140
144
|
process.databases._queues = getTargetDatabaseConnection("queues")?.connection;
|
|
141
145
|
}
|
|
146
|
+
if (hasMongoDBUsersDatabase) {
|
|
147
|
+
await createMongoDBAccountsIndexes();
|
|
148
|
+
}
|
|
142
149
|
if (hasPostgreSQLUsersDatabase) {
|
|
143
150
|
await createPostgreSQLAccountsTables();
|
|
144
151
|
await createPostgreSQLAccountsIndexes();
|
|
@@ -192,7 +199,6 @@ class App {
|
|
|
192
199
|
if (existingUser) {
|
|
193
200
|
await runUserQuery("deleteUser", { userId: existingUser?._id || existingUser?.user_id });
|
|
194
201
|
}
|
|
195
|
-
await wait(0.5);
|
|
196
202
|
const signup = await accounts.signup({
|
|
197
203
|
emailAddress: req?.body?.emailAddress,
|
|
198
204
|
password: req?.body?.password,
|