@boarteam/boar-pack-users-backend 5.1.1 → 5.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boarteam/boar-pack-users-backend",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "NestJS Users module including permissions system, authentication strategies etc",
5
5
  "main": "src/index",
6
6
  "files": [
@@ -43,6 +43,7 @@
43
43
  "ws": "^8.16.0"
44
44
  },
45
45
  "devDependencies": {
46
+ "@nestjs/platform-express": "^10.4.15",
46
47
  "@types/bcrypt": "^5.0.2",
47
48
  "@types/passport-google-oauth20": "^2.0.14",
48
49
  "@types/passport-http-bearer": "^1.0.41",
@@ -50,12 +51,14 @@
50
51
  "@types/passport-local": "^1.0.38",
51
52
  "@types/ws": "^8.5.10",
52
53
  "class-transformer": "^0.5.1",
54
+ "openapi-typescript-codegen": "^0.29.0",
53
55
  "passport-azure-ad-oauth2": "^0.0.4",
54
- "passport-google-oauth20": "^2.0.0"
56
+ "passport-google-oauth20": "^2.0.0",
57
+ "pg": "^8.13.1"
55
58
  },
56
59
  "scripts": {
57
60
  "yalc:push": "yalc push",
58
61
  "gen-types": "SWAGGER=true JWT_SECRET=swagger nest start"
59
62
  },
60
- "gitHead": "90375484c919d3991d35ccacf186c679e90bee1b"
63
+ "gitHead": "8eb798bf7672983cd13372098b1cfae43d73d190"
61
64
  }
@@ -3,6 +3,7 @@ import { ConfigService } from '@nestjs/config';
3
3
 
4
4
  export type TBcryptConfig = {
5
5
  saltRounds: number;
6
+ experimentalFeatures: string[];
6
7
  };
7
8
 
8
9
  @Injectable()
@@ -12,6 +13,7 @@ export class BcryptConfigService {
12
13
 
13
14
  get config(): TBcryptConfig {
14
15
  const saltRounds = Number.parseInt(this.configService.get<string>('BCRYPT_SALT_ROUNDS', ''), 10);
16
+ const experimentalFeatures = this.configService.get<string>('EXPERIMENTAL_FEATURES');
15
17
 
16
18
  if (!Number.isInteger(saltRounds)) {
17
19
  throw new Error('BCRYPT_SALT_ROUNDS is not defined, set it as integer');
@@ -19,6 +21,7 @@ export class BcryptConfigService {
19
21
 
20
22
  return {
21
23
  saltRounds,
24
+ experimentalFeatures: experimentalFeatures ? experimentalFeatures.split(',') : [],
22
25
  };
23
26
  }
24
27
  }
@@ -58,8 +58,10 @@ export class User {
58
58
  @UpdateDateColumn({ name: 'updated_at' })
59
59
  updatedAt: Date;
60
60
 
61
- @DeleteDateColumn()
61
+ @DeleteDateColumn({ name: 'deleted_at' })
62
62
  deletedAt: Date;
63
63
 
64
64
  policies: PackRule<SubjectRawRule<Action, TSubjectsNames, unknown>>[];
65
+
66
+ experimentalFeatures: string[];
65
67
  }
@@ -3,9 +3,10 @@ import { TUser, User } from './entities/user.entity';
3
3
  import { Controller, Req } from '@nestjs/common';
4
4
  import type { Request } from 'express';
5
5
  import { UsersService } from './users.service';
6
- import { CaslAbilityFactory } from '../casl/casl-ability.factory';
7
- import { SkipPoliciesGuard } from '../casl/policies.guard';
6
+ import { CaslAbilityFactory } from '../casl';
7
+ import { SkipPoliciesGuard } from '../casl';
8
8
  import { ApiTags } from '@nestjs/swagger';
9
+ import { TUsersConfig, UsersConfigService } from "./users.config";
9
10
 
10
11
  @Crud({
11
12
  model: {
@@ -34,10 +35,14 @@ import { ApiTags } from '@nestjs/swagger';
34
35
  @ApiTags('Users')
35
36
  @Controller('me')
36
37
  export class MeController implements CrudController<User> {
38
+ private config: TUsersConfig;
37
39
  constructor(
38
40
  public service: UsersService,
39
41
  private caslAbilityFactory: CaslAbilityFactory,
40
- ) {}
42
+ private usersConfig: UsersConfigService,
43
+ ) {
44
+ this.config = this.usersConfig.config;
45
+ }
41
46
 
42
47
  get base(): CrudController<User> {
43
48
  return this;
@@ -51,6 +56,7 @@ export class MeController implements CrudController<User> {
51
56
  const user = await this.base.getOneBase!(req);
52
57
  const ability = await this.caslAbilityFactory.createForUser(user);
53
58
  user.policies = this.caslAbilityFactory.packAbility(ability);
59
+ user.experimentalFeatures = this.config.experimentalFeatures;
54
60
 
55
61
  return user;
56
62
  }