diff --git a/package.json b/package.json index e2bf874d..ee78b186 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ultimate-nest-template", - "version": "1.4.5", + "version": "1.5.0", "description": "NestJS + MikroORM realworld API example", "license": "MIT", "repository": "https://github.com/rubiin/ultimate-nest", diff --git a/src/entities/user.entity.ts b/src/entities/user.entity.ts index 802f46d9..a5d69fb0 100644 --- a/src/entities/user.entity.ts +++ b/src/entities/user.entity.ts @@ -53,7 +53,7 @@ export class User extends BaseEntity { this.password = await HelperService.hashString(this.password); } - @OneToMany(() => Post, post => post.author, { hidden: true }) + @OneToMany(() => Post, post => post.author) posts = new Collection(this); @ManyToMany({ hidden: true }) @@ -70,7 +70,7 @@ export class User extends BaseEntity { }) followers = new Collection(this); - @ManyToMany(() => User, u => u.followers, { hidden: true }) + @ManyToMany(() => User, u => u.followers) followed = new Collection(this); toJSON() { diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index 011d71c2..589de038 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -111,11 +111,4 @@ export class AuthController { ? this.authService.logoutFromAll(user) : this.authService.logout(user, refreshToken.refreshToken); } - - @ApiOperation({ summary: "User profile" }) - @Auth() - @Get("profile") - profile(@LoggedInUser() user: UserEntity) { - return user; - } } diff --git a/src/modules/user/user.service.ts b/src/modules/user/user.service.ts index a49b4e29..cc11da81 100644 --- a/src/modules/user/user.service.ts +++ b/src/modules/user/user.service.ts @@ -108,16 +108,20 @@ export class UserService { await em.persistAndFlush(user); - await this.amqpConnection.publish("nestify", "send-mail", { - template: EmailTemplateEnum.WELCOME_TEMPLATE, - replacements: { - firstName: capitalize(user.firstName), - link: "example.com", + await this.amqpConnection.publish( + this.configService.get("rabbit.exchange"), + "send-mail", + { + template: EmailTemplateEnum.WELCOME_TEMPLATE, + replacements: { + firstName: capitalize(user.firstName), + link: "example.com", + }, + to: user.email, + subject: "Welcome onboard", + from: this.configService.get("mail.senderEmail"), }, - to: user.email, - subject: "Welcome onboard", - from: this.configService.get("mail.senderEmail"), - }); + ); }); return user; diff --git a/temp/ActivityLog.js.json b/temp/ActivityLog.js.json new file mode 100644 index 00000000..fef2ac45 --- /dev/null +++ b/temp/ActivityLog.js.json @@ -0,0 +1,43 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "activityType": { "name": "activityType", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + "loginType": { "name": "loginType", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + "ipAddress": { "name": "ipAddress", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + "deviceId": { "name": "deviceId", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + "status": { "name": "status", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + "loginStatus": { "name": "loginStatus", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + "user": { "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false } + }, + "props": [ + { "name": "activityType", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + { "name": "loginType", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + { "name": "ipAddress", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + { "name": "deviceId", "reference": "scalar", "length": 50, "getter": false, "setter": false, "type": "string", "nullable": true }, + { "name": "status", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + { "name": "loginStatus", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + { "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false } + ], + "primaryKeys": [], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "ActivityLog", + "path": "./dist/entities/activity-log.entity.js", + "name": "ActivityLog", + "abstract": false, + "constructorParams": [], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [{ "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }], + "collection": "activity_log" + }, + "origin": "./dist/entities/activity-log.entity.js", + "hash": "119c1e9dca7e0d9cc073c77349e93a66", + "version": "5.1.3" +} diff --git a/temp/BaseEntity.js.json b/temp/BaseEntity.js.json new file mode 100644 index 00000000..d05857fd --- /dev/null +++ b/temp/BaseEntity.js.json @@ -0,0 +1,41 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "id": { "name": "id", "reference": "scalar", "primary": true, "hidden": true, "type": "number" }, + "idx": { "name": "idx", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "isActive": { "name": "isActive", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + "isObsolete": { "name": "isObsolete", "reference": "scalar", "hidden": true, "getter": false, "setter": false, "type": "boolean" }, + "deletedAt": { "name": "deletedAt", "reference": "scalar", "getter": false, "setter": false, "type": "Date", "nullable": true }, + "createdAt": { "name": "createdAt", "reference": "scalar", "getter": false, "setter": false, "type": "Date" }, + "updatedAt": { "name": "updatedAt", "reference": "scalar", "hidden": true, "getter": false, "setter": false, "type": "Date", "nullable": true } + }, + "props": [ + { "name": "id", "reference": "scalar", "primary": true, "hidden": true, "type": "number" }, + { "name": "idx", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "isActive", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + { "name": "isObsolete", "reference": "scalar", "hidden": true, "getter": false, "setter": false, "type": "boolean" }, + { "name": "deletedAt", "reference": "scalar", "getter": false, "setter": false, "type": "Date", "nullable": true }, + { "name": "createdAt", "reference": "scalar", "getter": false, "setter": false, "type": "Date" }, + { "name": "updatedAt", "reference": "scalar", "hidden": true, "getter": false, "setter": false, "type": "Date", "nullable": true } + ], + "primaryKeys": ["id"], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "BaseEntity", + "path": "./dist/common/database/base-entity.entity.js", + "abstract": true, + "constructorParams": [], + "toJsonParams": [], + "useCache": true, + "compositePK": false, + "relations": [] + }, + "origin": "./dist/common/database/base-entity.entity.js", + "hash": "99e78948829038cbac77d4fb363a4c51", + "version": "5.1.3" +} diff --git a/temp/Comment.js.json b/temp/Comment.js.json new file mode 100644 index 00000000..d41ab36e --- /dev/null +++ b/temp/Comment.js.json @@ -0,0 +1,38 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "body": { "name": "body", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "post": { "name": "post", "reference": "m:1", "cascade": ["persist"], "type": "Post", "nullable": false }, + "author": { "name": "author", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false } + }, + "props": [ + { "name": "body", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "post", "reference": "m:1", "cascade": ["persist"], "type": "Post", "nullable": false }, + { "name": "author", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false } + ], + "primaryKeys": [], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "Comment", + "path": "./dist/entities/comment.entity.js", + "name": "Comment", + "abstract": false, + "constructorParams": ["author", "post", "body"], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [ + { "name": "post", "reference": "m:1", "cascade": ["persist"], "type": "Post", "nullable": false }, + { "name": "author", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false } + ], + "collection": "comment" + }, + "origin": "./dist/entities/comment.entity.js", + "hash": "45a0c9cab4433cf9bb3ec3b4ddd16ea8", + "version": "5.1.3" +} diff --git a/temp/OtpLog.js.json b/temp/OtpLog.js.json new file mode 100644 index 00000000..9a45c1e1 --- /dev/null +++ b/temp/OtpLog.js.json @@ -0,0 +1,37 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "expiresIn": { "name": "expiresIn", "reference": "scalar", "getter": false, "setter": false, "type": "Date" }, + "otpCode": { "name": "otpCode", "reference": "scalar", "length": 20, "getter": false, "setter": false, "type": "string", "nullable": true }, + "user": { "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }, + "isUsed": { "name": "isUsed", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" } + }, + "props": [ + { "name": "expiresIn", "reference": "scalar", "getter": false, "setter": false, "type": "Date" }, + { "name": "otpCode", "reference": "scalar", "length": 20, "getter": false, "setter": false, "type": "string", "nullable": true }, + { "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }, + { "name": "isUsed", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" } + ], + "primaryKeys": [], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "OtpLog", + "path": "./dist/entities/otp-log.entity.js", + "name": "OtpLog", + "abstract": false, + "constructorParams": [], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [{ "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }], + "collection": "otp_log" + }, + "origin": "./dist/entities/otp-log.entity.js", + "hash": "654243168518b0d960b84dfc4e887bdf", + "version": "5.1.3" +} diff --git a/temp/Post.js.json b/temp/Post.js.json new file mode 100644 index 00000000..68fbace4 --- /dev/null +++ b/temp/Post.js.json @@ -0,0 +1,48 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "slug": { "name": "slug", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "title": { "name": "title", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "description": { "name": "description", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "content": { "name": "content", "reference": "scalar", "type": "text", "getter": false, "setter": false }, + "tags": { "name": "tags", "reference": "scalar", "getter": false, "setter": false, "array": true }, + "author": { "name": "author", "reference": "m:1", "cascade": ["persist"], "eager": false, "type": "User", "nullable": false }, + "comments": { "name": "comments", "reference": "1:m", "cascade": ["persist"], "eager": false, "orphanRemoval": true, "type": "Comment" }, + "favoritesCount": { "name": "favoritesCount", "reference": "scalar", "getter": false, "setter": false, "type": "number" } + }, + "props": [ + { "name": "slug", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "title", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "description", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "content", "reference": "scalar", "type": "text", "getter": false, "setter": false }, + { "name": "tags", "reference": "scalar", "getter": false, "setter": false, "array": true }, + { "name": "author", "reference": "m:1", "cascade": ["persist"], "eager": false, "type": "User", "nullable": false }, + { "name": "comments", "reference": "1:m", "cascade": ["persist"], "eager": false, "orphanRemoval": true, "type": "Comment" }, + { "name": "favoritesCount", "reference": "scalar", "getter": false, "setter": false, "type": "number" } + ], + "primaryKeys": [], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "Post", + "path": "./dist/entities/post.entity.js", + "name": "Post", + "abstract": false, + "constructorParams": ["author", "title", "description", "body"], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [ + { "name": "author", "reference": "m:1", "cascade": ["persist"], "eager": false, "type": "User", "nullable": false }, + { "name": "comments", "reference": "1:m", "cascade": ["persist"], "eager": false, "orphanRemoval": true, "type": "Comment" } + ], + "collection": "post" + }, + "origin": "./dist/entities/post.entity.js", + "hash": "7ee92987abab980f7abddc5cc9c54ae2", + "version": "5.1.3" +} diff --git a/temp/Protocol.js.json b/temp/Protocol.js.json new file mode 100644 index 00000000..fbb0bbfd --- /dev/null +++ b/temp/Protocol.js.json @@ -0,0 +1,43 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "loginAttemptnumbererval": { "name": "loginAttemptnumbererval", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + "loginnumberervalUnit": { "name": "loginnumberervalUnit", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "loginMaxRetry": { "name": "loginMaxRetry", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + "otpExpiryInMinutes": { "name": "otpExpiryInMinutes", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + "mpinAttemptInterval": { "name": "mpinAttemptInterval", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + "mpinIntervalUnit": { "name": "mpinIntervalUnit", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + "mpinMaxRetry": { "name": "mpinMaxRetry", "reference": "scalar", "getter": false, "setter": false, "type": "number" } + }, + "props": [ + { "name": "loginAttemptnumbererval", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + { "name": "loginnumberervalUnit", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "loginMaxRetry", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + { "name": "otpExpiryInMinutes", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + { "name": "mpinAttemptInterval", "reference": "scalar", "getter": false, "setter": false, "type": "number" }, + { "name": "mpinIntervalUnit", "reference": "scalar", "getter": false, "setter": false, "type": "string" }, + { "name": "mpinMaxRetry", "reference": "scalar", "getter": false, "setter": false, "type": "number" } + ], + "primaryKeys": [], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "Protocol", + "path": "./dist/entities/protocol.entity.js", + "name": "Protocol", + "abstract": false, + "constructorParams": [], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [], + "collection": "protocol" + }, + "origin": "./dist/entities/protocol.entity.js", + "hash": "a65f8797a631a4085829a9788a9c429b", + "version": "5.1.3" +} diff --git a/temp/RefreshToken.js.json b/temp/RefreshToken.js.json new file mode 100644 index 00000000..c331ca86 --- /dev/null +++ b/temp/RefreshToken.js.json @@ -0,0 +1,35 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "expiresIn": { "name": "expiresIn", "reference": "scalar", "getter": false, "setter": false, "type": "Date" }, + "user": { "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }, + "isRevoked": { "name": "isRevoked", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" } + }, + "props": [ + { "name": "expiresIn", "reference": "scalar", "getter": false, "setter": false, "type": "Date" }, + { "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }, + { "name": "isRevoked", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" } + ], + "primaryKeys": [], + "filters": {}, + "hooks": {}, + "indexes": [], + "uniques": [], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "RefreshToken", + "path": "./dist/entities/refresh-token.entity.js", + "name": "RefreshToken", + "abstract": false, + "constructorParams": [], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [{ "name": "user", "reference": "m:1", "cascade": ["persist"], "type": "User", "nullable": false }], + "collection": "refresh_token" + }, + "origin": "./dist/entities/refresh-token.entity.js", + "hash": "e7be13281e33735088740e789e602817", + "version": "5.1.3" +} diff --git a/temp/User.js.json b/temp/User.js.json new file mode 100644 index 00000000..c606c3e5 --- /dev/null +++ b/temp/User.js.json @@ -0,0 +1,102 @@ +{ + "data": { + "propertyOrder": {}, + "properties": { + "firstName": { "name": "firstName", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + "lastName": { "name": "lastName", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + "username": { "name": "username", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + "email": { "name": "email", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + "avatar": { "name": "avatar", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + "password": { "name": "password", "reference": "scalar", "hidden": true, "getter": false, "setter": false, "type": "string" }, + "roles": { + "name": "roles", + "reference": "scalar", + "enum": false, + "items": ["AUTHOR", "ADMIN", "READER"], + "array": true, + "default": ["AUTHOR"], + "type": "AppRoles", + "customType": "customType" + }, + "mobileNumber": { "name": "mobileNumber", "reference": "scalar", "getter": false, "setter": false, "type": "string", "nullable": true }, + "isVerified": { "name": "isVerified", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + "posts": { "name": "posts", "reference": "1:m", "cascade": ["persist"], "type": "Post" }, + "favorites": { "name": "favorites", "reference": "m:n", "cascade": ["persist"], "hidden": true, "type": "Post", "fixedOrder": false, "owner": true }, + "followers": { + "name": "followers", + "reference": "m:n", + "cascade": ["persist"], + "owner": true, + "pivotTable": "user_to_follower", + "hidden": true, + "type": "User", + "fixedOrder": false, + "joinColumns": ["follower"], + "inverseJoinColumns": ["following"] + }, + "followed": { "name": "followed", "reference": "m:n", "cascade": ["persist"], "type": "User", "fixedOrder": false } + }, + "props": [ + { "name": "firstName", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + { "name": "lastName", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + { "name": "username", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + { "name": "email", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + { "name": "avatar", "reference": "scalar", "length": 255, "getter": false, "setter": false, "type": "string" }, + { "name": "password", "reference": "scalar", "hidden": true, "getter": false, "setter": false, "type": "string" }, + { "name": "roles", "reference": "scalar", "enum": false, "items": ["AUTHOR", "ADMIN", "READER"], "array": true, "default": ["AUTHOR"], "type": "AppRoles", "customType": "customType" }, + { "name": "mobileNumber", "reference": "scalar", "getter": false, "setter": false, "type": "string", "nullable": true }, + { "name": "isVerified", "reference": "scalar", "getter": false, "setter": false, "type": "boolean" }, + { "name": "posts", "reference": "1:m", "cascade": ["persist"], "type": "Post" }, + { "name": "favorites", "reference": "m:n", "cascade": ["persist"], "hidden": true, "type": "Post", "fixedOrder": false, "owner": true }, + { + "name": "followers", + "reference": "m:n", + "cascade": ["persist"], + "owner": true, + "pivotTable": "user_to_follower", + "hidden": true, + "type": "User", + "fixedOrder": false, + "joinColumns": ["follower"], + "inverseJoinColumns": ["following"] + }, + { "name": "followed", "reference": "m:n", "cascade": ["persist"], "type": "User", "fixedOrder": false } + ], + "primaryKeys": [], + "filters": {}, + "hooks": { "beforeUpdate": ["hashPassword"], "beforeCreate": ["hashPassword"] }, + "indexes": [], + "uniques": [{ "properties": "username" }, { "properties": "email" }, { "properties": "mobileNumber" }], + "checks": [], + "concurrencyCheckKeys": {}, + "className": "User", + "path": "./dist/entities/user.entity.js", + "name": "User", + "abstract": false, + "constructorParams": [], + "toJsonParams": [], + "extends": "BaseEntity", + "useCache": true, + "relations": [ + { "name": "posts", "reference": "1:m", "cascade": ["persist"], "type": "Post" }, + { "name": "favorites", "reference": "m:n", "cascade": ["persist"], "hidden": true, "type": "Post", "fixedOrder": false, "owner": true }, + { + "name": "followers", + "reference": "m:n", + "cascade": ["persist"], + "owner": true, + "pivotTable": "user_to_follower", + "hidden": true, + "type": "User", + "fixedOrder": false, + "joinColumns": ["follower"], + "inverseJoinColumns": ["following"] + }, + { "name": "followed", "reference": "m:n", "cascade": ["persist"], "type": "User", "fixedOrder": false } + ], + "collection": "user" + }, + "origin": "./dist/entities/user.entity.js", + "hash": "365c396c1ada7c4488b69c9277354c72", + "version": "5.1.3" +}