Browse Source

fix conflicts

merge-requests/74/head
D-Klimishen 3 years ago
parent
commit
5bb53e4a8b
  1. 89
      README.md
  2. 20
      package-lock.json
  3. 3
      src/domain/mailer/mailer.module.ts
  4. 10
      src/rest/admin/sessions/admin-sessions.module.ts
  5. 31
      src/rest/admin/sessions/controllers/admin-sessions.controller.ts
  6. 6
      src/rest/admin/sessions/dto/get-user-sessions-params.dto.ts
  7. 4
      src/rest/admin/sessions/dto/index.ts
  8. 6
      src/rest/admin/sessions/dto/stop-sessions-params.dto.ts
  9. 18
      src/rest/admin/sessions/services/admin-sessions.service.ts
  10. 20
      src/rest/admin/users/admin-users.module.ts
  11. 17
      src/rest/admin/users/controllers/admin-users-sessions.controller.ts
  12. 1
      src/rest/admin/users/controllers/index.ts
  13. 1
      src/rest/app/account/controllers/app-accounts.controller.ts

89
README.md

@ -1,75 +1,52 @@
<p align="center"> # Task Me Api
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master Version: 2.0 Beta
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description ---
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. ### Requires
## Installation The following software must be installed on the system to run the project
```bash - Docker 20.10.2 +
$ npm install - Docker-compose 1.28.0 +
``` - Node.js 14.0.0 +
- npm 8.0.0 +
## Running the app ---
```bash ### Setting project
# development
$ npm run start
# watch mode Create .env file from .env.example
$ npm run start:dev
# production mode `cp .env .env.example`
$ npm run start:prod
```
## Test Change configuration params
```bash `nano .env`
# unit tests
$ npm run test
# e2e tests Install dependencies
$ npm run test:e2e
# test coverage `npm install`
$ npm run test:cov
```
## Support ---
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). ### Start project local
## Stay in touch Build `npm run start`
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) Start `docker-compose up`
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License ### Run project stage/dev
Nest is [MIT licensed](LICENSE). Build
`npm run build`
Start
`docker-compose -f docker-compose.stage up -d`
Restart
`docker-compose restart`
Stop
`docker-compose stop`

20
package-lock.json generated

@ -8811,6 +8811,7 @@
"version": "4.7.7", "version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"devOptional": true,
"dependencies": { "dependencies": {
"minimist": "^1.2.5", "minimist": "^1.2.5",
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
@ -8831,6 +8832,7 @@
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"devOptional": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@ -13193,7 +13195,8 @@
"node_modules/neo-async": { "node_modules/neo-async": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"devOptional": true
}, },
"node_modules/netmask": { "node_modules/netmask": {
"version": "2.0.2", "version": "2.0.2",
@ -18197,6 +18200,7 @@
"version": "3.14.1", "version": "3.14.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz",
"integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==", "integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==",
"dev": true,
"optional": true, "optional": true,
"bin": { "bin": {
"uglifyjs": "bin/uglifyjs" "uglifyjs": "bin/uglifyjs"
@ -18809,7 +18813,8 @@
"node_modules/wordwrap": { "node_modules/wordwrap": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"devOptional": true
}, },
"node_modules/wrap-ansi": { "node_modules/wrap-ansi": {
"version": "6.2.0", "version": "6.2.0",
@ -25962,6 +25967,7 @@
"version": "4.7.7", "version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"devOptional": true,
"requires": { "requires": {
"minimist": "^1.2.5", "minimist": "^1.2.5",
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
@ -25973,7 +25979,8 @@
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"devOptional": true
} }
} }
}, },
@ -29488,7 +29495,8 @@
"neo-async": { "neo-async": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"devOptional": true
}, },
"netmask": { "netmask": {
"version": "2.0.2", "version": "2.0.2",
@ -33385,6 +33393,7 @@
"version": "3.14.1", "version": "3.14.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz",
"integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==", "integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==",
"dev": true,
"optional": true "optional": true
}, },
"uid2": { "uid2": {
@ -33863,7 +33872,8 @@
"wordwrap": { "wordwrap": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"devOptional": true
}, },
"wrap-ansi": { "wrap-ansi": {
"version": "6.2.0", "version": "6.2.0",

3
src/domain/mailer/mailer.module.ts

@ -15,7 +15,6 @@ export class MailerModule {
static getImports() { static getImports() {
const { options } = MailerModule const { options } = MailerModule
console.log(options)
if (options.test) return [] if (options.test) return []
return [ return [
@ -30,7 +29,7 @@ export class MailerModule {
}, },
}, },
defaults: { defaults: {
from: '"nest-modules" <modules@nestjs.com>', from: options.login,
}, },
}), }),
] ]

