Skip to content

Commit ebcaec8

Browse files
Merge pull request #381 from andrechristikan/development
Development
2 parents b1c5d9d + 3ce6f3f commit ebcaec8

File tree

15 files changed

+954
-720
lines changed

15 files changed

+954
-720
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ updates:
77
interval: "monthly"
88
day: tuesday
99
time: "01:00"
10-
open-pull-requests-limit: 5
10+
open-pull-requests-limit: 3
1111
target-branch: "development"
1212
commit-message:
1313
prefix: "npm"
@@ -19,9 +19,9 @@ updates:
1919
interval: "monthly"
2020
day: tuesday
2121
time: "00:00"
22-
open-pull-requests-limit: 5
22+
open-pull-requests-limit: 3
2323
target-branch: "development"
2424
commit-message:
2525
prefix: "github-action"
2626
labels:
27-
- dependabot
27+
- dependabot

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
Next development
6868

69-
* Validation guard change to pipe
69+
* [ ] Validation guard change to pipe
7070
* [ ] SSO
7171
* [ ] Google
7272
* [ ] Apple

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ack-nestjs-boilerplate",
3-
"version": "4.2.6",
3+
"version": "4.3.0",
44
"description": "Ack NestJs Boilerplate",
55
"repository": {
66
"type": "git",
@@ -52,19 +52,19 @@
5252
"rollback": "yarn rollback:setting && yarn rollback:apikey && yarn rollback:user && yarn rollback:role && yarn rollback:permission"
5353
},
5454
"dependencies": {
55-
"@aws-sdk/client-s3": "^3.264.0",
55+
"@aws-sdk/client-s3": "^3.266.0",
5656
"@faker-js/faker": "^7.6.0",
5757
"@joi/date": "^2.1.0",
5858
"@nestjs/axios": "^2.0.0",
59-
"@nestjs/common": "^9.2.1",
59+
"@nestjs/common": "^9.3.3",
6060
"@nestjs/config": "^2.3.0",
61-
"@nestjs/core": "^9.2.1",
61+
"@nestjs/core": "^9.3.3",
6262
"@nestjs/jwt": "^10.0.1",
6363
"@nestjs/mongoose": "^9.2.1",
6464
"@nestjs/passport": "^9.0.1",
65-
"@nestjs/platform-express": "^9.2.1",
65+
"@nestjs/platform-express": "^9.3.3",
6666
"@nestjs/schedule": "^2.2.0",
67-
"@nestjs/swagger": "^6.1.4",
67+
"@nestjs/swagger": "^6.2.1",
6868
"@nestjs/terminus": "^9.2.0",
6969
"@types/response-time": "^2.3.5",
7070
"bcryptjs": "^2.4.3",
@@ -76,7 +76,7 @@
7676
"helmet": "^6.0.1",
7777
"joi": "^17.7.0",
7878
"moment": "^2.29.4",
79-
"mongoose": "^6.9.0",
79+
"mongoose": "^6.9.1",
8080
"morgan": "^1.10.0",
8181
"nest-winston": "^1.8.0",
8282
"nestjs-command": "^3.1.3",
@@ -99,27 +99,27 @@
9999
"devDependencies": {
100100
"@nestjs/cli": "^9.2.0",
101101
"@nestjs/schematics": "^9.0.4",
102-
"@nestjs/testing": "^9.2.1",
102+
"@nestjs/testing": "^9.3.3",
103103
"@types/bcryptjs": "^2.4.2",
104104
"@types/bytes": "^3.1.1",
105105
"@types/cors": "^2.8.13",
106106
"@types/cron": "^2.0.0",
107107
"@types/crypto-js": "^4.1.1",
108-
"@types/express": "^4.17.16",
108+
"@types/express": "^4.17.17",
109109
"@types/express-rate-limit": "^6.0.0",
110110
"@types/jest": "^29.4.0",
111111
"@types/lodash": "^4.14.191",
112112
"@types/morgan": "^1.9.4",
113113
"@types/ms": "^0.7.31",
114114
"@types/multer": "^1.4.7",
115-
"@types/node": "^18.11.18",
115+
"@types/node": "^18.11.19",
116116
"@types/passport-jwt": "^3.0.8",
117117
"@types/supertest": "^2.0.12",
118118
"@types/ua-parser-js": "^0.7.36",
119119
"@types/uuid": "^9.0.0",
120-
"@typescript-eslint/eslint-plugin": "^5.50.0",
121-
"@typescript-eslint/parser": "^5.50.0",
122-
"cspell": "^6.21.0",
120+
"@typescript-eslint/eslint-plugin": "^5.51.0",
121+
"@typescript-eslint/parser": "^5.51.0",
122+
"cspell": "^6.22.0",
123123
"eslint": "^8.33.0",
124124
"eslint-config-prettier": "^8.6.0",
125125
"eslint-plugin-import": "^2.27.5",

src/modules/role/controllers/role.admin.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ export class RoleAdminController {
387387

388388
@RoleAccessForDoc()
389389
@Response('role.accessFor', { serialization: RoleAccessForSerialization })
390-
@RequestParamGuard(RoleRequestDto)
391390
@AuthPermissionProtected(ENUM_AUTH_PERMISSIONS.ROLE_READ)
392391
@AuthJwtAdminAccessProtected()
393392
@Get('/access-for')

src/modules/user/controllers/user.public.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
} from '@nestjs/common';
99
import { ApiTags } from '@nestjs/swagger';
1010
import {
11-
AuthJwtAccessProtected,
1211
AuthJwtPayload,
12+
AuthJwtPublicAccessProtected,
1313
} from 'src/common/auth/decorators/auth.jwt.decorator';
1414
import { AuthService } from 'src/common/auth/services/auth.service';
1515
import { ENUM_ERROR_STATUS_CODE_ERROR } from 'src/common/error/constants/error.status-code.constant';
@@ -100,7 +100,7 @@ export class UserPublicController {
100100

101101
@UserDeleteSelfDoc()
102102
@Response('user.deleteSelf')
103-
@AuthJwtAccessProtected()
103+
@AuthJwtPublicAccessProtected()
104104
@Delete('/delete')
105105
async deleteSelf(@AuthJwtPayload('_id') _id: string): Promise<void> {
106106
try {

src/modules/user/interfaces/user.service.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export interface IUserService {
9595

9696
blocked(_id: string, options?: IDatabaseOptions): Promise<UserEntity>;
9797

98+
unblocked(_id: string, options?: IDatabaseOptions): Promise<UserEntity>;
99+
98100
maxPasswordAttempt(
99101
_id: string,
100102
options?: IDatabaseOptions

src/modules/user/services/user.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,21 @@ export class UserService implements IUserService {
248248
);
249249
}
250250

251+
async unblocked(
252+
_id: string,
253+
options?: IDatabaseOptions
254+
): Promise<UserEntity> {
255+
const dto: UserBlockedDto = new UserBlockedDto();
256+
dto.blocked = false;
257+
dto.blockedDate = undefined;
258+
259+
return this.userRepository.updateOneById<UserBlockedDto>(
260+
_id,
261+
dto,
262+
options
263+
);
264+
}
265+
251266
async maxPasswordAttempt(
252267
_id: string,
253268
options?: IDatabaseOptions

test/e2e/role/role.admin.e2e-spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HttpStatus, INestApplication } from '@nestjs/common';
22
import { Test } from '@nestjs/testing';
33
import request from 'supertest';
44
import {
5+
E2E_ROLE_ACCESS_FOR_URL,
56
E2E_ROLE_ADMIN_ACTIVE_URL,
67
E2E_ROLE_ADMIN_CREATE_URL,
78
E2E_ROLE_ADMIN_DELETE_URL,
@@ -484,4 +485,14 @@ describe('E2E Role Admin', () => {
484485
expect(response.status).toEqual(HttpStatus.OK);
485486
expect(response.body.statusCode).toEqual(HttpStatus.OK);
486487
});
488+
489+
it(`GET ${E2E_ROLE_ACCESS_FOR_URL} Access For Success`, async () => {
490+
const response = await request(app.getHttpServer())
491+
.get(E2E_ROLE_ACCESS_FOR_URL)
492+
.set('Authorization', `Bearer ${accessToken}`)
493+
.set('x-permission-token', permissionToken);
494+
495+
expect(response.status).toEqual(HttpStatus.OK);
496+
expect(response.body.statusCode).toEqual(HttpStatus.OK);
497+
});
487498
});

test/e2e/role/role.constant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export const E2E_ROLE_ADMIN_UPDATE_PERMISSION_URL =
77
export const E2E_ROLE_ADMIN_DELETE_URL = '/admin/role/delete/:_id';
88
export const E2E_ROLE_ADMIN_INACTIVE_URL = '/admin/role/update/:_id/inactive';
99
export const E2E_ROLE_ADMIN_ACTIVE_URL = '/admin/role/update/:_id/active';
10+
export const E2E_ROLE_ACCESS_FOR_URL = '/admin/role/access-for';

test/e2e/user/user.admin.e2e-spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import request from 'supertest';
44
import { faker } from '@faker-js/faker';
55
import {
66
E2E_USER_ADMIN_ACTIVE_URL,
7+
E2E_USER_ADMIN_BLOCKED_URL,
78
E2E_USER_ADMIN_CREATE_URL,
89
E2E_USER_ADMIN_DELETE_URL,
910
E2E_USER_ADMIN_EXPORT_URL,
@@ -398,6 +399,33 @@ describe('E2E User Admin', () => {
398399
);
399400
});
400401

402+
it(`PATCH ${E2E_USER_ADMIN_BLOCKED_URL} Blocked, Not Found`, async () => {
403+
const response = await request(app.getHttpServer())
404+
.patch(
405+
E2E_USER_ADMIN_BLOCKED_URL.replace(
406+
':_id',
407+
`${DatabaseDefaultUUID()}`
408+
)
409+
)
410+
.set('Authorization', `Bearer ${accessToken}`)
411+
.set('x-permission-token', permissionToken);
412+
413+
expect(response.status).toEqual(HttpStatus.NOT_FOUND);
414+
expect(response.body.statusCode).toEqual(
415+
ENUM_USER_STATUS_CODE_ERROR.USER_NOT_FOUND_ERROR
416+
);
417+
});
418+
419+
it(`PATCH ${E2E_USER_ADMIN_BLOCKED_URL} Blocked, success`, async () => {
420+
const response = await request(app.getHttpServer())
421+
.patch(E2E_USER_ADMIN_BLOCKED_URL.replace(':_id', userData._id))
422+
.set('Authorization', `Bearer ${accessToken}`)
423+
.set('x-permission-token', permissionToken);
424+
425+
expect(response.status).toEqual(HttpStatus.OK);
426+
expect(response.body.statusCode).toEqual(HttpStatus.OK);
427+
});
428+
401429
it(`DELETE ${E2E_USER_ADMIN_DELETE_URL} Delete, Not Found`, async () => {
402430
const response = await request(app.getHttpServer())
403431
.delete(

0 commit comments

Comments
 (0)