* Registers the encryption service with the container * * Creates singleton bindings for both the encryption manager and * the default encryption instance. Resolves configuration from * config/encryption.ts file. * * @example * const encryption = await container.make('encryption
()
| 179 | * const encrypted = encryption.encrypt('secret-data') |
| 180 | */ |
| 181 | protected registerEncryption() { |
| 182 | this.app.container.singleton('encryption', async () => { |
| 183 | const encryptionConfigProvider = this.app.config.get('encryption') |
| 184 | |
| 185 | /** |
| 186 | * Resolve config from the provider |
| 187 | */ |
| 188 | const config = await configProvider.resolve<any>(this.app, encryptionConfigProvider) |
| 189 | if (!config) { |
| 190 | throw new RuntimeException( |
| 191 | 'Invalid "config/encryption.ts" file. Make sure you are using the "defineConfig" method' |
| 192 | ) |
| 193 | } |
| 194 | |
| 195 | const { EncryptionManager } = await import('../modules/encryption/main.js') |
| 196 | return new EncryptionManager(config) |
| 197 | }) |
| 198 | |
| 199 | this.app.container.singleton(Encryption, async (resolver) => { |
| 200 | const encryptionManager = await resolver.make('encryption') |
| 201 | return encryptionManager.use() |
| 202 | }) |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Registers the HTTP server with the container as a singleton |