10
src/rest/admin/sessions/admin-sessions.module.ts

@ -1,7 +1,7 @@
import { DynamicModule, Module } from '@nestjs/common' import { DynamicModule, Module } from '@nestjs/common'
import { SessionsModule } from 'src/domain' import { PermissionsModule, SessionsModule } from 'src/domain'
import { JwtModule } from "src/libs" import { JwtModule } from 'src/libs'
import { AdminSessionsController } from './controllers' import { AdminSessionsController } from './controllers'
import { AdminSessionsService } from './services' import { AdminSessionsService } from './services'
@ -10,7 +10,11 @@ export class AdminSessionsModule {
static forRoot(): DynamicModule { static forRoot(): DynamicModule {
return { return {
module: AdminSessionsModule, module: AdminSessionsModule,
imports: [SessionsModule.forFeature(), JwtModule.forFeature()], imports: [
SessionsModule.forFeature(),
JwtModule.forFeature(),
PermissionsModule.forFeature(),
],
providers: [AdminSessionsService], providers: [AdminSessionsService],
controllers: [AdminSessionsController], controllers: [AdminSessionsController],
} }

31
src/rest/admin/sessions/controllers/admin-sessions.controller.ts

@ -1,21 +1,32 @@
import { Controller, Get, Param } from '@nestjs/common' import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common'
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger' import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
import { Users } from "src/core" import { Users } from 'src/core'
import { RoleGuard } from "src/domain/sessions/decorators" import { RoleGuard } from 'src/domain/sessions/decorators'
import { GetUserSessionsResDto } from "../dto" import { PermissionsTabsGuard } from 'src/shared'
import { GetUserSessionsParamsDto, GetUserSessionsResDto, StopSessionsParamsDto } from '../dto'
import { AdminSessionsService } from '../services' import { AdminSessionsService } from '../services'
@ApiTags('Admin | Sessions') @ApiTags('Admin | Sessions')
@Controller('admin/sessions') @Controller('admin/sessions')
export class AdminSessionsController { export class AdminSessionsController {
constructor(private readonly adminSessionsService: AdminSessionsService) { } constructor(private readonly adminSessionsService: AdminSessionsService) {}
@ApiOperation({ summary: 'Список активних сесій користувача' }) @ApiOperation({ summary: 'Список активних сесій користувача' })
@ApiResponse({ status: 200, description: 'Список активних сесій', type: [GetUserSessionsResDto] }) @ApiResponse({
status: 200,
description: 'Список активних сесій',
type: [GetUserSessionsResDto],
})
@RoleGuard(Users.Role.Admin) @RoleGuard(Users.Role.Admin)
@Get('/:userId') @Get('/')
public async getUserSessions(@Param('userId') userId: number) { public async getUserSessions(@Query() dto: GetUserSessionsParamsDto) {
return await this.adminSessionsService.getUserSessionsList(userId) return await this.adminSessionsService.getUserSessions(dto)
}
@ApiOperation({ summary: 'Зупинка сесії' })
@PermissionsTabsGuard('user', 'logout')
@Post('/stop')
public async stopUsersSessions(@Body() dto: StopSessionsParamsDto) {
return await this.adminSessionsService.stopUsersSessions(dto.userId)
} }
} }

6
src/rest/admin/sessions/dto/get-user-sessions-params.dto.ts

@ -0,0 +1,6 @@
import { DtoProperty } from 'src/shared'
export class GetUserSessionsParamsDto {
@DtoProperty()
userId: number
}

4
src/rest/admin/sessions/dto/index.ts

@ -1 +1,3 @@
export * from './get-user-sessions.dto' export * from './get-user-sessions.dto'
export * from './stop-sessions-params.dto'
export * from './get-user-sessions-params.dto'

6
src/rest/admin/sessions/dto/stop-sessions-params.dto.ts

@ -0,0 +1,6 @@
import { DtoProperty } from 'src/shared'
export class StopSessionsParamsDto {
@DtoProperty()
userId: number
}

18
src/rest/admin/sessions/services/admin-sessions.service.ts

@ -1,17 +1,19 @@
import { BadRequestException } from "@nestjs/common"
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { throwError } from "rxjs"
import { Sessions } from 'src/core' import { Sessions } from 'src/core'
import { SESSIONS_SERVICE } from 'src/core/consts' import { SESSIONS_SERVICE } from 'src/core/consts'
import { GetUserSessionsParamsDto } from '../dto'
@Injectable() @Injectable()
export class AdminSessionsService { export class AdminSessionsService {
constructor(@Inject(SESSIONS_SERVICE) private readonly sessionsService: Sessions.ISessionsService) { } constructor(
@Inject(SESSIONS_SERVICE) private readonly sessionsService: Sessions.ISessionsService,
) {}
public async getUserSessionsList(userId: number) { public async getUserSessions(dto: GetUserSessionsParamsDto) {
if (!userId) throw new BadRequestException('userId is required') return await this.sessionsService.getByUserId(dto.userId)
const res = await this.sessionsService.getByUserId(userId) }
if (!res[0]) throw new BadRequestException('Not found sessions by id')
return res public async stopUsersSessions(userId: number) {
await this.sessionsService.closeAllUserSessions(userId)
} }
} }

20
src/rest/admin/users/admin-users.module.ts

@ -4,16 +4,8 @@ import { PermissionsModule, SessionsModule } from 'src/domain'
/** IMPORTANT FULL PART */ /** IMPORTANT FULL PART */
import { UsersModule } from 'src/domain/users/users.module' import { UsersModule } from 'src/domain/users/users.module'
import { JwtModule } from 'src/libs' import { JwtModule } from 'src/libs'
import { import { AdminUsersController, AdminUsersFactoriesController } from './controllers'
AdminUsersController, import { AdminUsersService, AdminUsersFactoriesService } from './services'
AdminUsersFactoriesController,
AdminUsersSessionsController,
} from './controllers'
import {
AdminUsersService,
AdminUsersFactoriesService,
AdminUsersSessionsService,
} from './services'
@Module({}) @Module({})
export class AdminUsersModule { export class AdminUsersModule {
@ -26,12 +18,8 @@ export class AdminUsersModule {
JwtModule.forFeature(), JwtModule.forFeature(),
PermissionsModule.forFeature(), PermissionsModule.forFeature(),
], ],
providers: [AdminUsersService, AdminUsersFactoriesService, AdminUsersSessionsService], providers: [AdminUsersService, AdminUsersFactoriesService],
controllers: [ controllers: [AdminUsersController, AdminUsersFactoriesController],
AdminUsersController,
AdminUsersFactoriesController,
AdminUsersSessionsController,
],
} }
} }
} }

