@joystick.js/node-canary 0.0.0-canary.71 → 0.0.0-canary.73
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.
- package/dist/app/index.js +30 -0
- package/package.json +1 -1
package/dist/app/index.js
CHANGED
|
@@ -186,6 +186,36 @@ class App {
|
|
|
186
186
|
}
|
|
187
187
|
res.status(200).send({ data: {}, translations: {} });
|
|
188
188
|
});
|
|
189
|
+
this.express.app.post("/api/_test/accounts/signup", async (req, res) => {
|
|
190
|
+
const existingUser = await runUserQuery("user", { emailAddress: req?.body?.emailAddress });
|
|
191
|
+
if (existingUser) {
|
|
192
|
+
await runUserQuery("deleteUser", { userId: existingUser?._id || existingUser?.user_id });
|
|
193
|
+
}
|
|
194
|
+
const signup = await accounts.signup({
|
|
195
|
+
emailAddress: req?.body?.emailAddress,
|
|
196
|
+
password: req?.body?.password,
|
|
197
|
+
metadata: req?.body?.metadata,
|
|
198
|
+
output: req?.body?.output || defaultUserOutputFields
|
|
199
|
+
});
|
|
200
|
+
res.status(200).send(JSON.stringify({
|
|
201
|
+
...signup?.user || {},
|
|
202
|
+
joystickToken: signup?.token,
|
|
203
|
+
joystickLoginTokenExpiresAt: signup?.tokenExpiresAt
|
|
204
|
+
}));
|
|
205
|
+
});
|
|
206
|
+
this.express.app.post("/api/_test/accounts/login", async (req, res) => {
|
|
207
|
+
const login = await accounts.login({
|
|
208
|
+
emailAddress: req?.body?.emailAddress,
|
|
209
|
+
username: req?.body?.username,
|
|
210
|
+
password: req?.body?.password,
|
|
211
|
+
output: req?.body?.output || defaultUserOutputFields
|
|
212
|
+
});
|
|
213
|
+
res.status(200).send(JSON.stringify({
|
|
214
|
+
...login?.user || {},
|
|
215
|
+
joystickToken: login?.token,
|
|
216
|
+
joystickLoginTokenExpiresAt: login?.tokenExpiresAt
|
|
217
|
+
}));
|
|
218
|
+
});
|
|
189
219
|
this.express.app.delete("/api/_test/accounts", async (req, res) => {
|
|
190
220
|
await runUserQuery("deleteUser", { userId: req?.body?.userId });
|
|
191
221
|
res.status(200).send({ data: {} });
|