@breadstone/archipel-mcp 0.0.38 → 0.0.39
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/data/guides/application-bootstrap.md +181 -0
- package/data/guides/email-templates.md +4 -0
- package/data/guides/index.md +1 -2
- package/data/guides/openapi-and-feature-discovery.md +26 -1
- package/data/packages/platform-bootstrap/api/Class.PlatformApplication.md +41 -0
- package/data/packages/platform-bootstrap/api/Class.PlatformApplicationBuilder.md +164 -0
- package/data/packages/platform-bootstrap/api/Class.PlatformBootstrapContext.md +164 -0
- package/data/packages/platform-bootstrap/api/Class.PlatformBootstrapError.md +130 -0
- package/data/packages/platform-bootstrap/api/Function.createPlatformTestApplication.md +26 -0
- package/data/packages/platform-bootstrap/api/Function.useApi.md +32 -0
- package/data/packages/platform-bootstrap/api/Function.useExpressServer.md +32 -0
- package/data/packages/platform-bootstrap/api/Function.useOpenApi.md +32 -0
- package/data/packages/platform-bootstrap/api/Function.useSecurity.md +32 -0
- package/data/packages/platform-bootstrap/api/Function.useSession.md +32 -0
- package/data/packages/platform-bootstrap/api/Interface.IApiStepOptions.md +58 -0
- package/data/packages/platform-bootstrap/api/Interface.IApiValidationOptions.md +58 -0
- package/data/packages/platform-bootstrap/api/Interface.IExpressServerStepOptions.md +46 -0
- package/data/packages/platform-bootstrap/api/Interface.IOpenApiStepOptions.md +34 -0
- package/data/packages/platform-bootstrap/api/Interface.IPlatformApplicationOptions.md +22 -0
- package/data/packages/platform-bootstrap/api/Interface.IPlatformListenOptions.md +46 -0
- package/data/packages/platform-bootstrap/api/Interface.IPlatformTestApplication.md +211 -0
- package/data/packages/platform-bootstrap/api/Interface.ISecurityStepOptions.md +63 -0
- package/data/packages/platform-bootstrap/api/Interface.ISessionStepOptions.md +118 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.PlatformBootstrapNext.md +18 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.PlatformBootstrapStep.md +31 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.PlatformContentSecurityPolicyMode.md +14 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.PlatformCorsOptions.md +14 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.SecurityRateLimitOptions.md +28 -0
- package/data/packages/platform-bootstrap/api/Variable.APP_CORS_ORIGIN.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.APP_RATE_LIMIT_MAX_REQUESTS.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.APP_RATE_LIMIT_WINDOW_MS.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.AUTH_SESSION_MAX_AGE.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.AUTH_SESSION_SECRET.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.AUTH_SESSION_SECURE.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.PLATFORM_SECURITY_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.PLATFORM_SERVER_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.PLATFORM_SESSION_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-bootstrap/api/Variable.PORT.md +14 -0
- package/data/packages/platform-bootstrap/api/index.md +65 -0
- package/data/packages/platform-bootstrap/index.md +162 -0
- package/data/patterns/bootstrap-pattern.md +145 -0
- package/data/patterns/index.md +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Application Bootstrap
|
|
3
|
+
description: Compose NestJS startup concerns with platform-bootstrap, Express middleware, security, sessions, OpenAPI, and typed configuration.
|
|
4
|
+
order: 3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Application Bootstrap
|
|
8
|
+
|
|
9
|
+
`platform-bootstrap` standardizes the small but important code that usually accumulates in `main.ts`: global API prefix, validation pipe, filters, Express middleware, CORS, Helmet, sessions, rate limiting, Swagger UI, app initialization, and HTTP listening.
|
|
10
|
+
|
|
11
|
+
The consuming application still owns `NestFactory`, the HTTP adapter, and the concrete Nest application type. This keeps serverless and Vercel entrypoints explicit while moving reusable startup concerns into composable `PlatformBootstrapStep` functions.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add @breadstone/archipel-platform-bootstrap @nestjs/platform-express express compression helmet express-rate-limit express-session
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Most Archipel applications already install `@nestjs/common`, `@nestjs/core`, `class-validator`, `class-transformer`, `reflect-metadata`, and `rxjs` through their NestJS setup.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Root Module Configuration
|
|
26
|
+
|
|
27
|
+
Register the bootstrap configuration entries in the root module so `ConfigRegistry` can validate and document them with the rest of the application config.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { Module } from '@nestjs/common';
|
|
31
|
+
import {
|
|
32
|
+
ConfigModule,
|
|
33
|
+
EnvironmentConfigStrategy,
|
|
34
|
+
} from '@breadstone/archipel-platform-configuration';
|
|
35
|
+
import {
|
|
36
|
+
PLATFORM_SECURITY_CONFIG_ENTRIES,
|
|
37
|
+
PLATFORM_SERVER_CONFIG_ENTRIES,
|
|
38
|
+
PLATFORM_SESSION_CONFIG_ENTRIES,
|
|
39
|
+
} from '@breadstone/archipel-platform-bootstrap';
|
|
40
|
+
|
|
41
|
+
@Module({
|
|
42
|
+
imports: [
|
|
43
|
+
ConfigModule.forRoot({
|
|
44
|
+
strategyFactory: () => new EnvironmentConfigStrategy(),
|
|
45
|
+
}),
|
|
46
|
+
ConfigModule.register('platform-bootstrap/server', PLATFORM_SERVER_CONFIG_ENTRIES),
|
|
47
|
+
ConfigModule.register('platform-bootstrap/security', PLATFORM_SECURITY_CONFIG_ENTRIES),
|
|
48
|
+
ConfigModule.register('platform-bootstrap/session', PLATFORM_SESSION_CONFIG_ENTRIES),
|
|
49
|
+
],
|
|
50
|
+
})
|
|
51
|
+
export class AppModule {}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Entry | Keys |
|
|
55
|
+
| ----- | ---- |
|
|
56
|
+
| `PLATFORM_SERVER_CONFIG_ENTRIES` | `PORT` |
|
|
57
|
+
| `PLATFORM_SECURITY_CONFIG_ENTRIES` | `APP_CORS_ORIGIN`, `APP_RATE_LIMIT_WINDOW_MS`, `APP_RATE_LIMIT_MAX_REQUESTS` |
|
|
58
|
+
| `PLATFORM_SESSION_CONFIG_ENTRIES` | `AUTH_SESSION_SECRET`, `AUTH_SESSION_SECURE`, `AUTH_SESSION_MAX_AGE` |
|
|
59
|
+
|
|
60
|
+
`AUTH_SESSION_SECRET` is required when `useSession()` is part of the pipeline. The other entries provide documented defaults or host-provided values.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Bootstrap Entry Point
|
|
65
|
+
|
|
66
|
+
Keep the adapter and app type visible in `main.ts`. The builder receives the already-created Nest app and applies ordered steps.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { ConsoleLogger } from '@nestjs/common';
|
|
70
|
+
import { NestFactory } from '@nestjs/core';
|
|
71
|
+
import { ExpressAdapter, NestExpressApplication } from '@nestjs/platform-express';
|
|
72
|
+
import { PlatformApplication, useApi } from '@breadstone/archipel-platform-bootstrap';
|
|
73
|
+
import { useOpenApi } from '@breadstone/archipel-platform-bootstrap/openapi';
|
|
74
|
+
import { useExpressServer } from '@breadstone/archipel-platform-bootstrap/server/express';
|
|
75
|
+
import { useSecurity } from '@breadstone/archipel-platform-bootstrap/security';
|
|
76
|
+
import { useSession } from '@breadstone/archipel-platform-bootstrap/session';
|
|
77
|
+
import { AppModule } from './AppModule';
|
|
78
|
+
|
|
79
|
+
async function main(): Promise<void> {
|
|
80
|
+
const app = await NestFactory.create<NestExpressApplication>(AppModule, new ExpressAdapter(), {
|
|
81
|
+
logger: new ConsoleLogger({
|
|
82
|
+
prefix: 'API',
|
|
83
|
+
colors: true,
|
|
84
|
+
forceConsole: true,
|
|
85
|
+
compact: true,
|
|
86
|
+
sorted: true,
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
await PlatformApplication.from(app)
|
|
91
|
+
.use(useApi({ prefix: 'api' }))
|
|
92
|
+
.use(useExpressServer({ json: { limit: '1mb' }, urlEncoded: { extended: true, limit: '1mb' } }))
|
|
93
|
+
.use(useSecurity({ contentSecurityPolicy: 'swagger-compatible' }))
|
|
94
|
+
.use(useSession())
|
|
95
|
+
.use(useOpenApi())
|
|
96
|
+
.listenFromConfig({ fallbackPort: 3000 });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
void main();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`listenFromConfig()` resolves the listening port from `PORT`, then `APP_PORT`, then `fallbackPort`. This matches hosted environments that inject `PORT` while preserving a local development default.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Built-In Steps
|
|
107
|
+
|
|
108
|
+
| Step | Import | Responsibility |
|
|
109
|
+
| ---- | ------ | -------------- |
|
|
110
|
+
| `useApi()` | `@breadstone/archipel-platform-bootstrap` | Global prefix, validation pipe, and global exception filter wiring. |
|
|
111
|
+
| `useExpressServer()` | `@breadstone/archipel-platform-bootstrap/server/express` | JSON parser, URL-encoded parser, and compression middleware. |
|
|
112
|
+
| `useSecurity()` | `@breadstone/archipel-platform-bootstrap/security` | CORS, Helmet, content security policy, and rate limiting. |
|
|
113
|
+
| `useSession()` | `@breadstone/archipel-platform-bootstrap/session` | Express-compatible session middleware backed by typed config keys. |
|
|
114
|
+
| `useOpenApi()` | `@breadstone/archipel-platform-bootstrap/openapi` | Multi-document Swagger UI discovery and setup. |
|
|
115
|
+
|
|
116
|
+
Use the steps in the order requests should pass through middleware: parser and security first, session before authenticated routes, OpenAPI after modules and decorators are loaded.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Custom Steps
|
|
121
|
+
|
|
122
|
+
Application-specific startup logic can live in a local `use*` factory. A step receives the `PlatformBootstrapContext`, performs its work, and calls `next()` to continue the pipeline.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { INestApplication } from '@nestjs/common';
|
|
126
|
+
import { PlatformBootstrapStep } from '@breadstone/archipel-platform-bootstrap';
|
|
127
|
+
|
|
128
|
+
export function useShutdownHooks<TApplication extends INestApplication = INestApplication>(): PlatformBootstrapStep<TApplication> {
|
|
129
|
+
return async function shutdownHooksStep(context, next): Promise<void> {
|
|
130
|
+
context.app.enableShutdownHooks();
|
|
131
|
+
await next();
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Then place it where the behavior belongs:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
await PlatformApplication.from(app)
|
|
140
|
+
.use(useApi({ prefix: 'api' }))
|
|
141
|
+
.use(useShutdownHooks())
|
|
142
|
+
.use(useOpenApi())
|
|
143
|
+
.listenFromConfig({ fallbackPort: 3000 });
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Testing Bootstrap Behavior
|
|
149
|
+
|
|
150
|
+
The testing subpath exposes a lightweight application double for step-order and middleware assertions.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { describe, expect, it } from 'vitest';
|
|
154
|
+
import { PlatformApplication, useApi } from '@breadstone/archipel-platform-bootstrap';
|
|
155
|
+
import { createPlatformTestApplication } from '@breadstone/archipel-platform-bootstrap/testing';
|
|
156
|
+
|
|
157
|
+
it('applies API bootstrap before initialization', async (): Promise<void> => {
|
|
158
|
+
const app = createPlatformTestApplication();
|
|
159
|
+
|
|
160
|
+
await PlatformApplication.from(app)
|
|
161
|
+
.use(useApi({ prefix: 'api' }))
|
|
162
|
+
.initialize();
|
|
163
|
+
|
|
164
|
+
expect(app.calls).toContain('setGlobalPrefix');
|
|
165
|
+
expect(app.calls.at(-1)).toBe('init');
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
For full HTTP behavior, keep using Supertest against a real Nest application. The test helper is for the composition layer itself, not controller or middleware integration coverage.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Production Checklist
|
|
174
|
+
|
|
175
|
+
- Register all bootstrap config entries in the root module.
|
|
176
|
+
- Keep `NestFactory.create()` in the application entrypoint so the adapter remains explicit.
|
|
177
|
+
- Use `useSecurity({ contentSecurityPolicy: 'swagger-compatible' })` when serving Swagger UI.
|
|
178
|
+
- Set `AUTH_SESSION_SECRET` in every environment that enables `useSession()`.
|
|
179
|
+
- Prefer `listenFromConfig()` for deployed HTTP apps and `initialize()` for serverless handler exports or composition tests.
|
|
180
|
+
|
|
181
|
+
See the [Bootstrap Pattern](/patterns/bootstrap-pattern) for the reusable design rules behind this package.
|
|
@@ -59,6 +59,8 @@ The strategy loads `AuthRegister.html`, `AuthRegister.txt`, `AuthVerify.html`, e
|
|
|
59
59
|
|
|
60
60
|
### Template Syntax
|
|
61
61
|
|
|
62
|
+
::: v-pre
|
|
63
|
+
|
|
62
64
|
Templates use a Handlebars-style syntax powered by `ContentTemplateEngine`:
|
|
63
65
|
|
|
64
66
|
| Syntax | Description |
|
|
@@ -109,6 +111,8 @@ Please verify your email address by visiting the following link:
|
|
|
109
111
|
If you did not create an account, you can safely ignore this email.
|
|
110
112
|
```
|
|
111
113
|
|
|
114
|
+
:::
|
|
115
|
+
|
|
112
116
|
### Security
|
|
113
117
|
|
|
114
118
|
When the format is `html`, `MailTemplateEngine` automatically **escapes all context values** (`&`, `<`, `>`, `"`, `'`) before interpolation to prevent XSS in email clients. Plain-text templates (`txt`) are not escaped.
|
package/data/guides/index.md
CHANGED
|
@@ -13,12 +13,11 @@ Practical guides for working with Archipel packages in your NestJS application.
|
|
|
13
13
|
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
14
14
|
| [Getting Started](./getting-started) | Install packages, register your first module, implement ports, and run the app. |
|
|
15
15
|
| [Configuration Management](./configuration) | Type-safe config keys, strategy-based resolution, central registry, and validation. |
|
|
16
|
+
| [Application Bootstrap](./application-bootstrap) | Compose NestJS startup with platform-bootstrap, Express middleware, security, sessions, and OpenAPI. |
|
|
16
17
|
| [Implementing Ports](./implementing-ports) | How the port/adapter pattern works, how to write adapters, and how to test them. |
|
|
17
18
|
| [Controller Best Practices](./controller-best-practices) | Structure, annotate, and implement controllers — regions, DI, ResponseReturn, guards, and the @Api decorator. |
|
|
18
19
|
| [Request & Response DTOs](./request-response-dtos) | DTO naming conventions, validation decorators, cross-field validation, and class-transformer integration. |
|
|
19
20
|
| [Testing](./testing) | Unit testing services, testing port adapters, integration testing with real databases. |
|
|
20
|
-
| [TSDoc Guidelines](./tsdoc-guidelines) | Documentation standards for public APIs and generated reference pages. ld validation, and class-transformer integration. |
|
|
21
|
-
| [Testing](./testing) | Unit testing services, testing port adapters, integration testing with real databases. |
|
|
22
21
|
| [TSDoc Guidelines](./tsdoc-guidelines) | Documentation standards for public APIs and generated reference pages. |
|
|
23
22
|
|
|
24
23
|
## Security & Identity
|
|
@@ -174,7 +174,32 @@ export class TipController {
|
|
|
174
174
|
|
|
175
175
|
## Step 3: Bootstrap the Swagger UI
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
The recommended application bootstrap path is `useOpenApi()` from `platform-bootstrap`. It runs the same feature discovery and multi-document Swagger setup while keeping the startup sequence consistent with the rest of the platform.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { NestFactory } from '@nestjs/core';
|
|
181
|
+
import { ExpressAdapter, NestExpressApplication } from '@nestjs/platform-express';
|
|
182
|
+
import { PlatformApplication, useApi } from '@breadstone/archipel-platform-bootstrap';
|
|
183
|
+
import { useOpenApi } from '@breadstone/archipel-platform-bootstrap/openapi';
|
|
184
|
+
import { useExpressServer } from '@breadstone/archipel-platform-bootstrap/server/express';
|
|
185
|
+
import { useSecurity } from '@breadstone/archipel-platform-bootstrap/security';
|
|
186
|
+
import { AppModule } from './AppModule';
|
|
187
|
+
|
|
188
|
+
async function bootstrap(): Promise<void> {
|
|
189
|
+
const app = await NestFactory.create<NestExpressApplication>(AppModule, new ExpressAdapter());
|
|
190
|
+
|
|
191
|
+
await PlatformApplication.from(app)
|
|
192
|
+
.use(useApi({ prefix: 'api' }))
|
|
193
|
+
.use(useExpressServer())
|
|
194
|
+
.use(useSecurity({ contentSecurityPolicy: 'swagger-compatible' }))
|
|
195
|
+
.use(useOpenApi())
|
|
196
|
+
.listenFromConfig({ fallbackPort: 3000 });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
void bootstrap();
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
If you are wiring OpenAPI without `platform-bootstrap`, use the lower-level services directly:
|
|
178
203
|
|
|
179
204
|
```typescript
|
|
180
205
|
import { NestFactory } from '@nestjs/core';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Class: PlatformApplication'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Class: PlatformApplication
|
|
7
|
+
|
|
8
|
+
Defined in: [application/PlatformApplication.ts:10](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplication.ts#L10)
|
|
9
|
+
|
|
10
|
+
Entry point for composing an existing NestJS application with Archipel bootstrap steps.
|
|
11
|
+
|
|
12
|
+
## Methods
|
|
13
|
+
|
|
14
|
+
### from()
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
static from<TApplication>(app, options?): PlatformApplicationBuilder<TApplication>;
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Defined in: [application/PlatformApplication.ts:33](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplication.ts#L33)
|
|
21
|
+
|
|
22
|
+
Wraps an already-created NestJS application in a fluent bootstrap builder.
|
|
23
|
+
|
|
24
|
+
#### Type Parameters
|
|
25
|
+
|
|
26
|
+
| Type Parameter |
|
|
27
|
+
| ------ |
|
|
28
|
+
| `TApplication` *extends* `INestApplication`\<`any`\> |
|
|
29
|
+
|
|
30
|
+
#### Parameters
|
|
31
|
+
|
|
32
|
+
| Parameter | Type | Description |
|
|
33
|
+
| ------ | ------ | ------ |
|
|
34
|
+
| `app` | `TApplication` | The NestJS application created by the consumer. |
|
|
35
|
+
| `options?` | [`IPlatformApplicationOptions`](Interface.IPlatformApplicationOptions) | Optional platform-level bootstrap dependencies. |
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
[`PlatformApplicationBuilder`](Class.PlatformApplicationBuilder)\<`TApplication`\>
|
|
40
|
+
|
|
41
|
+
A platform application builder.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Class: PlatformApplicationBuilder\<TApplication\>'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Class: PlatformApplicationBuilder\<TApplication\>
|
|
7
|
+
|
|
8
|
+
Defined in: [application/PlatformApplicationBuilder.ts:16](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L16)
|
|
9
|
+
|
|
10
|
+
Fluent builder that composes NestJS bootstrap steps and executes them once.
|
|
11
|
+
|
|
12
|
+
## Type Parameters
|
|
13
|
+
|
|
14
|
+
| Type Parameter | Default type |
|
|
15
|
+
| ------ | ------ |
|
|
16
|
+
| `TApplication` *extends* `INestApplication` | `INestApplication` |
|
|
17
|
+
|
|
18
|
+
## Constructors
|
|
19
|
+
|
|
20
|
+
### Constructor
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
new PlatformApplicationBuilder<TApplication>(app, options?): PlatformApplicationBuilder<TApplication>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Defined in: [application/PlatformApplicationBuilder.ts:28](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L28)
|
|
27
|
+
|
|
28
|
+
#### Parameters
|
|
29
|
+
|
|
30
|
+
| Parameter | Type |
|
|
31
|
+
| ------ | ------ |
|
|
32
|
+
| `app` | `TApplication` |
|
|
33
|
+
| `options?` | [`IPlatformApplicationOptions`](Interface.IPlatformApplicationOptions) |
|
|
34
|
+
|
|
35
|
+
#### Returns
|
|
36
|
+
|
|
37
|
+
`PlatformApplicationBuilder`\<`TApplication`\>
|
|
38
|
+
|
|
39
|
+
## Accessors
|
|
40
|
+
|
|
41
|
+
### app
|
|
42
|
+
|
|
43
|
+
#### Get Signature
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
get app(): TApplication;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Defined in: [application/PlatformApplicationBuilder.ts:44](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L44)
|
|
50
|
+
|
|
51
|
+
The wrapped NestJS application.
|
|
52
|
+
|
|
53
|
+
##### Returns
|
|
54
|
+
|
|
55
|
+
`TApplication`
|
|
56
|
+
|
|
57
|
+
## Methods
|
|
58
|
+
|
|
59
|
+
### initialize()
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
initialize(): Promise<TApplication>;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Defined in: [application/PlatformApplicationBuilder.ts:70](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L70)
|
|
66
|
+
|
|
67
|
+
Executes the configured bootstrap pipeline and initializes the NestJS application.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`Promise`\<`TApplication`\>
|
|
72
|
+
|
|
73
|
+
The wrapped NestJS application.
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
### listen()
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
listen(port, hostname?): Promise<TApplication>;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Defined in: [application/PlatformApplicationBuilder.ts:94](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L94)
|
|
84
|
+
|
|
85
|
+
Executes the pipeline and starts the NestJS listener on the given port.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
| Parameter | Type | Description |
|
|
90
|
+
| ------ | ------ | ------ |
|
|
91
|
+
| `port` | `number` | The HTTP port. |
|
|
92
|
+
| `hostname?` | `string` | Optional hostname/interface binding. |
|
|
93
|
+
|
|
94
|
+
#### Returns
|
|
95
|
+
|
|
96
|
+
`Promise`\<`TApplication`\>
|
|
97
|
+
|
|
98
|
+
The wrapped NestJS application.
|
|
99
|
+
|
|
100
|
+
***
|
|
101
|
+
|
|
102
|
+
### listenFromConfig()
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
listenFromConfig(options?): Promise<TApplication>;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Defined in: [application/PlatformApplicationBuilder.ts:113](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L113)
|
|
109
|
+
|
|
110
|
+
Executes the pipeline and starts the listener using typed configuration keys.
|
|
111
|
+
|
|
112
|
+
#### Parameters
|
|
113
|
+
|
|
114
|
+
| Parameter | Type | Description |
|
|
115
|
+
| ------ | ------ | ------ |
|
|
116
|
+
| `options?` | [`IPlatformListenOptions`](Interface.IPlatformListenOptions) | Port resolution options. |
|
|
117
|
+
|
|
118
|
+
#### Returns
|
|
119
|
+
|
|
120
|
+
`Promise`\<`TApplication`\>
|
|
121
|
+
|
|
122
|
+
The wrapped NestJS application.
|
|
123
|
+
|
|
124
|
+
***
|
|
125
|
+
|
|
126
|
+
### run()
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
run(): Promise<PlatformBootstrapContext<TApplication>>;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Defined in: [application/PlatformApplicationBuilder.ts:82](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L82)
|
|
133
|
+
|
|
134
|
+
Executes the configured bootstrap pipeline without starting a listener.
|
|
135
|
+
|
|
136
|
+
#### Returns
|
|
137
|
+
|
|
138
|
+
`Promise`\<[`PlatformBootstrapContext`](Class.PlatformBootstrapContext)\<`TApplication`\>\>
|
|
139
|
+
|
|
140
|
+
The bootstrap context used for the execution.
|
|
141
|
+
|
|
142
|
+
***
|
|
143
|
+
|
|
144
|
+
### use()
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
use(step): this;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Defined in: [application/PlatformApplicationBuilder.ts:59](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L59)
|
|
151
|
+
|
|
152
|
+
Adds a bootstrap step to the application pipeline.
|
|
153
|
+
|
|
154
|
+
#### Parameters
|
|
155
|
+
|
|
156
|
+
| Parameter | Type | Description |
|
|
157
|
+
| ------ | ------ | ------ |
|
|
158
|
+
| `step` | [`PlatformBootstrapStep`](TypeAlias.PlatformBootstrapStep)\<`TApplication`\> | The step to execute during bootstrap. |
|
|
159
|
+
|
|
160
|
+
#### Returns
|
|
161
|
+
|
|
162
|
+
`this`
|
|
163
|
+
|
|
164
|
+
The current builder for chaining.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Class: PlatformBootstrapContext\<TApplication\>'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Class: PlatformBootstrapContext\<TApplication\>
|
|
7
|
+
|
|
8
|
+
Defined in: [context/PlatformBootstrapContext.ts:9](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L9)
|
|
9
|
+
|
|
10
|
+
Runtime context shared by platform bootstrap steps.
|
|
11
|
+
|
|
12
|
+
## Type Parameters
|
|
13
|
+
|
|
14
|
+
| Type Parameter | Default type |
|
|
15
|
+
| ------ | ------ |
|
|
16
|
+
| `TApplication` *extends* `INestApplication` | `INestApplication` |
|
|
17
|
+
|
|
18
|
+
## Constructors
|
|
19
|
+
|
|
20
|
+
### Constructor
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
new PlatformBootstrapContext<TApplication>(app, configService?): PlatformBootstrapContext<TApplication>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Defined in: [context/PlatformBootstrapContext.ts:19](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L19)
|
|
27
|
+
|
|
28
|
+
#### Parameters
|
|
29
|
+
|
|
30
|
+
| Parameter | Type |
|
|
31
|
+
| ------ | ------ |
|
|
32
|
+
| `app` | `TApplication` |
|
|
33
|
+
| `configService?` | `ConfigService` |
|
|
34
|
+
|
|
35
|
+
#### Returns
|
|
36
|
+
|
|
37
|
+
`PlatformBootstrapContext`\<`TApplication`\>
|
|
38
|
+
|
|
39
|
+
## Accessors
|
|
40
|
+
|
|
41
|
+
### app
|
|
42
|
+
|
|
43
|
+
#### Get Signature
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
get app(): TApplication;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Defined in: [context/PlatformBootstrapContext.ts:33](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L33)
|
|
50
|
+
|
|
51
|
+
The wrapped NestJS application.
|
|
52
|
+
|
|
53
|
+
##### Returns
|
|
54
|
+
|
|
55
|
+
`TApplication`
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### config
|
|
60
|
+
|
|
61
|
+
#### Get Signature
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
get config(): ConfigService;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Defined in: [context/PlatformBootstrapContext.ts:42](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L42)
|
|
68
|
+
|
|
69
|
+
The Archipel configuration service resolved from the app or builder options.
|
|
70
|
+
|
|
71
|
+
##### Returns
|
|
72
|
+
|
|
73
|
+
`ConfigService`
|
|
74
|
+
|
|
75
|
+
## Methods
|
|
76
|
+
|
|
77
|
+
### getConfigValue()
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
getConfigValue<TValue>(key): TValue;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Defined in: [context/PlatformBootstrapContext.ts:68](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L68)
|
|
84
|
+
|
|
85
|
+
Reads a required value from the configuration service.
|
|
86
|
+
|
|
87
|
+
#### Type Parameters
|
|
88
|
+
|
|
89
|
+
| Type Parameter |
|
|
90
|
+
| ------ |
|
|
91
|
+
| `TValue` |
|
|
92
|
+
|
|
93
|
+
#### Parameters
|
|
94
|
+
|
|
95
|
+
| Parameter | Type | Description |
|
|
96
|
+
| ------ | ------ | ------ |
|
|
97
|
+
| `key` | `IConfigKey`\<`TValue`\> | The typed configuration key. |
|
|
98
|
+
|
|
99
|
+
#### Returns
|
|
100
|
+
|
|
101
|
+
`TValue`
|
|
102
|
+
|
|
103
|
+
The typed configuration value.
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
107
|
+
### getService()
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
getService<TService>(token): TService;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Defined in: [context/PlatformBootstrapContext.ts:57](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L57)
|
|
114
|
+
|
|
115
|
+
Resolves a provider from the NestJS application container.
|
|
116
|
+
|
|
117
|
+
#### Type Parameters
|
|
118
|
+
|
|
119
|
+
| Type Parameter |
|
|
120
|
+
| ------ |
|
|
121
|
+
| `TService` |
|
|
122
|
+
|
|
123
|
+
#### Parameters
|
|
124
|
+
|
|
125
|
+
| Parameter | Type | Description |
|
|
126
|
+
| ------ | ------ | ------ |
|
|
127
|
+
| `token` | `string` \| `symbol` \| `Type`\<`TService`\> | The provider token. |
|
|
128
|
+
|
|
129
|
+
#### Returns
|
|
130
|
+
|
|
131
|
+
`TService`
|
|
132
|
+
|
|
133
|
+
The resolved provider instance.
|
|
134
|
+
|
|
135
|
+
***
|
|
136
|
+
|
|
137
|
+
### tryGetConfigValue()
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
tryGetConfigValue<TValue>(key, fallback): TValue;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Defined in: [context/PlatformBootstrapContext.ts:80](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/context/PlatformBootstrapContext.ts#L80)
|
|
144
|
+
|
|
145
|
+
Reads an optional value from the configuration service.
|
|
146
|
+
|
|
147
|
+
#### Type Parameters
|
|
148
|
+
|
|
149
|
+
| Type Parameter |
|
|
150
|
+
| ------ |
|
|
151
|
+
| `TValue` |
|
|
152
|
+
|
|
153
|
+
#### Parameters
|
|
154
|
+
|
|
155
|
+
| Parameter | Type | Description |
|
|
156
|
+
| ------ | ------ | ------ |
|
|
157
|
+
| `key` | `IConfigKey`\<`TValue`\> | The typed configuration key. |
|
|
158
|
+
| `fallback` | `TValue` | The fallback value when the key is absent. |
|
|
159
|
+
|
|
160
|
+
#### Returns
|
|
161
|
+
|
|
162
|
+
`TValue`
|
|
163
|
+
|
|
164
|
+
The typed configuration value or fallback.
|