17
src/rest/admin/users/controllers/admin-users-sessions.controller.ts

@ -1,17 +0,0 @@
import { Controller, Param, Post } from '@nestjs/common'
import { ApiOperation, ApiTags } from '@nestjs/swagger'
import { PermissionsTabsGuard, ReqUser } from 'src/shared'
import { AdminUsersSessionsService } from '../services'
@ApiTags('Admin | Users Sessions')
@Controller('admin/users/sessions')
export class AdminUsersSessionsController {
constructor(private readonly adminUsersSessionsService: AdminUsersSessionsService) {}
@ApiOperation({ summary: 'Розлогінення користувача' })
@PermissionsTabsGuard('user', 'logout')
@Post('stop/:id')
public async stopUsersSessions(@Param('id') id: number) {
return await this.adminUsersSessionsService.stopUsersSessions(id)
}
}

1
src/rest/admin/users/controllers/index.ts

@ -1,3 +1,2 @@
export * from './admin-users.controller' export * from './admin-users.controller'
export * from './admin-users-factories.controllers' export * from './admin-users-factories.controllers'
export * from './admin-users-sessions.controller'

1
src/rest/app/account/controllers/app-accounts.controller.ts

@ -54,7 +54,6 @@ export class AppAccountsController {
@Patch() @Patch()
public async update(@ReqUser() id: number, @Body() dto: UpdateAccountDto) { public async update(@ReqUser() id: number, @Body() dto: UpdateAccountDto) {
const user = await this.accountsService.update(id, dto) const user = await this.accountsService.update(id, dto)
console.log(user, plainToClass(GetAccountDto, user))
return plainToClass(GetAccountDto, user) return plainToClass(GetAccountDto, user)
} }

Loading…
Cancel
Save