Browse Source

fix conflicts

merge-requests/74/head
D-Klimishen 3 years ago
parent
commit
5bb53e4a8b
  1. 87
      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. 29
      src/rest/admin/sessions/controllers/admin-sessions.controller.ts
  6. 6
      src/rest/admin/sessions/dto/get-user-sessions-params.dto.ts
  7. 2
      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

87
README.md

@ -1,75 +1,52 @@ @@ -1,75 +1,52 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
# Task Me Api
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[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
Version: 2.0 Beta
<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
### Requires
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
The following software must be installed on the system to run the project
## Installation
- Docker 20.10.2 +
- Docker-compose 1.28.0 +
- Node.js 14.0.0 +
- npm 8.0.0 +
```bash
$ npm install
```
---
## Running the app
### Setting project
```bash
# development
$ npm run start
Create .env file from .env.example
# watch mode
$ npm run start:dev
`cp .env .env.example`
# production mode
$ npm run start:prod
```
Change configuration params
## Test
`nano .env`
```bash
# unit tests
$ npm run test
Install dependencies
# e2e tests
$ npm run test:e2e
`npm install`
# test coverage
$ npm run test:cov
```
---
## Support
### Start project local
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).
Build `npm run start`
## Stay in touch
Start `docker-compose up`
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
### Run project stage/dev
## License
Build
`npm run build`
Nest is [MIT licensed](LICENSE).
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 @@ @@ -8811,6 +8811,7 @@
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"devOptional": true,
"dependencies": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
@ -8831,6 +8832,7 @@ @@ -8831,6 +8832,7 @@
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"devOptional": true,
"engines": {
"node": ">=0.10.0"
}
@ -13193,7 +13195,8 @@ @@ -13193,7 +13195,8 @@
"node_modules/neo-async": {
"version": "2.6.2",
"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": {
"version": "2.0.2",
@ -18197,6 +18200,7 @@ @@ -18197,6 +18200,7 @@
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz",
"integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==",
"dev": true,
"optional": true,
"bin": {
"uglifyjs": "bin/uglifyjs"
@ -18809,7 +18813,8 @@ @@ -18809,7 +18813,8 @@
"node_modules/wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"devOptional": true
},
"node_modules/wrap-ansi": {
"version": "6.2.0",
@ -25962,6 +25967,7 @@ @@ -25962,6 +25967,7 @@
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"devOptional": true,
"requires": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
@ -25973,7 +25979,8 @@ @@ -25973,7 +25979,8 @@
"source-map": {
"version": "0.6.1",
"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 @@ @@ -29488,7 +29495,8 @@
"neo-async": {
"version": "2.6.2",
"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": {
"version": "2.0.2",
@ -33385,6 +33393,7 @@ @@ -33385,6 +33393,7 @@
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz",
"integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==",
"dev": true,
"optional": true
},
"uid2": {
@ -33863,7 +33872,8 @@ @@ -33863,7 +33872,8 @@
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"devOptional": true
},
"wrap-ansi": {
"version": "6.2.0",

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

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

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

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

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

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

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

@ -1 +1,3 @@ @@ -1 +1,3 @@
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 @@ @@ -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 @@ @@ -1,17 +1,19 @@
import { BadRequestException } from "@nestjs/common"
import { Inject, Injectable } from '@nestjs/common'
import { throwError } from "rxjs"
import { Sessions } from 'src/core'
import { SESSIONS_SERVICE } from 'src/core/consts'
import { GetUserSessionsParamsDto } from '../dto'
@Injectable()
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) {
if (!userId) throw new BadRequestException('userId is required')
const res = await this.sessionsService.getByUserId(userId)
if (!res[0]) throw new BadRequestException('Not found sessions by id')
return res
public async getUserSessions(dto: GetUserSessionsParamsDto) {
return await this.sessionsService.getByUserId(dto.userId)
}
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' @@ -4,16 +4,8 @@ import { PermissionsModule, SessionsModule } from 'src/domain'
/** IMPORTANT FULL PART */
import { UsersModule } from 'src/domain/users/users.module'
import { JwtModule } from 'src/libs'
import {
AdminUsersController,
AdminUsersFactoriesController,
AdminUsersSessionsController,
} from './controllers'
import {
AdminUsersService,
AdminUsersFactoriesService,
AdminUsersSessionsService,
} from './services'
import { AdminUsersController, AdminUsersFactoriesController } from './controllers'
import { AdminUsersService, AdminUsersFactoriesService } from './services'
@Module({})
export class AdminUsersModule {
@ -26,12 +18,8 @@ export class AdminUsersModule { @@ -26,12 +18,8 @@ export class AdminUsersModule {
JwtModule.forFeature(),
PermissionsModule.forFeature(),
],
providers: [AdminUsersService, AdminUsersFactoriesService, AdminUsersSessionsService],
controllers: [
AdminUsersController,
AdminUsersFactoriesController,
AdminUsersSessionsController,
],
providers: [AdminUsersService, AdminUsersFactoriesService],
controllers: [AdminUsersController, AdminUsersFactoriesController],
}
}
}

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

@ -1,17 +0,0 @@ @@ -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 @@ @@ -1,3 +1,2 @@
export * from './admin-users.controller'
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 { @@ -54,7 +54,6 @@ export class AppAccountsController {
@Patch()
public async update(@ReqUser() id: number, @Body() dto: UpdateAccountDto) {
const user = await this.accountsService.update(id, dto)
console.log(user, plainToClass(GetAccountDto, user))
return plainToClass(GetAccountDto, user)
}

Loading…
Cancel
Save