@laboratory-one/api-components 0.0.17 → 0.0.18
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/cjs/auth/auth.service.d.ts +5 -0
- package/dist/cjs/auth/auth.service.d.ts.map +1 -1
- package/dist/cjs/auth/auth.service.js +14 -0
- package/dist/cjs/auth/auth.service.js.map +1 -1
- package/dist/cjs/user/dtos/delete-user.request.dto.d.ts +1 -1
- package/dist/cjs/user/dtos/delete-user.request.dto.d.ts.map +1 -1
- package/dist/cjs/user/dtos/delete-user.request.dto.js +1 -1
- package/dist/cjs/user/dtos/delete-user.request.dto.js.map +1 -1
- package/dist/cjs/user/dtos/index.d.ts +3 -0
- package/dist/cjs/user/dtos/index.d.ts.map +1 -1
- package/dist/cjs/user/dtos/index.js +3 -0
- package/dist/cjs/user/dtos/index.js.map +1 -1
- package/dist/cjs/user/dtos/phone-login-verify.request.dto.d.ts +6 -0
- package/dist/cjs/user/dtos/phone-login-verify.request.dto.d.ts.map +1 -0
- package/dist/cjs/user/dtos/phone-login-verify.request.dto.js +25 -0
- package/dist/cjs/user/dtos/phone-login-verify.request.dto.js.map +1 -0
- package/dist/cjs/user/dtos/phone-login.request.dto.d.ts +4 -0
- package/dist/cjs/user/dtos/phone-login.request.dto.d.ts.map +1 -0
- package/dist/cjs/user/dtos/phone-login.request.dto.js +15 -0
- package/dist/cjs/user/dtos/phone-login.request.dto.js.map +1 -0
- package/dist/cjs/user/dtos/phone-login.response.dto.d.ts +5 -0
- package/dist/cjs/user/dtos/phone-login.response.dto.d.ts.map +1 -0
- package/dist/cjs/user/dtos/phone-login.response.dto.js +20 -0
- package/dist/cjs/user/dtos/phone-login.response.dto.js.map +1 -0
- package/dist/cjs/user/dtos/update-user.request.dto.d.ts +1 -0
- package/dist/cjs/user/dtos/update-user.request.dto.d.ts.map +1 -1
- package/dist/cjs/user/dtos/update-user.request.dto.js +6 -0
- package/dist/cjs/user/dtos/update-user.request.dto.js.map +1 -1
- package/dist/cjs/user/schemas/index.d.ts +2 -0
- package/dist/cjs/user/schemas/index.d.ts.map +1 -1
- package/dist/cjs/user/schemas/index.js +2 -0
- package/dist/cjs/user/schemas/index.js.map +1 -1
- package/dist/cjs/user/schemas/phone-login-verify.schema.d.ts +15 -0
- package/dist/cjs/user/schemas/phone-login-verify.schema.d.ts.map +1 -0
- package/dist/cjs/user/schemas/phone-login-verify.schema.js +11 -0
- package/dist/cjs/user/schemas/phone-login-verify.schema.js.map +1 -0
- package/dist/cjs/user/schemas/phone-login.schema.d.ts +9 -0
- package/dist/cjs/user/schemas/phone-login.schema.d.ts.map +1 -0
- package/dist/cjs/user/schemas/phone-login.schema.js +9 -0
- package/dist/cjs/user/schemas/phone-login.schema.js.map +1 -0
- package/dist/cjs/user/schemas/update-user.schema.d.ts +3 -0
- package/dist/cjs/user/schemas/update-user.schema.d.ts.map +1 -1
- package/dist/cjs/user/schemas/update-user.schema.js +1 -0
- package/dist/cjs/user/schemas/update-user.schema.js.map +1 -1
- package/dist/cjs/user/user.controller.d.ts +6 -6
- package/dist/cjs/user/user.controller.d.ts.map +1 -1
- package/dist/cjs/user/user.controller.js +115 -15
- package/dist/cjs/user/user.controller.js.map +1 -1
- package/dist/cjs/user/user.service.d.ts +1 -0
- package/dist/cjs/user/user.service.d.ts.map +1 -1
- package/dist/cjs/user/user.service.js +6 -0
- package/dist/cjs/user/user.service.js.map +1 -1
- package/dist/cjs/utils/schema.util.d.ts +2 -0
- package/dist/cjs/utils/schema.util.d.ts.map +1 -1
- package/dist/cjs/utils/schema.util.js +2 -0
- package/dist/cjs/utils/schema.util.js.map +1 -1
- package/dist/esm/auth/auth.service.d.ts +5 -0
- package/dist/esm/auth/auth.service.d.ts.map +1 -1
- package/dist/esm/auth/auth.service.js +14 -0
- package/dist/esm/auth/auth.service.js.map +1 -1
- package/dist/esm/user/dtos/delete-user.request.dto.d.ts +1 -1
- package/dist/esm/user/dtos/delete-user.request.dto.d.ts.map +1 -1
- package/dist/esm/user/dtos/delete-user.request.dto.js +1 -1
- package/dist/esm/user/dtos/delete-user.request.dto.js.map +1 -1
- package/dist/esm/user/dtos/index.d.ts +3 -0
- package/dist/esm/user/dtos/index.d.ts.map +1 -1
- package/dist/esm/user/dtos/index.js +3 -0
- package/dist/esm/user/dtos/index.js.map +1 -1
- package/dist/esm/user/dtos/phone-login-verify.request.dto.d.ts +6 -0
- package/dist/esm/user/dtos/phone-login-verify.request.dto.d.ts.map +1 -0
- package/dist/esm/user/dtos/phone-login-verify.request.dto.js +21 -0
- package/dist/esm/user/dtos/phone-login-verify.request.dto.js.map +1 -0
- package/dist/esm/user/dtos/phone-login.request.dto.d.ts +4 -0
- package/dist/esm/user/dtos/phone-login.request.dto.d.ts.map +1 -0
- package/dist/esm/user/dtos/phone-login.request.dto.js +11 -0
- package/dist/esm/user/dtos/phone-login.request.dto.js.map +1 -0
- package/dist/esm/user/dtos/phone-login.response.dto.d.ts +5 -0
- package/dist/esm/user/dtos/phone-login.response.dto.d.ts.map +1 -0
- package/dist/esm/user/dtos/phone-login.response.dto.js +16 -0
- package/dist/esm/user/dtos/phone-login.response.dto.js.map +1 -0
- package/dist/esm/user/dtos/update-user.request.dto.d.ts +1 -0
- package/dist/esm/user/dtos/update-user.request.dto.d.ts.map +1 -1
- package/dist/esm/user/dtos/update-user.request.dto.js +6 -0
- package/dist/esm/user/dtos/update-user.request.dto.js.map +1 -1
- package/dist/esm/user/schemas/index.d.ts +2 -0
- package/dist/esm/user/schemas/index.d.ts.map +1 -1
- package/dist/esm/user/schemas/index.js +2 -0
- package/dist/esm/user/schemas/index.js.map +1 -1
- package/dist/esm/user/schemas/phone-login-verify.schema.d.ts +15 -0
- package/dist/esm/user/schemas/phone-login-verify.schema.d.ts.map +1 -0
- package/dist/esm/user/schemas/phone-login-verify.schema.js +8 -0
- package/dist/esm/user/schemas/phone-login-verify.schema.js.map +1 -0
- package/dist/esm/user/schemas/phone-login.schema.d.ts +9 -0
- package/dist/esm/user/schemas/phone-login.schema.d.ts.map +1 -0
- package/dist/esm/user/schemas/phone-login.schema.js +6 -0
- package/dist/esm/user/schemas/phone-login.schema.js.map +1 -0
- package/dist/esm/user/schemas/update-user.schema.d.ts +3 -0
- package/dist/esm/user/schemas/update-user.schema.d.ts.map +1 -1
- package/dist/esm/user/schemas/update-user.schema.js +1 -0
- package/dist/esm/user/schemas/update-user.schema.js.map +1 -1
- package/dist/esm/user/user.controller.d.ts +6 -6
- package/dist/esm/user/user.controller.d.ts.map +1 -1
- package/dist/esm/user/user.controller.js +107 -7
- package/dist/esm/user/user.controller.js.map +1 -1
- package/dist/esm/user/user.service.d.ts +1 -0
- package/dist/esm/user/user.service.d.ts.map +1 -1
- package/dist/esm/user/user.service.js +6 -0
- package/dist/esm/user/user.service.js.map +1 -1
- package/dist/esm/utils/schema.util.d.ts +2 -0
- package/dist/esm/utils/schema.util.d.ts.map +1 -1
- package/dist/esm/utils/schema.util.js +2 -0
- package/dist/esm/utils/schema.util.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/auth/auth.service.ts +26 -0
- package/src/user/dtos/delete-user.request.dto.ts +1 -1
- package/src/user/dtos/index.ts +3 -0
- package/src/user/dtos/phone-login-verify.request.dto.ts +16 -0
- package/src/user/dtos/phone-login.request.dto.ts +8 -0
- package/src/user/dtos/phone-login.response.dto.ts +12 -0
- package/src/user/dtos/update-user.request.dto.ts +5 -0
- package/src/user/schemas/index.ts +2 -0
- package/src/user/schemas/phone-login-verify.schema.ts +9 -0
- package/src/user/schemas/phone-login.schema.ts +7 -0
- package/src/user/schemas/update-user.schema.ts +1 -0
- package/src/user/user.controller.ts +142 -7
- package/src/user/user.service.ts +8 -0
- package/src/utils/schema.util.ts +2 -0
|
@@ -6,16 +6,14 @@ const common_1 = require("@nestjs/common");
|
|
|
6
6
|
const jwt_1 = require("@nestjs/jwt");
|
|
7
7
|
const swagger_1 = require("@nestjs/swagger");
|
|
8
8
|
const client_1 = require("@prisma/client");
|
|
9
|
-
const
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
10
|
const user_service_1 = require("./user.service");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const register_response_dto_1 = require("./dtos/register.response.dto");
|
|
14
|
-
const register_request_dto_1 = require("./dtos/register.request.dto");
|
|
15
|
-
const push_service_1 = require("../push/push.service");
|
|
11
|
+
const dtos_1 = require("./dtos");
|
|
12
|
+
const push_1 = require("../push");
|
|
16
13
|
const utils_1 = require("../utils");
|
|
17
14
|
const guard_1 = require("../guard");
|
|
18
15
|
const types = tslib_1.__importStar(require("../types"));
|
|
16
|
+
const schemas_1 = require("./schemas");
|
|
19
17
|
let UserController = class UserController {
|
|
20
18
|
constructor(userService, authService, pushService, jwtService) {
|
|
21
19
|
this.userService = userService;
|
|
@@ -23,6 +21,48 @@ let UserController = class UserController {
|
|
|
23
21
|
this.pushService = pushService;
|
|
24
22
|
this.jwtService = jwtService;
|
|
25
23
|
}
|
|
24
|
+
async phoneLogin(dto) {
|
|
25
|
+
try {
|
|
26
|
+
const parsedDto = schemas_1.phoneLoginSchema.parse(dto);
|
|
27
|
+
const phoneNumber = (0, utils_1.cleanPhoneNumber)(parsedDto.phoneNumber);
|
|
28
|
+
const user = await this.userService.findOneByPhoneNumber(parsedDto.phoneNumber);
|
|
29
|
+
if (!user) {
|
|
30
|
+
const newUser = await this.userService.create({
|
|
31
|
+
phoneNumber,
|
|
32
|
+
});
|
|
33
|
+
if (!newUser) {
|
|
34
|
+
(0, utils_1.handleError)('Error creating user');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const res = await this.authService.phoneLoginOrCreate(phoneNumber);
|
|
38
|
+
return {
|
|
39
|
+
methodId: res.phone_id,
|
|
40
|
+
phoneNumber,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
(0, utils_1.handleError)(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async phoneLoginVerify(dto) {
|
|
48
|
+
try {
|
|
49
|
+
const parsedDto = schemas_1.phoneLoginVerifySchema.parse(dto);
|
|
50
|
+
const res = await this.authService.phoneAuthenticate({
|
|
51
|
+
methodId: parsedDto.methodId,
|
|
52
|
+
code: parsedDto.code,
|
|
53
|
+
});
|
|
54
|
+
const user = await this.userService.findOneByPhoneNumber(parsedDto.phoneNumber);
|
|
55
|
+
await this.userService.update(user.id, {
|
|
56
|
+
externalId: res.user_id,
|
|
57
|
+
});
|
|
58
|
+
const payload = { userId: user.id };
|
|
59
|
+
const token = await this.jwtService.signAsync(payload);
|
|
60
|
+
return Object.assign(Object.assign({}, user), { token });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
(0, utils_1.handleError)(error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
26
66
|
async signup(dto) {
|
|
27
67
|
const cleanedDTO = {
|
|
28
68
|
email: (0, utils_1.cleanStringAndLowercase)(dto.email),
|
|
@@ -33,6 +73,7 @@ let UserController = class UserController {
|
|
|
33
73
|
(0, utils_1.handleError)('Error creating user');
|
|
34
74
|
}
|
|
35
75
|
const user = await this.userService.create({
|
|
76
|
+
phoneNumber: res.user_id,
|
|
36
77
|
email: cleanedDTO.email,
|
|
37
78
|
externalId: res.user_id,
|
|
38
79
|
});
|
|
@@ -108,18 +149,63 @@ let UserController = class UserController {
|
|
|
108
149
|
(0, utils_1.handleError)(error);
|
|
109
150
|
}
|
|
110
151
|
}
|
|
152
|
+
async delete(req, dto) {
|
|
153
|
+
try {
|
|
154
|
+
const parsedDto = schemas_1.deleteUserSchema.parse(dto);
|
|
155
|
+
const user = await this.userService.findOneByUserId(req.user.userId);
|
|
156
|
+
if (!user) {
|
|
157
|
+
(0, utils_1.handleError)('User not found');
|
|
158
|
+
}
|
|
159
|
+
if (parsedDto.phoneNumber !== user.phoneNumber) {
|
|
160
|
+
(0, utils_1.handleError)('Invalid email');
|
|
161
|
+
}
|
|
162
|
+
await this.authService.delete(user.externalId);
|
|
163
|
+
await this.userService.update(req.user.userId, {
|
|
164
|
+
status: client_1.UserStatus.DELETED,
|
|
165
|
+
email: user.externalId,
|
|
166
|
+
phoneNumber: user.externalId,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
(0, utils_1.handleError)(error);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
111
173
|
};
|
|
112
174
|
exports.UserController = UserController;
|
|
175
|
+
tslib_1.__decorate([
|
|
176
|
+
(0, common_1.Post)('phone-login'),
|
|
177
|
+
(0, swagger_1.ApiResponse)({
|
|
178
|
+
status: 200,
|
|
179
|
+
description: 'loginOrCreate successful',
|
|
180
|
+
type: dtos_1.PhoneLoginResponseDto,
|
|
181
|
+
}),
|
|
182
|
+
tslib_1.__param(0, (0, common_1.Body)()),
|
|
183
|
+
tslib_1.__metadata("design:type", Function),
|
|
184
|
+
tslib_1.__metadata("design:paramtypes", [dtos_1.PhoneLoginRequestDto]),
|
|
185
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
186
|
+
], UserController.prototype, "phoneLogin", null);
|
|
187
|
+
tslib_1.__decorate([
|
|
188
|
+
(0, common_1.Post)('phone-login-verify'),
|
|
189
|
+
(0, swagger_1.ApiResponse)({
|
|
190
|
+
status: 200,
|
|
191
|
+
description: 'loginOrCreate successful',
|
|
192
|
+
type: dtos_1.RegisterResponseDto,
|
|
193
|
+
}),
|
|
194
|
+
tslib_1.__param(0, (0, common_1.Body)()),
|
|
195
|
+
tslib_1.__metadata("design:type", Function),
|
|
196
|
+
tslib_1.__metadata("design:paramtypes", [dtos_1.PhoneLoginVerifyRequestDto]),
|
|
197
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
198
|
+
], UserController.prototype, "phoneLoginVerify", null);
|
|
113
199
|
tslib_1.__decorate([
|
|
114
200
|
(0, common_1.Post)('signup'),
|
|
115
201
|
(0, swagger_1.ApiResponse)({
|
|
116
202
|
status: 200,
|
|
117
203
|
description: 'loginOrCreate successful',
|
|
118
|
-
type:
|
|
204
|
+
type: dtos_1.RegisterResponseDto,
|
|
119
205
|
}),
|
|
120
206
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
121
207
|
tslib_1.__metadata("design:type", Function),
|
|
122
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
208
|
+
tslib_1.__metadata("design:paramtypes", [dtos_1.RegisterRequestDto]),
|
|
123
209
|
tslib_1.__metadata("design:returntype", Promise)
|
|
124
210
|
], UserController.prototype, "signup", null);
|
|
125
211
|
tslib_1.__decorate([
|
|
@@ -127,11 +213,11 @@ tslib_1.__decorate([
|
|
|
127
213
|
(0, swagger_1.ApiResponse)({
|
|
128
214
|
status: 200,
|
|
129
215
|
description: 'loginOrCreate successful',
|
|
130
|
-
type:
|
|
216
|
+
type: dtos_1.RegisterResponseDto,
|
|
131
217
|
}),
|
|
132
218
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
133
219
|
tslib_1.__metadata("design:type", Function),
|
|
134
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
220
|
+
tslib_1.__metadata("design:paramtypes", [dtos_1.RegisterRequestDto]),
|
|
135
221
|
tslib_1.__metadata("design:returntype", Promise)
|
|
136
222
|
], UserController.prototype, "login", null);
|
|
137
223
|
tslib_1.__decorate([
|
|
@@ -140,7 +226,7 @@ tslib_1.__decorate([
|
|
|
140
226
|
(0, swagger_1.ApiResponse)({
|
|
141
227
|
status: 200,
|
|
142
228
|
description: 'get self successful',
|
|
143
|
-
type:
|
|
229
|
+
type: dtos_1.GetUserResponseDto,
|
|
144
230
|
}),
|
|
145
231
|
tslib_1.__param(0, (0, common_1.Request)()),
|
|
146
232
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -153,12 +239,12 @@ tslib_1.__decorate([
|
|
|
153
239
|
(0, swagger_1.ApiResponse)({
|
|
154
240
|
status: 200,
|
|
155
241
|
description: 'update user successful',
|
|
156
|
-
type:
|
|
242
|
+
type: dtos_1.GetUserResponseDto,
|
|
157
243
|
}),
|
|
158
244
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
159
245
|
tslib_1.__param(1, (0, common_1.Request)()),
|
|
160
246
|
tslib_1.__metadata("design:type", Function),
|
|
161
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
247
|
+
tslib_1.__metadata("design:paramtypes", [dtos_1.UpdateUserRequestDto, Object]),
|
|
162
248
|
tslib_1.__metadata("design:returntype", Promise)
|
|
163
249
|
], UserController.prototype, "edit", null);
|
|
164
250
|
tslib_1.__decorate([
|
|
@@ -173,12 +259,26 @@ tslib_1.__decorate([
|
|
|
173
259
|
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
174
260
|
tslib_1.__metadata("design:returntype", Promise)
|
|
175
261
|
], UserController.prototype, "pushTest", null);
|
|
262
|
+
tslib_1.__decorate([
|
|
263
|
+
(0, common_1.UseGuards)(guard_1.AuthGuard),
|
|
264
|
+
(0, common_1.Post)('delete'),
|
|
265
|
+
(0, swagger_1.ApiResponse)({
|
|
266
|
+
status: 200,
|
|
267
|
+
description: 'delete user successful',
|
|
268
|
+
type: dtos_1.GetUserResponseDto,
|
|
269
|
+
}),
|
|
270
|
+
tslib_1.__param(0, (0, common_1.Request)()),
|
|
271
|
+
tslib_1.__param(1, (0, common_1.Body)()),
|
|
272
|
+
tslib_1.__metadata("design:type", Function),
|
|
273
|
+
tslib_1.__metadata("design:paramtypes", [Object, dtos_1.DeleteUserRequestDto]),
|
|
274
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
275
|
+
], UserController.prototype, "delete", null);
|
|
176
276
|
exports.UserController = UserController = tslib_1.__decorate([
|
|
177
277
|
(0, swagger_1.ApiTags)('User'),
|
|
178
278
|
(0, common_1.Controller)('user'),
|
|
179
279
|
tslib_1.__metadata("design:paramtypes", [user_service_1.UserService,
|
|
180
|
-
|
|
181
|
-
|
|
280
|
+
auth_1.AuthService,
|
|
281
|
+
push_1.PushService,
|
|
182
282
|
jwt_1.JwtService])
|
|
183
283
|
], UserController);
|
|
184
284
|
//# sourceMappingURL=user.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.controller.js","sourceRoot":"/","sources":["user/user.controller.ts"],"names":[],"mappings":";;;;AAAA,2CAOwB;AACxB,qCAAyC;AACzC,6CAAuD;AACvD,2CAAwD;AAIxD,uDAAmD;AACnD,iDAA6C;AAC7C,wEAAkE;AAClE,4EAAsE;AACtE,wEAAmE;AACnE,sEAAiE;AACjE,uDAAmD;AACnD,oCAMkB;AAClB,oCAAqC;AACrC,wDAAkC;AAI3B,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YACU,WAAwB,EACxB,WAAwB,EACxB,WAAwB,EACxB,UAAsB;QAHtB,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;IAC7B,CAAC;IAQE,AAAN,KAAK,CAAC,MAAM,CAAS,GAAuB;QAC1C,MAAM,UAAU,GAAuB;YACrC,KAAK,EAAE,IAAA,+BAAuB,EAAC,GAAG,CAAC,KAAK,CAAC;YACzC,QAAQ,EAAE,IAAA,mBAAW,EAAC,GAAG,CAAC,QAAQ,CAAC;SACpC,CAAC;QAEF,MAAM,GAAG,GACP,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAE5C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,IAAA,mBAAW,EAAC,qBAAqB,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,IAAI,GAAS,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAC/C,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,UAAU,EAAE,GAAG,CAAC,OAAO;SACxB,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAA,mBAAW,EAAC,qBAAqB,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,OAAO,G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AAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE,0CAAkB;KACzB,CAAC;IAEC,mBAAA,IAAA,aAAI,GAAE,CAAA;IACN,mBAAA,IAAA,gBAAO,GAAE,CAAA;;6CADG,8CAAoB;;0CA8BlC;AAQK;IANL,IAAA,kBAAS,EAAC,iBAAS,CAAC;IACpB,IAAA,aAAI,EAAC,UAAU,CAAC;IAChB,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,sBAAsB;KACpC,CAAC;IACc,mBAAA,IAAA,gBAAO,GAAE,CAAA;;;;8CAgBxB;yBA/JU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;6CAGM,0BAAW;QACX,0BAAW;QACX,0BAAW;QACZ,gBAAU;GALrB,cAAc,CAgK1B","sourcesContent":["import {\n Body,\n Controller,\n Get,\n Post,\n Request,\n UseGuards,\n} from '@nestjs/common';\nimport { JwtService } from '@nestjs/jwt';\nimport { ApiResponse, ApiTags } from '@nestjs/swagger';\nimport { OnboardingStatus, User } from '@prisma/client';\nimport { ExpoPushMessage } from 'expo-server-sdk';\nimport * as stytch from 'stytch';\n\nimport { AuthService } from '../auth/auth.service';\nimport { UserService } from './user.service';\nimport { GetUserResponseDto } from './dtos/get-user.response.dto';\nimport { UpdateUserRequestDto } from './dtos/update-user.request.dto';\nimport { RegisterResponseDto } from './dtos/register.response.dto';\nimport { RegisterRequestDto } from './dtos/register.request.dto';\nimport { PushService } from '../push/push.service';\nimport {\n cleanPhoneNumber,\n cleanString,\n cleanStringAndLowercase,\n handleError,\n utcOffsetToHours,\n} from '../utils';\nimport { AuthGuard } from '../guard';\nimport * as types from '../types';\n\n@ApiTags('User')\n@Controller('user')\nexport class UserController {\n constructor(\n private userService: UserService,\n private authService: AuthService,\n private pushService: PushService,\n private jwtService: JwtService,\n ) {}\n\n @Post('signup')\n @ApiResponse({\n status: 200,\n description: 'loginOrCreate successful',\n type: RegisterResponseDto,\n })\n async signup(@Body() dto: RegisterRequestDto): Promise<RegisterResponseDto> {\n const cleanedDTO: RegisterRequestDto = {\n email: cleanStringAndLowercase(dto.email),\n password: cleanString(dto.password),\n };\n\n const res: stytch.PasswordsCreateResponse =\n await this.authService.signup(cleanedDTO);\n\n if (!res) {\n handleError('Error creating user');\n }\n\n const user: User = await this.userService.create({\n email: cleanedDTO.email,\n externalId: res.user_id,\n });\n\n if (!user) {\n handleError('Error creating user');\n }\n\n const payload = { userId: user.id };\n const token: string = await this.jwtService.signAsync(payload);\n\n return {\n ...user,\n token,\n };\n }\n\n @Post('login')\n @ApiResponse({\n status: 200,\n description: 'loginOrCreate successful',\n type: RegisterResponseDto,\n })\n async login(@Body() dto: RegisterRequestDto): Promise<RegisterResponseDto> {\n const cleanedDTO: RegisterRequestDto = {\n email: cleanStringAndLowercase(dto.email),\n password: dto.password.trim(),\n };\n\n const res: boolean = await this.authService.login(cleanedDTO);\n\n if (!res) {\n handleError('Error logging in');\n }\n\n const user: User = await this.userService.findOneByEmail(cleanedDTO.email);\n\n if (!user) {\n handleError('Error logging in');\n }\n\n const payload = { userId: user.id };\n const token: string = await this.jwtService.signAsync(payload);\n\n return {\n ...user,\n token,\n };\n }\n\n @UseGuards(AuthGuard)\n @Get('self')\n @ApiResponse({\n status: 200,\n description: 'get self successful',\n type: GetUserResponseDto,\n })\n async getSelf(@Request() req: types.reqType): Promise<GetUserResponseDto> {\n try {\n const user: User = await this.userService.findOneByUserId(\n req.user.userId,\n );\n\n return user as GetUserResponseDto;\n } catch (error) {\n handleError(error);\n }\n }\n\n @UseGuards(AuthGuard)\n @Post('update')\n @ApiResponse({\n status: 200,\n description: 'update user successful',\n type: GetUserResponseDto,\n })\n async edit(\n @Body() dto: UpdateUserRequestDto,\n @Request() req: types.reqType,\n ): Promise<GetUserResponseDto> {\n try {\n const cleanDto: UpdateUserRequestDto = {\n phoneNumber: dto.phoneNumber\n ? cleanPhoneNumber(dto.phoneNumber)\n : undefined,\n fullName: dto.fullName\n ? cleanStringAndLowercase(dto.fullName)\n : undefined,\n pushToken: dto.pushToken ? cleanString(dto.pushToken) : undefined,\n tz: dto.tz ? utcOffsetToHours(dto.tz) : undefined,\n };\n\n const user: User = await this.userService.update(\n req.user.userId,\n cleanDto,\n );\n\n if (user.fullName && user.phoneNumber) {\n await this.userService.update(req.user.userId, {\n onboardingStatus: OnboardingStatus.COMPLETED,\n });\n }\n\n return user as GetUserResponseDto;\n } catch (error) {\n handleError(error);\n }\n }\n\n @UseGuards(AuthGuard)\n @Post('pushTest')\n @ApiResponse({\n status: 200,\n description: 'push test successful',\n })\n async pushTest(@Request() req: types.reqType): Promise<void> {\n try {\n const user: User = await this.userService.findOneByUserId(\n req.user.userId,\n );\n\n if (user.pushToken) {\n const messages: ExpoPushMessage[] = this.pushService.createMessages({\n body: 'Test push',\n pushTokens: [user.pushToken],\n });\n await this.pushService.sendMessages(messages);\n }\n } catch (error) {\n handleError(error);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"user.controller.js","sourceRoot":"/","sources":["user/user.controller.ts"],"names":[],"mappings":";;;;AAAA,2CAOwB;AACxB,qCAAyC;AACzC,6CAAuD;AACvD,2CAAoE;AAKpE,kCAAsC;AACtC,iDAA6C;AAC7C,iCASgB;AAChB,kCAAsC;AACtC,oCAMkB;AAClB,oCAAqC;AACrC,wDAAkC;AAClC,uCAImB;AAIZ,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YACU,WAAwB,EACxB,WAAwB,EACxB,WAAwB,EACxB,UAAsB;QAHtB,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;IAC7B,CAAC;IAQE,AAAN,KAAK,CAAC,UAAU,CACN,GAAyB;QAEjC,IAAI,CAAC;YACH,MAAM,SAAS,GAAyB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AA,IAAA,gBAAO,GAAE,CAAA;;6CADG,2BAAoB;;0CA8BlC;AAQK;IANL,IAAA,kBAAS,EAAC,iBAAS,CAAC;IACpB,IAAA,aAAI,EAAC,UAAU,CAAC;IAChB,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,sBAAsB;KACpC,CAAC;IACc,mBAAA,IAAA,gBAAO,GAAE,CAAA;;;;8CAgBxB;AASK;IAPL,IAAA,kBAAS,EAAC,iBAAS,CAAC;IACpB,IAAA,aAAI,EAAC,QAAQ,CAAC;IACd,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE,yBAAkB;KACzB,CAAC;IAEC,mBAAA,IAAA,gBAAO,GAAE,CAAA;IACT,mBAAA,IAAA,aAAI,GAAE,CAAA;;qDAAM,2BAAoB;;4CA4BlC;yBA1RU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;6CAGM,0BAAW;QACX,kBAAW;QACX,kBAAW;QACZ,gBAAU;GALrB,cAAc,CA2R1B","sourcesContent":["import {\n Body,\n Controller,\n Get,\n Post,\n Request,\n UseGuards,\n} from '@nestjs/common';\nimport { JwtService } from '@nestjs/jwt';\nimport { ApiResponse, ApiTags } from '@nestjs/swagger';\nimport { OnboardingStatus, User, UserStatus } from '@prisma/client';\nimport { ExpoPushMessage } from 'expo-server-sdk';\nimport * as stytch from 'stytch';\nimport { ZodObject } from 'zod';\n\nimport { AuthService } from '../auth';\nimport { UserService } from './user.service';\nimport {\n GetUserResponseDto,\n UpdateUserRequestDto,\n RegisterResponseDto,\n DeleteUserRequestDto,\n PhoneLoginRequestDto,\n PhoneLoginResponseDto,\n PhoneLoginVerifyRequestDto,\n RegisterRequestDto,\n} from './dtos';\nimport { PushService } from '../push';\nimport {\n cleanPhoneNumber,\n cleanString,\n cleanStringAndLowercase,\n handleError,\n utcOffsetToHours,\n} from '../utils';\nimport { AuthGuard } from '../guard';\nimport * as types from '../types';\nimport {\n deleteUserSchema,\n phoneLoginSchema,\n phoneLoginVerifySchema,\n} from './schemas';\n\n@ApiTags('User')\n@Controller('user')\nexport class UserController {\n constructor(\n private userService: UserService,\n private authService: AuthService,\n private pushService: PushService,\n private jwtService: JwtService,\n ) {}\n\n @Post('phone-login')\n @ApiResponse({\n status: 200,\n description: 'loginOrCreate successful',\n type: PhoneLoginResponseDto,\n })\n async phoneLogin(\n @Body() dto: PhoneLoginRequestDto,\n ): Promise<PhoneLoginResponseDto> {\n try {\n const parsedDto: PhoneLoginRequestDto = phoneLoginSchema.parse(\n dto,\n ) as PhoneLoginRequestDto;\n\n const phoneNumber: string = cleanPhoneNumber(parsedDto.phoneNumber);\n\n const user: User = await this.userService.findOneByPhoneNumber(\n parsedDto.phoneNumber,\n );\n\n if (!user) {\n const newUser: User = await this.userService.create({\n phoneNumber,\n });\n\n if (!newUser) {\n handleError('Error creating user');\n }\n\n // this is where you can do other user setup\n }\n\n const res: stytch.OTPsSmsLoginOrCreateResponse =\n await this.authService.phoneLoginOrCreate(phoneNumber);\n\n return {\n methodId: res.phone_id,\n phoneNumber,\n };\n } catch (error) {\n handleError(error);\n }\n }\n\n @Post('phone-login-verify')\n @ApiResponse({\n status: 200,\n description: 'loginOrCreate successful',\n type: RegisterResponseDto,\n })\n async phoneLoginVerify(\n @Body() dto: PhoneLoginVerifyRequestDto,\n ): Promise<RegisterResponseDto> {\n try {\n const parsedDto: PhoneLoginVerifyRequestDto =\n phoneLoginVerifySchema.parse(dto) as PhoneLoginVerifyRequestDto;\n\n const res: stytch.OTPsAuthenticateResponse =\n await this.authService.phoneAuthenticate({\n methodId: parsedDto.methodId,\n code: parsedDto.code,\n });\n\n const user: User = await this.userService.findOneByPhoneNumber(\n parsedDto.phoneNumber,\n );\n\n await this.userService.update(user.id, {\n externalId: res.user_id,\n });\n\n const payload = { userId: user.id };\n const token: string = await this.jwtService.signAsync(payload);\n\n return {\n ...user,\n token,\n };\n } catch (error) {\n handleError(error);\n }\n }\n\n @Post('signup')\n @ApiResponse({\n status: 200,\n description: 'loginOrCreate successful',\n type: RegisterResponseDto,\n })\n async signup(@Body() dto: RegisterRequestDto): Promise<RegisterResponseDto> {\n const cleanedDTO: RegisterRequestDto = {\n email: cleanStringAndLowercase(dto.email),\n password: cleanString(dto.password),\n };\n\n const res: stytch.PasswordsCreateResponse =\n await this.authService.signup(cleanedDTO);\n\n if (!res) {\n handleError('Error creating user');\n }\n\n const user: User = await this.userService.create({\n phoneNumber: res.user_id, // use phone number as placeholder\n email: cleanedDTO.email,\n externalId: res.user_id,\n });\n\n if (!user) {\n handleError('Error creating user');\n }\n\n const payload = { userId: user.id };\n const token: string = await this.jwtService.signAsync(payload);\n\n return {\n ...user,\n token,\n };\n }\n\n @Post('login')\n @ApiResponse({\n status: 200,\n description: 'loginOrCreate successful',\n type: RegisterResponseDto,\n })\n async login(@Body() dto: RegisterRequestDto): Promise<RegisterResponseDto> {\n const cleanedDTO: RegisterRequestDto = {\n email: cleanStringAndLowercase(dto.email),\n password: dto.password.trim(),\n };\n\n const res: boolean = await this.authService.login(cleanedDTO);\n\n if (!res) {\n handleError('Error logging in');\n }\n\n const user: User = await this.userService.findOneByEmail(cleanedDTO.email);\n\n if (!user) {\n handleError('Error logging in');\n }\n\n const payload = { userId: user.id };\n const token: string = await this.jwtService.signAsync(payload);\n\n return {\n ...user,\n token,\n };\n }\n\n @UseGuards(AuthGuard)\n @Get('self')\n @ApiResponse({\n status: 200,\n description: 'get self successful',\n type: GetUserResponseDto,\n })\n async getSelf(@Request() req: types.reqType): Promise<GetUserResponseDto> {\n try {\n const user: User = await this.userService.findOneByUserId(\n req.user.userId,\n );\n\n return user as GetUserResponseDto;\n } catch (error) {\n handleError(error);\n }\n }\n\n @UseGuards(AuthGuard)\n @Post('update')\n @ApiResponse({\n status: 200,\n description: 'update user successful',\n type: GetUserResponseDto,\n })\n async edit(\n @Body() dto: UpdateUserRequestDto,\n @Request() req: types.reqType,\n ): Promise<GetUserResponseDto> {\n try {\n const cleanDto: UpdateUserRequestDto = {\n phoneNumber: dto.phoneNumber\n ? cleanPhoneNumber(dto.phoneNumber)\n : undefined,\n fullName: dto.fullName\n ? cleanStringAndLowercase(dto.fullName)\n : undefined,\n pushToken: dto.pushToken ? cleanString(dto.pushToken) : undefined,\n tz: dto.tz ? utcOffsetToHours(dto.tz) : undefined,\n };\n\n const user: User = await this.userService.update(\n req.user.userId,\n cleanDto,\n );\n\n if (user.fullName && user.phoneNumber) {\n await this.userService.update(req.user.userId, {\n onboardingStatus: OnboardingStatus.COMPLETED,\n });\n }\n\n return user as GetUserResponseDto;\n } catch (error) {\n handleError(error);\n }\n }\n\n @UseGuards(AuthGuard)\n @Post('pushTest')\n @ApiResponse({\n status: 200,\n description: 'push test successful',\n })\n async pushTest(@Request() req: types.reqType): Promise<void> {\n try {\n const user: User = await this.userService.findOneByUserId(\n req.user.userId,\n );\n\n if (user.pushToken) {\n const messages: ExpoPushMessage[] = this.pushService.createMessages({\n body: 'Test push',\n pushTokens: [user.pushToken],\n });\n await this.pushService.sendMessages(messages);\n }\n } catch (error) {\n handleError(error);\n }\n }\n\n @UseGuards(AuthGuard)\n @Post('delete')\n @ApiResponse({\n status: 200,\n description: 'delete user successful',\n type: GetUserResponseDto,\n })\n async delete(\n @Request() req: types.reqType,\n @Body() dto: DeleteUserRequestDto,\n ): Promise<void> {\n try {\n const parsedDto: DeleteUserRequestDto = (\n deleteUserSchema as ZodObject<any>\n ).parse(dto) as DeleteUserRequestDto;\n\n const user: User = await this.userService.findOneByUserId(\n req.user.userId,\n );\n\n if (!user) {\n handleError('User not found');\n }\n\n if (parsedDto.phoneNumber !== user.phoneNumber) {\n handleError('Invalid email');\n }\n\n await this.authService.delete(user.externalId);\n await this.userService.update(req.user.userId, {\n status: UserStatus.DELETED,\n email: user.externalId,\n phoneNumber: user.externalId,\n });\n } catch (error) {\n handleError(error);\n }\n }\n}\n"]}
|
|
@@ -6,6 +6,7 @@ export declare class UserService {
|
|
|
6
6
|
constructor(prisma: PrismaService);
|
|
7
7
|
create(data: Prisma.UserCreateInput): Promise<User>;
|
|
8
8
|
findOneByEmail(email: string): Promise<User>;
|
|
9
|
+
findOneByPhoneNumber(phoneNumber: string): Promise<User>;
|
|
9
10
|
findOneByUserId(userId: string): Promise<User>;
|
|
10
11
|
findMany(): Promise<User[]>;
|
|
11
12
|
findManyByTz(tz: number): Promise<User[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.d.ts","sourceRoot":"/","sources":["user/user.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,qBACa,WAAW;IAGV,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAE3C,MAAM,EAAE,aAAa;IAEnC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5C,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9C,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAM3B,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAUzC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAQtE"}
|
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"/","sources":["user/user.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,qBACa,WAAW;IAGV,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAE3C,MAAM,EAAE,aAAa;IAEnC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5C,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxD,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9C,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAM3B,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAUzC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAQtE"}
|
|
@@ -22,6 +22,12 @@ let UserService = UserService_1 = class UserService {
|
|
|
22
22
|
where: { email },
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
async findOneByPhoneNumber(phoneNumber) {
|
|
26
|
+
this.logger.debug('findOneByPhoneNumber');
|
|
27
|
+
return this.prisma.user.findUnique({
|
|
28
|
+
where: { phoneNumber },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
25
31
|
async findOneByUserId(userId) {
|
|
26
32
|
this.logger.debug('findOneByUserId');
|
|
27
33
|
return this.prisma.user.findUnique({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"/","sources":["user/user.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AAGpD,6DAAyD;AAGlD,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAGtB,YAAoB,MAAqB;QAAr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AAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAElC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC/B,KAAK,EAAE;gBACL,EAAE;aACH;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,IAA4B;QACnD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA7DY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;6CAIiB,8BAAa;GAH9B,WAAW,CA6DvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport { Prisma, User } from '@prisma/client';\n\nimport { PrismaService } from '../prisma/prisma.service';\n\n@Injectable()\nexport class UserService {\n private readonly logger: Logger = new Logger(UserService.name);\n\n constructor(private prisma: PrismaService) {}\n\n async create(data: Prisma.UserCreateInput): Promise<User> {\n this.logger.debug('create');\n\n return this.prisma.user.create({\n data,\n });\n }\n\n async findOneByEmail(email: string): Promise<User> {\n this.logger.debug('findOneByEmail');\n\n return this.prisma.user.findUnique({\n where: { email },\n });\n }\n\n async findOneByPhoneNumber(phoneNumber: string): Promise<User> {\n this.logger.debug('findOneByPhoneNumber');\n\n return this.prisma.user.findUnique({\n where: { phoneNumber },\n });\n }\n\n async findOneByUserId(userId: string): Promise<User> {\n this.logger.debug('findOneByUserId');\n\n return this.prisma.user.findUnique({\n where: { id: userId },\n });\n }\n\n async findMany(): Promise<User[]> {\n this.logger.debug('findMany');\n\n return this.prisma.user.findMany();\n }\n\n async findManyByTz(tz: number): Promise<User[]> {\n this.logger.debug('findManyByTz');\n\n return this.prisma.user.findMany({\n where: {\n tz,\n },\n });\n }\n\n async update(id: string, data: Prisma.UserUpdateInput): Promise<User> {\n this.logger.debug('update');\n\n return this.prisma.user.update({\n where: { id },\n data,\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.util.d.ts","sourceRoot":"/","sources":["utils/schema.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"schema.util.d.ts","sourceRoot":"/","sources":["utils/schema.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;CAU1B,CAAC"}
|
|
@@ -10,5 +10,7 @@ exports.schemaPatterns = {
|
|
|
10
10
|
pushToken: zod_1.z.string().min(1).max(500).trim(),
|
|
11
11
|
tz: zod_1.z.number().int().min(-10000).max(10000),
|
|
12
12
|
date: zod_1.z.string().date(),
|
|
13
|
+
code: zod_1.z.string().length(6).trim(),
|
|
14
|
+
methodId: zod_1.z.string().min(1).max(500).trim(),
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=schema.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.util.js","sourceRoot":"/","sources":["utils/schema.util.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,cAAc,GAAG;IAC5B,KAAK,EAAE,OAAC,CA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CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE;IAC7C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IAC3C,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IAC5C,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC3C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;IACjC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;CAC5C,CAAC","sourcesContent":["import { z } from 'zod';\n\nexport const schemaPatterns = {\n email: z.string().email().max(100).min(1).toLowerCase().trim(),\n password: z.string().min(10).max(100).trim(),\n phoneNumber: z.string().min(7).max(20).trim(),\n fullName: z.string().min(2).max(100).trim(),\n pushToken: z.string().min(1).max(500).trim(),\n tz: z.number().int().min(-10000).max(10000),\n date: z.string().date(),\n code: z.string().length(6).trim(),\n methodId: z.string().min(1).max(500).trim(),\n};\n"]}
|
|
@@ -8,6 +8,11 @@ export declare class AuthService {
|
|
|
8
8
|
constructor(configService: ConfigService);
|
|
9
9
|
signup(data: RegisterRequestDto): Promise<stytch.PasswordsCreateResponse>;
|
|
10
10
|
login(data: RegisterRequestDto): Promise<boolean>;
|
|
11
|
+
phoneLoginOrCreate(phoneNumber: string): Promise<stytch.OTPsSmsLoginOrCreateResponse>;
|
|
12
|
+
phoneAuthenticate({ methodId, code, }: {
|
|
13
|
+
methodId: string;
|
|
14
|
+
code: string;
|
|
15
|
+
}): Promise<stytch.OTPsAuthenticateResponse>;
|
|
11
16
|
delete(externalId: string): Promise<void>;
|
|
12
17
|
}
|
|
13
18
|
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,qBACa,WAAW;IAIV,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAgB;gBAEd,aAAa,EAAE,aAAa;IAW1C,MAAM,CACV,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IAMpC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBjD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,qBACa,WAAW;IAIV,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAgB;gBAEd,aAAa,EAAE,aAAa;IAW1C,MAAM,CACV,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IAMpC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBjD,kBAAkB,CACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC;IASzC,iBAAiB,CAAC,EACtB,QAAQ,EACR,IAAI,GACL,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,MAAM,CAAC,wBAAwB,CAAC;IAStC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
|
|
@@ -35,6 +35,20 @@ let AuthService = AuthService_1 = class AuthService {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
async phoneLoginOrCreate(phoneNumber) {
|
|
39
|
+
this.logger.debug('phoneLoginOrCreate');
|
|
40
|
+
return await this.authClient.otps.sms.loginOrCreate({
|
|
41
|
+
phone_number: phoneNumber,
|
|
42
|
+
expiration_minutes: 5,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async phoneAuthenticate({ methodId, code, }) {
|
|
46
|
+
this.logger.debug('phoneAuthenticate');
|
|
47
|
+
return await this.authClient.otps.authenticate({
|
|
48
|
+
method_id: methodId,
|
|
49
|
+
code,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
38
52
|
async delete(externalId) {
|
|
39
53
|
this.logger.debug('delete');
|
|
40
54
|
await this.authClient.users.delete({ user_id: externalId });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,MAAM,M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AAS,EAAE,QAAQ;YACnB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AAvEY,WAAW;IADvB,UAAU,EAAE;qCAKwB,aAAa;GAJrC,WAAW,CAuEvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport * as stytch from 'stytch';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user';\nimport { handleError } from '../utils';\n\n@Injectable()\nexport class AuthService {\n private readonly logger: Logger = new Logger(AuthService.name);\n private authClient: stytch.Client;\n\n constructor(private configService: ConfigService) {\n this.authClient = new stytch.Client({\n project_id: this.configService.get<string>('STYTCH_PROJECT_ID'),\n secret: this.configService.get<string>('STYTCH_SECRET'),\n env:\n this.configService.get<string>('STYTCH_ENV') === 'test'\n ? stytch.envs.test\n : stytch.envs.live,\n });\n }\n\n async signup(\n data: RegisterRequestDto,\n ): Promise<stytch.PasswordsCreateResponse> {\n this.logger.debug('signup');\n\n return await this.authClient.passwords.create(data);\n }\n\n async login(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('login');\n\n try {\n const res = await this.authClient.passwords.authenticate(data);\n return res['status_code'] === 200;\n } catch (error: any) {\n if (error.error_type === 'email_not_found') {\n handleError('Email or password is wrong');\n }\n\n if (error.error_type === 'unauthorized_credentials') {\n handleError('Email or password is wrong');\n }\n }\n }\n\n async phoneLoginOrCreate(\n phoneNumber: string,\n ): Promise<stytch.OTPsSmsLoginOrCreateResponse> {\n this.logger.debug('phoneLoginOrCreate');\n\n return await this.authClient.otps.sms.loginOrCreate({\n phone_number: phoneNumber,\n expiration_minutes: 5,\n });\n }\n\n async phoneAuthenticate({\n methodId,\n code,\n }: {\n methodId: string;\n code: string;\n }): Promise<stytch.OTPsAuthenticateResponse> {\n this.logger.debug('phoneAuthenticate');\n\n return await this.authClient.otps.authenticate({\n method_id: methodId,\n code,\n });\n }\n\n async delete(externalId: string): Promise<void> {\n this.logger.debug('delete');\n\n await this.authClient.users.delete({ user_id: externalId });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-user.request.dto.d.ts","sourceRoot":"/","sources":["user/dtos/delete-user.request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,oBAAoB;IAG/B,
|
|
1
|
+
{"version":3,"file":"delete-user.request.dto.d.ts","sourceRoot":"/","sources":["user/dtos/delete-user.request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,oBAAoB;IAG/B,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-user.request.dto.js","sourceRoot":"/","sources":["user/dtos/delete-user.request.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,oBAAoB;CAIhC;AADC;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;
|
|
1
|
+
{"version":3,"file":"delete-user.request.dto.js","sourceRoot":"/","sources":["user/dtos/delete-user.request.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,oBAAoB;CAIhC;AADC;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;yDACM","sourcesContent":["import { IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\n\nexport class DeleteUserRequestDto {\n @IsString()\n @ApiProperty()\n phoneNumber: string;\n}\n"]}
|
|
@@ -3,4 +3,7 @@ export * from './register.request.dto';
|
|
|
3
3
|
export * from './register.response.dto';
|
|
4
4
|
export * from './update-user.request.dto';
|
|
5
5
|
export * from './delete-user.request.dto';
|
|
6
|
+
export * from './phone-login.request.dto';
|
|
7
|
+
export * from './phone-login-verify.request.dto';
|
|
8
|
+
export * from './phone-login.response.dto';
|
|
6
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["user/dtos/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["user/dtos/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC"}
|
|
@@ -3,4 +3,7 @@ export * from './register.request.dto';
|
|
|
3
3
|
export * from './register.response.dto';
|
|
4
4
|
export * from './update-user.request.dto';
|
|
5
5
|
export * from './delete-user.request.dto';
|
|
6
|
+
export * from './phone-login.request.dto';
|
|
7
|
+
export * from './phone-login-verify.request.dto';
|
|
8
|
+
export * from './phone-login.response.dto';
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["user/dtos/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './get-user.response.dto';\nexport * from './register.request.dto';\nexport * from './register.response.dto';\nexport * from './update-user.request.dto';\nexport * from './delete-user.request.dto';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["user/dtos/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './get-user.response.dto';\nexport * from './register.request.dto';\nexport * from './register.response.dto';\nexport * from './update-user.request.dto';\nexport * from './delete-user.request.dto';\nexport * from './phone-login.request.dto';\nexport * from './phone-login-verify.request.dto';\nexport * from './phone-login.response.dto';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-login-verify.request.dto.d.ts","sourceRoot":"/","sources":["user/dtos/phone-login-verify.request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,0BAA0B;IAGrC,IAAI,EAAE,MAAM,CAAC;IAIb,QAAQ,EAAE,MAAM,CAAC;IAIjB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { IsString } from 'class-validator';
|
|
3
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
4
|
+
export class PhoneLoginVerifyRequestDto {
|
|
5
|
+
}
|
|
6
|
+
__decorate([
|
|
7
|
+
IsString(),
|
|
8
|
+
ApiProperty(),
|
|
9
|
+
__metadata("design:type", String)
|
|
10
|
+
], PhoneLoginVerifyRequestDto.prototype, "code", void 0);
|
|
11
|
+
__decorate([
|
|
12
|
+
IsString(),
|
|
13
|
+
ApiProperty(),
|
|
14
|
+
__metadata("design:type", String)
|
|
15
|
+
], PhoneLoginVerifyRequestDto.prototype, "methodId", void 0);
|
|
16
|
+
__decorate([
|
|
17
|
+
IsString(),
|
|
18
|
+
ApiProperty(),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], PhoneLoginVerifyRequestDto.prototype, "phoneNumber", void 0);
|
|
21
|
+
//# sourceMappingURL=phone-login-verify.request.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-login-verify.request.dto.js","sourceRoot":"/","sources":["user/dtos/phone-login-verify.request.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,0BAA0B;CAYtC;AATC;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;wDACD;AAIb;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;4DACG;AAIjB;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;+DACM","sourcesContent":["import { IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\n\nexport class PhoneLoginVerifyRequestDto {\n @IsString()\n @ApiProperty()\n code: string;\n\n @IsString()\n @ApiProperty()\n methodId: string;\n\n @IsString()\n @ApiProperty()\n phoneNumber: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-login.request.dto.d.ts","sourceRoot":"/","sources":["user/dtos/phone-login.request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,oBAAoB;IAG/B,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { IsString } from 'class-validator';
|
|
3
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
4
|
+
export class PhoneLoginRequestDto {
|
|
5
|
+
}
|
|
6
|
+
__decorate([
|
|
7
|
+
IsString(),
|
|
8
|
+
ApiProperty(),
|
|
9
|
+
__metadata("design:type", String)
|
|
10
|
+
], PhoneLoginRequestDto.prototype, "phoneNumber", void 0);
|
|
11
|
+
//# sourceMappingURL=phone-login.request.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-login.request.dto.js","sourceRoot":"/","sources":["user/dtos/phone-login.request.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,oBAAoB;CAIhC;AADC;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;yDACM","sourcesContent":["import { IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\n\nexport class PhoneLoginRequestDto {\n @IsString()\n @ApiProperty()\n phoneNumber: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-login.response.dto.d.ts","sourceRoot":"/","sources":["user/dtos/phone-login.response.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,qBAAqB;IAGhC,QAAQ,EAAE,MAAM,CAAC;IAIjB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { IsString } from 'class-validator';
|
|
3
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
4
|
+
export class PhoneLoginResponseDto {
|
|
5
|
+
}
|
|
6
|
+
__decorate([
|
|
7
|
+
IsString(),
|
|
8
|
+
ApiProperty(),
|
|
9
|
+
__metadata("design:type", String)
|
|
10
|
+
], PhoneLoginResponseDto.prototype, "methodId", void 0);
|
|
11
|
+
__decorate([
|
|
12
|
+
IsString(),
|
|
13
|
+
ApiProperty(),
|
|
14
|
+
__metadata("design:type", String)
|
|
15
|
+
], PhoneLoginResponseDto.prototype, "phoneNumber", void 0);
|
|
16
|
+
//# sourceMappingURL=phone-login.response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-login.response.dto.js","sourceRoot":"/","sources":["user/dtos/phone-login.response.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,qBAAqB;CAQjC;AALC;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;uDACG;AAIjB;IAFC,QAAQ,EAAE;IACV,WAAW,EAAE;;0DACM","sourcesContent":["import { IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\n\nexport class PhoneLoginResponseDto {\n @IsString()\n @ApiProperty()\n methodId: string;\n\n @IsString()\n @ApiProperty()\n phoneNumber: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-user.request.dto.d.ts","sourceRoot":"/","sources":["user/dtos/update-user.request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,oBAAoB;IAI/B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAKjC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAK9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAK/B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"update-user.request.dto.d.ts","sourceRoot":"/","sources":["user/dtos/update-user.request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,oBAAoB;IAI/B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAKjC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAK9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAK/B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAKxB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B"}
|
|
@@ -27,4 +27,10 @@ __decorate([
|
|
|
27
27
|
ApiProperty(),
|
|
28
28
|
__metadata("design:type", Number)
|
|
29
29
|
], UpdateUserRequestDto.prototype, "tz", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
IsOptional(),
|
|
32
|
+
IsString(),
|
|
33
|
+
ApiProperty(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], UpdateUserRequestDto.prototype, "email", void 0);
|
|
30
36
|
//# sourceMappingURL=update-user.request.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-user.request.dto.js","sourceRoot":"/","sources":["user/dtos/update-user.request.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,oBAAoB;
|
|
1
|
+
{"version":3,"file":"update-user.request.dto.js","sourceRoot":"/","sources":["user/dtos/update-user.request.dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,oBAAoB;CAyBhC;AArBC;IAHC,UAAU,EAAE;IACZ,QAAQ,EAAE;IACV,WAAW,EAAE;;yDACmB;AAKjC;IAHC,UAAU,EAAE;IACZ,QAAQ,EAAE;IACV,WAAW,EAAE;;sDACgB;AAK9B;IAHC,UAAU,EAAE;IACZ,QAAQ,EAAE;IACV,WAAW,EAAE;;uDACiB;AAK/B;IAHC,UAAU,EAAE;IACZ,QAAQ,EAAE;IACV,WAAW,EAAE;;gDACU;AAKxB;IAHC,UAAU,EAAE;IACZ,QAAQ,EAAE;IACV,WAAW,EAAE;;mDACa","sourcesContent":["import { IsNumber, IsOptional, IsString } from 'class-validator';\nimport { ApiProperty } from '@nestjs/swagger';\n\nexport class UpdateUserRequestDto {\n @IsOptional()\n @IsString()\n @ApiProperty()\n phoneNumber?: string | undefined;\n\n @IsOptional()\n @IsString()\n @ApiProperty()\n fullName?: string | undefined;\n\n @IsOptional()\n @IsString()\n @ApiProperty()\n pushToken?: string | undefined;\n\n @IsOptional()\n @IsNumber()\n @ApiProperty()\n tz?: number | undefined;\n\n @IsOptional()\n @IsString()\n @ApiProperty()\n email?: string | undefined;\n}\n"]}
|