@devmoods/express-extras 0.17.5 → 0.17.8

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/bin/migrate ADDED
@@ -0,0 +1,5 @@
1
+ #/bin/bash
2
+
3
+ set -e
4
+
5
+ node_modules/.bin/ts-node --esm dist/cli.js ${*:1}
package/dist/auth.js CHANGED
@@ -63,28 +63,27 @@ export function createAuth({ getUserByToken, methods: { emailAndPassword }, filt
63
63
  type: 'string',
64
64
  minLength: 4,
65
65
  };
66
- router.post('/reset/:token', validateParams(tokenSchema), validateBody({
67
- type: 'object',
68
- properties: {
69
- password: { type: 'string', minLength: 8 },
70
- },
71
- required: ['password'],
72
- }), route(async (req) => {
73
- const { password } = req.body;
74
- const { token } = req.params;
75
- if (!emailAndPassword) {
76
- throw new Error('Not applicable for login method');
77
- }
78
- const email = await redis.get(token);
79
- if (!email) {
80
- throw BadRequest('invalid reset token');
81
- }
82
- const user = await emailAndPassword(email, skipPasswordCheck);
83
- await onPasswordChanged?.(user, await hashPassword(password));
84
- await redis.del(token);
85
- logger.info('user changed password', { email });
86
- return 200;
87
- }));
66
+ if (emailAndPassword) {
67
+ router.post('/reset/:token', validateParams(tokenSchema), validateBody({
68
+ type: 'object',
69
+ properties: {
70
+ password: { type: 'string', minLength: 8 },
71
+ },
72
+ required: ['password'],
73
+ }), route(async (req) => {
74
+ const { password } = req.body;
75
+ const { token } = req.params;
76
+ const email = await redis.get(token);
77
+ if (!email) {
78
+ throw BadRequest('invalid reset token');
79
+ }
80
+ const user = await emailAndPassword(email, skipPasswordCheck);
81
+ await onPasswordChanged?.(user, await hashPassword(password));
82
+ await redis.del(token);
83
+ logger.info('user changed password', { email });
84
+ return 200;
85
+ }));
86
+ }
88
87
  router.get('/reset/:token', validateParams(tokenSchema), route(async (req) => {
89
88
  const token = req.params.token;
90
89
  const email = await redis.get(token);
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ import 'dotenv/config';
package/dist/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ import 'dotenv/config';
2
+ import { cli } from './migrate.js';
3
+ cli();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devmoods/express-extras",
3
- "version": "0.17.5",
3
+ "version": "0.17.8",
4
4
  "description": "Kubernetes-ready utilities for rapid Node.js application development",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/bin/migrate.js DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env -S node --loader ts-node/esm
2
-
3
- import 'dotenv/config';
4
-
5
- async function run() {
6
- const { cli } = await import('../dist/migrate.js');
7
- cli();
8
- }
9
-
10
- run();