@joystick.js/node-canary 0.0.0-canary.70 → 0.0.0-canary.72

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,7 @@
1
+ import runUserQuery from "./runUserQuery.js";
2
+ var deleteUser_default = (userId = "") => {
3
+ return runUserQuery("deleteUser", { userId });
4
+ };
5
+ export {
6
+ deleteUser_default as default
7
+ };
@@ -1,6 +1,7 @@
1
1
  import _setAuthenticationCookie from "./setAuthenticationCookie.js";
2
2
  import _unsetAuthenticationCookie from "./unsetAuthenticationCookie.js";
3
3
  import defaultUserOutputFields from "./defaultUserOutputFields";
4
+ import deleteUser from "./deleteUser.js";
4
5
  import getBrowserSafeUser from "./getBrowserSafeUser";
5
6
  import login from "./login";
6
7
  import recoverPassword from "./recoverPassword";
@@ -14,6 +15,7 @@ var accounts_default = {
14
15
  _setAuthenticationCookie,
15
16
  _unsetAuthenticationCookie,
16
17
  defaultUserOutputFields,
18
+ deleteUser,
17
19
  getBrowserSafeUser,
18
20
  login,
19
21
  recoverPassword,
@@ -37,6 +37,11 @@ var accounts_default = {
37
37
  }
38
38
  return null;
39
39
  },
40
+ deleteUser: async (input = {}) => {
41
+ return process.databases._users?.collection("users").deleteOne({
42
+ _id: input?.userId
43
+ });
44
+ },
40
45
  deleteOldSessions: async (input = {}) => {
41
46
  const user = await process.databases._users?.collection("users").findOne({
42
47
  _id: input?.userId
@@ -43,6 +43,9 @@ var accounts_default = {
43
43
  }
44
44
  return null;
45
45
  },
46
+ deleteUser: async (input = {}) => {
47
+ await process.databases._users?.query(`DELETE FROM users WHERE user_id = $1`, [input?.userId]);
48
+ },
46
49
  deleteOldSessions: async (input = {}) => {
47
50
  await process.databases._users?.query(`DELETE FROM users_sessions WHERE user_id = $1 AND token_expires_at::date < NOW()`, [input?.userId]);
48
51
  },
package/dist/app/index.js CHANGED
@@ -39,6 +39,7 @@ import getAPIForDataFunctions from "../ssr/getAPIForDataFunctions.js";
39
39
  import getBrowserSafeRequest from "./getBrowserSafeRequest.js";
40
40
  import getDataFromComponent from "../ssr/getDataFromComponent.js";
41
41
  import getTranslations from "./middleware/getTranslations.js";
42
+ import runUserQuery from "./accounts/runUserQuery.js";
42
43
  process.setMaxListeners(0);
43
44
  class App {
44
45
  constructor(options = {}) {
@@ -185,6 +186,10 @@ class App {
185
186
  }
186
187
  res.status(200).send({ data: {}, translations: {} });
187
188
  });
189
+ this.express.app.delete("/api/_test/accounts", async (req, res) => {
190
+ await runUserQuery("deleteUser", { userId: req?.body?.userId });
191
+ res.status(200).send({ data: {} });
192
+ });
188
193
  }
189
194
  }
190
195
  initDeploy() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
- "version": "0.0.0-canary.70",
3
+ "version": "0.0.0-canary.72",
4
4
  "type": "module",
5
5
  "description": "A Node.js framework for building web apps.",
6
6
  "main": "./dist/index.js",