Skip to content

Commit

Permalink
fix: clean the interfaces of the node js packages to be able to use i…
Browse files Browse the repository at this point in the history
…njection dependences directly in the modules (#573)

* fix: update mailer to use mailjet v6

* fix: update mailer to use mailjet v6

* feat: clean authentication modules

* fix: update package lock

* fix: resolve conversation and make the api start without settings env

* chore(prerelease): prerelease next version 2.0.11-next.0

* fix: remove @tractr and replace it by @trxn

* chore(prerelease): prerelease next version 2.0.11-next.1

* fix: add casl public permissions and MAILER_CLIENT token

* chore(prerelease): prerelease next version 2.0.11-next.2

* fix: update MAILER_CLIENT providers

* chore(prerelease): prerelease next version 2.0.11-next.3

* docs: add authentication documentation

* chore(prerelease): prerelease next version 2.1.0-next.0

* chore(prerelease): prerelease next version 2.1.0-next.1
  • Loading branch information
floross authored Feb 27, 2023
1 parent 6975973 commit a44391c
Show file tree
Hide file tree
Showing 388 changed files with 4,515 additions and 3,382 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"html",
"vue"
],
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifier": "shortest",
"typescript.updateImportsOnFileMove.enabled": "always"
}
8 changes: 8 additions & 0 deletions apps/admin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)



# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)



## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)


Expand Down
35 changes: 35 additions & 0 deletions apps/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)



# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)



## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)



## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)



## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)



## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)


### Bug Fixes

* resolve conversation and make the api start without settings env ([87d4465](https://github.com/tractr/traxion/commit/87d446509dd3c182c92a9d269dfbe24a826899ec))
* update mailer to use mailjet v6 ([2a4a060](https://github.com/tractr/traxion/commit/2a4a0607963235cbb859e8ff99794829f7eaaf58))


### Features

* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))



## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)


Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@trxn/traxion-api",
"version": "2.0.13"
"version": "2.1.0-next.1"
}
11 changes: 11 additions & 0 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Module } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { ConsoleModule } from 'nestjs-console';

import {
AuthenticationModule,
CaslModule,
DatabaseModule,
FileStorageModule,
GraphQLModule,
Expand All @@ -11,6 +13,8 @@ import {
PasswordModule,
} from './modules';

import { JwtGlobalAuthGuard } from '@trxn/nestjs-authentication';
import { CaslExceptionInterceptor, PoliciesGuard } from '@trxn/nestjs-casl';
import { LoggerModule } from '@trxn/nestjs-core';

@Module({
Expand All @@ -23,6 +27,7 @@ import { LoggerModule } from '@trxn/nestjs-core';
GraphQLModule,

// Authentication modules
CaslModule,
AuthenticationModule,
PasswordModule,

Expand All @@ -36,5 +41,11 @@ import { LoggerModule } from '@trxn/nestjs-core';
// Cli
ConsoleModule,
],

providers: [
{ provide: APP_GUARD, useClass: JwtGlobalAuthGuard },
{ provide: APP_GUARD, useClass: PoliciesGuard },
{ provide: APP_INTERCEPTOR, useClass: CaslExceptionInterceptor },
],
})
export class AppModule {}
38 changes: 8 additions & 30 deletions apps/api/src/app/modules/authentication.module.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
import { Module } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';

import { CaslModule } from './casl.module';
import { EncryptionModule } from './encryption.module';
import { ModelsModule } from './models.module';
import { UserModule } from './user.module';

import { getSelectPrismaUserQuery } from '@trxn/generated-casl';
import { USER_SERVICE } from '@trxn/generated-nestjs-models-common';
import {
JwtGlobalAuthGuard,
AuthenticationModule as TraxionAuthenticationModule,
} from '@trxn/nestjs-authentication';
import { BcryptService } from '@trxn/nestjs-bcrypt';
import { CaslExceptionInterceptor, PoliciesGuard } from '@trxn/nestjs-casl';
import { AuthenticationModule as TraxionAuthenticationModule } from '@trxn/nestjs-authentication';

@Module({
imports: [
CaslModule,
TraxionAuthenticationModule.registerAsync({
imports: [ModelsModule, EncryptionModule],
useFactory: (userService, encryptionService) => ({
user: {
customSelect: getSelectPrismaUserQuery(),
},
jwtModuleOptions: {
secret: 'secret',
},
userService,
encryptionService,
}),
inject: [USER_SERVICE, BcryptService],
TraxionAuthenticationModule.register({
imports: [UserModule],
customSelect: getSelectPrismaUserQuery(),
jwtModuleOptions: {
secret: 'secret',
},
}),
],
providers: [
{ provide: APP_GUARD, useClass: JwtGlobalAuthGuard },
{ provide: APP_GUARD, useClass: PoliciesGuard },
{ provide: APP_INTERCEPTOR, useClass: CaslExceptionInterceptor },
],
exports: [TraxionAuthenticationModule],
})
export class AuthenticationModule {}
4 changes: 4 additions & 0 deletions apps/api/src/app/modules/casl.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { CaslModule as TraxionCaslModule } from '@trxn/nestjs-casl';
imports: [
TraxionCaslModule.register({
rolePermissions,
getRoles: (user) => user.roles,
publicPermissions: (ability) => {
ability.can('read', 'all');
},
}),
],
exports: [TraxionCaslModule],
Expand Down
14 changes: 9 additions & 5 deletions apps/api/src/app/modules/mailer.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Module } from '@nestjs/common';

import { MailerModule as TraxionMailerModule } from '@trxn/nestjs-mailer';
import { MailjetModule, MailjetService } from '@trxn/nestjs-mailjet';

@Module({
imports: [
TraxionMailerModule.registerAsync({
useFactory: () => ({
privateApiKey: 'test',
publicApiKey: 'test',
}),
TraxionMailerModule.register({
imports: [
MailjetModule.register({
apiKey: process.env.MAILJET_API_KEY || 'apiKey',
apiSecret: process.env.MAILJET_API_SECRET || 'apiSecret',
}),
],
MailerClient: MailjetService,
}),
],
exports: [TraxionMailerModule],
Expand Down
40 changes: 14 additions & 26 deletions apps/api/src/app/modules/password.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,24 @@ import { Module } from '@nestjs/common';

import { EncryptionModule } from './encryption.module';
import { MailerModule } from './mailer.module';
import { ModelsModule } from './models.module';
import { UserModule } from './user.module';

import { USER_SERVICE } from '@trxn/generated-nestjs-models-common';
import { BcryptService, EncryptionService } from '@trxn/nestjs-bcrypt';
import { ResetPasswordSendEmailService } from '@trxn/nestjs-mailer';
import { PasswordModule as TraxionPasswordModule } from '@trxn/nestjs-password';
import { BcryptService } from '@trxn/nestjs-bcrypt';
import {
ENCRYPTION_SERVICE,
PasswordModule as TraxionPasswordModule,
} from '@trxn/nestjs-password';
import { ResetPasswordModule } from '@trxn/nestjs-reset-password';

@Module({
imports: [
TraxionPasswordModule.registerAsync({
imports: [ModelsModule, MailerModule, EncryptionModule],
useFactory: (
userService,
resetPasswordSendEmailService: ResetPasswordSendEmailService,
encryptionService: EncryptionService,
) => ({
resetPasswordSendEmail: {
request:
resetPasswordSendEmailService.sendRequestResetPasswordEmailFactory({
from: '[email protected]',
}),
updated:
resetPasswordSendEmailService.sendUpdatedPasswordEmailFactory({
from: '[email protected]',
}),
},
userService,
encryptionService,
}),
inject: [USER_SERVICE, ResetPasswordSendEmailService, BcryptService],
TraxionPasswordModule.register({
imports: [UserModule, EncryptionModule],
providers: [{ provide: ENCRYPTION_SERVICE, useExisting: BcryptService }],
}),
ResetPasswordModule.register({
imports: [UserModule, MailerModule],
from: '[email protected]',
}),
],
exports: [TraxionPasswordModule],
Expand Down
15 changes: 15 additions & 0 deletions apps/api/src/app/modules/user.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Module } from '@nestjs/common';

import { ModelsModule } from './models.module';

import { UserModule as TraxionUserModule } from '@trxn/nestjs-user';

@Module({
imports: [
TraxionUserModule.register({
imports: [ModelsModule],
}),
],
exports: [TraxionUserModule],
})
export class UserModule {}
39 changes: 39 additions & 0 deletions apps/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

# [2.1.0-next.1](https://github.com/tractr/traxion/compare/v2.1.0-next.0...v2.1.0-next.1) (2023-02-27)



# [2.1.0-next.0](https://github.com/tractr/traxion/compare/v2.0.13...v2.1.0-next.0) (2023-02-27)



## [2.0.11-next.3](https://github.com/tractr/traxion/compare/v2.0.11-next.2...v2.0.11-next.3) (2023-02-22)



## [2.0.11-next.2](https://github.com/tractr/traxion/compare/v2.0.11-next.1...v2.0.11-next.2) (2023-02-22)


### Bug Fixes

* add casl public permissions and MAILER_CLIENT token ([46f4b06](https://github.com/tractr/traxion/commit/46f4b06da9d46a79c36bde365cd817b46031e24f))



## [2.0.11-next.1](https://github.com/tractr/traxion/compare/v2.0.11-next.0...v2.0.11-next.1) (2023-02-22)


### Bug Fixes

* remove [@tractr](https://github.com/tractr) and replace it by [@trxn](https://github.com/trxn) ([129058f](https://github.com/tractr/traxion/commit/129058fee9f88c34ac4f124f9d1d54470939a0e7))



## [2.0.11-next.0](https://github.com/tractr/traxion/compare/v2.0.10...v2.0.11-next.0) (2023-02-22)


### Features

* clean authentication modules ([99b7db6](https://github.com/tractr/traxion/commit/99b7db69cc4f885ac885d147043003448895d66d))



## [2.0.13](https://github.com/tractr/traxion/compare/v2.0.12...v2.0.13) (2023-02-24)


Expand Down
9 changes: 9 additions & 0 deletions apps/docs/docs/how-to/authentication/0-use-nestjs-user.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
id: use-nestjs-user
hide_title: true
sidebar_label: The user module
---

import SourceMarkdown from '../../../../../libs/nestjs/user/README.md';

<SourceMarkdown />
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
id: use-nestjs-authentication
hide_title: true
sidebar_label: Authenticate your routes
---

import SourceMarkdown from '../../../../../libs/nestjs/authentication/README.md';

<SourceMarkdown />
9 changes: 9 additions & 0 deletions apps/docs/docs/how-to/authentication/2-use-nestjs-casl.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
id: use-nestjs-casl
hide_title: true
sidebar_label: Authorization
---

import SourceMarkdown from '../../../../../libs/nestjs/casl/README.md';

<SourceMarkdown />
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: use-nestjs-password
hide_title: true
sidebar_label: Play with the password
---

import PasswordMarkdown from '../../../../../libs/nestjs/password/README.md';
import ResetPasswordMarkdown from '../../../../../libs/nestjs/reset-password/README.md';

<PasswordMarkdown />

<ResetPasswordMarkdown />
Loading

0 comments on commit a44391c

Please sign in to comment.