@owlmeans/server-app 0.1.1 → 0.1.3
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/LICENSE +1 -1
- package/README.md +45 -599
- package/build/exports.d.ts +6 -6
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +3 -3
- package/build/exports.js.map +1 -1
- package/build/main.d.ts +3 -3
- package/build/main.d.ts.map +1 -1
- package/build/main.js +1 -1
- package/build/main.js.map +1 -1
- package/build/modules.d.ts +1 -1
- package/build/modules.d.ts.map +1 -1
- package/package.json +19 -17
- package/src/exports.ts +6 -6
- package/src/main.ts +4 -4
- package/tsconfig.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 OwlMeans Common — Fullstack typescript framework
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,638 +1,84 @@
|
|
|
1
1
|
# @owlmeans/server-app
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The main entry point for OwlMeans backend services — aggregates server packages and provides the `makeContext` + `main` bootstrap functions.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- **API Server Management**: Automated API server configuration and lifecycle management
|
|
12
|
-
- **Module System Integration**: Seamless integration with the OwlMeans module system
|
|
13
|
-
- **Socket Support**: WebSocket functionality for real-time communication
|
|
14
|
-
- **Static Resource Serving**: Static file serving capabilities
|
|
15
|
-
- **Kubernetes Integration**: Optional Kubernetes deployment and management features
|
|
16
|
-
- **Configuration Management**: Comprehensive configuration handling
|
|
17
|
-
|
|
18
|
-
## Key Concepts
|
|
19
|
-
|
|
20
|
-
### Application Framework
|
|
21
|
-
This package acts as a meta-framework that combines and orchestrates multiple OwlMeans packages to create a complete server application environment.
|
|
22
|
-
|
|
23
|
-
### Context-driven Architecture
|
|
24
|
-
Uses the OwlMeans context system to manage dependencies, services, and application lifecycle in a structured manner.
|
|
25
|
-
|
|
26
|
-
### Module-first Design
|
|
27
|
-
Built around the OwlMeans module system where functionality is organized as URL units that can be transformed into API routes with handlers.
|
|
28
|
-
|
|
29
|
-
### Integrated Services
|
|
30
|
-
Automatically sets up and configures essential services like authentication, API handling, socket communication, and static resource serving.
|
|
7
|
+
- `makeContext(cfg)` creates a fully initialized server context with Fastify, auth, WebSocket, and static resource support
|
|
8
|
+
- `main(ctx, entrypoints)` registers entrypoints, initializes the context, and starts the HTTP server
|
|
9
|
+
- Re-exports the most commonly used symbols from lower-level packages so backend code has a single import target
|
|
10
|
+
- Used by every service in the viable monorepo
|
|
31
11
|
|
|
32
12
|
## Installation
|
|
33
13
|
|
|
34
14
|
```bash
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## API Reference
|
|
39
|
-
|
|
40
|
-
### Types
|
|
41
|
-
|
|
42
|
-
#### `AppConfig`
|
|
43
|
-
Application configuration interface extending ServerConfig.
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
interface AppConfig extends ServerConfig, KlusterConfig {
|
|
47
|
-
services: Record<string, ServiceRoute>
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
#### `AppContext<C extends AppConfig = AppConfig>`
|
|
52
|
-
Application context interface with integrated service capabilities.
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
interface AppContext<C extends AppConfig = AppConfig> extends ServerContext<C>,
|
|
56
|
-
AuthServiceAppend,
|
|
57
|
-
ApiServerAppend { }
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Core Functions
|
|
61
|
-
|
|
62
|
-
#### `makeContext<C extends AppConfig, T extends AppContext<C>>(cfg: C, customize?: boolean): T`
|
|
63
|
-
|
|
64
|
-
Creates a fully configured application context with all necessary services and middleware.
|
|
65
|
-
|
|
66
|
-
**Parameters:**
|
|
67
|
-
- `cfg`: Application configuration object
|
|
68
|
-
- `customize`: Whether to skip default authentication setup (defaults to false)
|
|
69
|
-
|
|
70
|
-
**Returns:** Configured application context
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import { makeContext } from '@owlmeans/server-app'
|
|
74
|
-
|
|
75
|
-
const config = {
|
|
76
|
-
service: 'my-app',
|
|
77
|
-
layer: Layer.System,
|
|
78
|
-
type: AppType.Backend,
|
|
79
|
-
services: {
|
|
80
|
-
'database': { host: 'localhost', port: 5432 }
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const context = makeContext(config)
|
|
15
|
+
bun add @owlmeans/server-app
|
|
85
16
|
```
|
|
86
17
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Main application entry point that registers modules, initializes the context, and starts the API server.
|
|
18
|
+
## Usage
|
|
90
19
|
|
|
91
|
-
|
|
92
|
-
- `ctx`: Application context instance
|
|
93
|
-
- `modules`: Array of modules to register with the application
|
|
94
|
-
|
|
95
|
-
**Returns:** Promise that resolves when the application is running
|
|
20
|
+
Bootstrap a backend service:
|
|
96
21
|
|
|
97
22
|
```typescript
|
|
98
|
-
import { main,
|
|
99
|
-
import { modules as defaultModules } from '@owlmeans/server-app'
|
|
100
|
-
|
|
101
|
-
const context = makeContext(config)
|
|
102
|
-
const allModules = [...defaultModules, ...customModules]
|
|
103
|
-
|
|
104
|
-
await main(context, allModules)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Pre-configured Modules
|
|
108
|
-
|
|
109
|
-
#### `modules`
|
|
110
|
-
Default set of modules that provide essential server functionality.
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
const modules: CommonModule[]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Includes:
|
|
117
|
-
- Server authentication modules
|
|
118
|
-
- API configuration modules
|
|
119
|
-
|
|
120
|
-
### Exported Utilities
|
|
121
|
-
|
|
122
|
-
The package re-exports commonly used utilities from various OwlMeans packages:
|
|
123
|
-
|
|
124
|
-
#### Configuration
|
|
125
|
-
```typescript
|
|
126
|
-
export { config } from '@owlmeans/server-context'
|
|
127
|
-
export { sservice } from '@owlmeans/server-config'
|
|
128
|
-
export { addWebService } from '@owlmeans/client-config'
|
|
129
|
-
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config'
|
|
130
|
-
```
|
|
23
|
+
import { makeContext, main, modules, config, service, AppType, Layer } from '@owlmeans/server-app'
|
|
131
24
|
|
|
132
|
-
#### Module System
|
|
133
|
-
```typescript
|
|
134
|
-
export { parent, filter, body, params, ModuleOutcome } from '@owlmeans/module'
|
|
135
|
-
export { elevate, module, guard } from '@owlmeans/server-module'
|
|
136
|
-
export { elevate as celevate } from '@owlmeans/client-module'
|
|
137
|
-
export { route as broute } from '@owlmeans/server-route'
|
|
138
|
-
export { route } from '@owlmeans/route'
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### API Handling
|
|
142
|
-
```typescript
|
|
143
|
-
export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api'
|
|
144
|
-
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/module'
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Resource Management
|
|
148
|
-
```typescript
|
|
149
|
-
export { createListSchema, filterObject } from '@owlmeans/resource'
|
|
150
|
-
export type { ListResult } from '@owlmeans/resource'
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
#### Context and Authentication
|
|
154
|
-
```typescript
|
|
155
|
-
export { AppType, BASE, Layer, assertContext } from '@owlmeans/context'
|
|
156
|
-
export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth'
|
|
157
|
-
export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common'
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
#### Kubernetes Integration
|
|
161
|
-
```typescript
|
|
162
|
-
export { klusterize } from '@owlmeans/kluster'
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Usage Examples
|
|
166
|
-
|
|
167
|
-
### Basic Application Setup
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
import { makeContext, main, modules, config, service } from '@owlmeans/server-app'
|
|
171
|
-
import { AppType, Layer } from '@owlmeans/context'
|
|
172
|
-
|
|
173
|
-
// Create application configuration
|
|
174
25
|
const appConfig = config(
|
|
175
26
|
AppType.Backend,
|
|
176
|
-
'
|
|
177
|
-
service('
|
|
178
|
-
|
|
179
|
-
port: parseInt(process.env.DB_PORT || '5432')
|
|
180
|
-
}),
|
|
181
|
-
{
|
|
182
|
-
layer: Layer.System,
|
|
183
|
-
port: 3000,
|
|
184
|
-
services: {
|
|
185
|
-
'auth-service': { host: 'localhost', port: 3001 },
|
|
186
|
-
'api-gateway': { host: 'localhost', port: 3002 }
|
|
187
|
-
}
|
|
188
|
-
}
|
|
27
|
+
'manager-api',
|
|
28
|
+
service({ service: 'mongo', host: process.env.MONGO_HOST!, port: 27017 }),
|
|
29
|
+
{ layer: Layer.Service, port: 3000 }
|
|
189
30
|
)
|
|
190
31
|
|
|
191
|
-
// Create application context
|
|
192
32
|
const context = makeContext(appConfig)
|
|
193
|
-
|
|
194
|
-
// Start the application
|
|
195
|
-
await main(context, modules)
|
|
196
|
-
console.log('Server started on port 3000')
|
|
33
|
+
await main(context, [...modules, ...appModules])
|
|
197
34
|
```
|
|
198
35
|
|
|
199
|
-
|
|
36
|
+
Elevate an entrypoint with a handler:
|
|
200
37
|
|
|
201
38
|
```typescript
|
|
202
|
-
import {
|
|
203
|
-
makeContext,
|
|
204
|
-
main,
|
|
205
|
-
modules,
|
|
206
|
-
module,
|
|
207
|
-
route,
|
|
208
|
-
guard,
|
|
209
|
-
filter,
|
|
210
|
-
body,
|
|
211
|
-
handleRequest
|
|
212
|
-
} from '@owlmeans/server-app'
|
|
39
|
+
import { elevate, handleBody, guard, GUARD_ED25519, modules } from '@owlmeans/server-app'
|
|
213
40
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
guard('authenticated')
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
elevate(userModule, 'users', handleRequest(async (req, res) => {
|
|
221
|
-
const users = await getUsersFromDatabase()
|
|
222
|
-
res.resolve(users)
|
|
223
|
-
}))
|
|
224
|
-
|
|
225
|
-
const createUserModule = module(
|
|
226
|
-
route('create-user', '/api/users', { method: 'POST' }),
|
|
227
|
-
filter(body({
|
|
228
|
-
type: 'object',
|
|
229
|
-
properties: {
|
|
230
|
-
name: { type: 'string' },
|
|
231
|
-
email: { type: 'string' }
|
|
232
|
-
},
|
|
233
|
-
required: ['name', 'email']
|
|
234
|
-
}), guard('authenticated'))
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
elevate(createUserModule, 'create-user', handleRequest(async (req, res) => {
|
|
238
|
-
const userData = req.body
|
|
239
|
-
const user = await createUser(userData)
|
|
240
|
-
res.resolve(user, ModuleOutcome.Created)
|
|
241
|
-
}))
|
|
242
|
-
|
|
243
|
-
// Combine with default modules
|
|
244
|
-
const allModules = [...modules, userModule, createUserModule]
|
|
245
|
-
|
|
246
|
-
// Create and start application
|
|
247
|
-
const context = makeContext(appConfig)
|
|
248
|
-
await main(context, allModules)
|
|
41
|
+
elevate(modules, 'project-create', handleBody<CreateProject>(async (payload, ctx) => {
|
|
42
|
+
return await (ctx as Context).project().create(payload)
|
|
43
|
+
}), guard(GUARD_ED25519))
|
|
249
44
|
```
|
|
250
45
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
```typescript
|
|
254
|
-
import { makeContext, main, service, config } from '@owlmeans/server-app'
|
|
255
|
-
|
|
256
|
-
// Configure database service
|
|
257
|
-
const appConfig = config(
|
|
258
|
-
AppType.Backend,
|
|
259
|
-
'data-app',
|
|
260
|
-
service('mongodb', {
|
|
261
|
-
uri: process.env.MONGODB_URI || 'mongodb://localhost:27017',
|
|
262
|
-
database: 'myapp'
|
|
263
|
-
}),
|
|
264
|
-
service('redis', {
|
|
265
|
-
host: process.env.REDIS_HOST || 'localhost',
|
|
266
|
-
port: parseInt(process.env.REDIS_PORT || '6379')
|
|
267
|
-
})
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
const context = makeContext(appConfig)
|
|
46
|
+
## API
|
|
271
47
|
|
|
272
|
-
|
|
273
|
-
const databaseModules = [
|
|
274
|
-
// Your database modules here
|
|
275
|
-
]
|
|
48
|
+
### `makeContext<C, T>(cfg, customize?): T`
|
|
276
49
|
|
|
277
|
-
|
|
278
|
-
```
|
|
50
|
+
Creates a server context with Fastify HTTP, WebSocket, static resources, and auth guard set up. Pass `customize: true` to skip the default auth setup.
|
|
279
51
|
|
|
280
|
-
###
|
|
52
|
+
### `main<R, C, T>(ctx, entrypoints): Promise<void>`
|
|
281
53
|
|
|
282
|
-
|
|
283
|
-
import {
|
|
284
|
-
makeContext,
|
|
285
|
-
main,
|
|
286
|
-
modules,
|
|
287
|
-
module,
|
|
288
|
-
route,
|
|
289
|
-
guard,
|
|
290
|
-
DAUTH_GUARD,
|
|
291
|
-
GUARD_ED25519
|
|
292
|
-
} from '@owlmeans/server-app'
|
|
54
|
+
Registers entrypoints, calls `configure().init()`, then starts the Fastify server.
|
|
293
55
|
|
|
294
|
-
|
|
295
|
-
const adminModule = module(
|
|
296
|
-
route('admin', '/api/admin', { method: 'GET' }),
|
|
297
|
-
guard([DAUTH_GUARD, GUARD_ED25519]) // Multiple guards
|
|
298
|
-
)
|
|
56
|
+
### Re-exported symbols (for convenience)
|
|
299
57
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
58
|
+
| Symbol | Source |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `handleBody`, `handleParams`, `handleRequest` | `@owlmeans/server-api` |
|
|
61
|
+
| `elevate`, `entrypoint`, `guard` | `@owlmeans/server-entrypoint` |
|
|
62
|
+
| `celevate` | `@owlmeans/client-entrypoint` |
|
|
63
|
+
| `route` | `@owlmeans/route` |
|
|
64
|
+
| `broute` | `@owlmeans/server-route` |
|
|
65
|
+
| `filter`, `body`, `params`, `parent`, `EntrypointOutcome` | `@owlmeans/entrypoint` |
|
|
66
|
+
| `config`, `service`, `sservice`, `toConfigRecord` | various config packages |
|
|
67
|
+
| `AppType`, `Layer`, `BASE`, `assertContext` | `@owlmeans/context` |
|
|
68
|
+
| `DAUTH_GUARD` | `@owlmeans/server-auth` |
|
|
69
|
+
| `GUARD_ED25519`, `BED255_CASHE_RESOURCE` | `@owlmeans/auth-common` |
|
|
70
|
+
| `klusterize` | `@owlmeans/kluster` |
|
|
71
|
+
| `Request`, `Response`, `CommonEntrypoint`, `ClientEntrypoint` | type re-exports |
|
|
305
72
|
|
|
306
|
-
|
|
307
|
-
await main(context, [...modules, adminModule])
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### WebSocket Integration
|
|
311
|
-
|
|
312
|
-
```typescript
|
|
313
|
-
import { makeContext, main, modules } from '@owlmeans/server-app'
|
|
314
|
-
|
|
315
|
-
// WebSocket is automatically configured in makeContext
|
|
316
|
-
const context = makeContext(appConfig)
|
|
317
|
-
|
|
318
|
-
// Access socket service if needed
|
|
319
|
-
await context.configure().init()
|
|
320
|
-
const socketService = context.service('socket')
|
|
321
|
-
|
|
322
|
-
// Register socket event handlers
|
|
323
|
-
socketService.on('user-connected', (socket, data) => {
|
|
324
|
-
console.log('User connected:', data.userId)
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
await main(context, modules)
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
### Static File Serving
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
import { makeContext, main, modules } from '@owlmeans/server-app'
|
|
334
|
-
|
|
335
|
-
const appConfig = config(
|
|
336
|
-
AppType.Backend,
|
|
337
|
-
'web-server',
|
|
338
|
-
{
|
|
339
|
-
staticPath: './public',
|
|
340
|
-
staticRoute: '/static'
|
|
341
|
-
}
|
|
342
|
-
)
|
|
343
|
-
|
|
344
|
-
// Static resource serving is automatically configured
|
|
345
|
-
const context = makeContext(appConfig)
|
|
346
|
-
await main(context, modules)
|
|
347
|
-
|
|
348
|
-
// Now files in ./public are served at /static/*
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
### Custom Context Configuration
|
|
352
|
-
|
|
353
|
-
```typescript
|
|
354
|
-
import { makeContext, main, appendCustomService } from '@owlmeans/server-app'
|
|
355
|
-
|
|
356
|
-
// Create context with custom flag to skip default auth
|
|
357
|
-
const context = makeContext(appConfig, true) // customize = true
|
|
358
|
-
|
|
359
|
-
// Add custom services
|
|
360
|
-
const customService = createService('custom-service', {
|
|
361
|
-
process: async (data) => {
|
|
362
|
-
return processData(data)
|
|
363
|
-
}
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
context.registerService(customService)
|
|
367
|
-
|
|
368
|
-
// Add custom authentication if needed
|
|
369
|
-
// ... custom auth setup
|
|
370
|
-
|
|
371
|
-
await main(context, modules)
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### Environment-based Configuration
|
|
375
|
-
|
|
376
|
-
```typescript
|
|
377
|
-
import {
|
|
378
|
-
makeContext,
|
|
379
|
-
main,
|
|
380
|
-
modules,
|
|
381
|
-
config,
|
|
382
|
-
service,
|
|
383
|
-
toConfigRecord
|
|
384
|
-
} from '@owlmeans/server-app'
|
|
385
|
-
|
|
386
|
-
// Create environment-aware configuration
|
|
387
|
-
const appConfig = config(
|
|
388
|
-
AppType.Backend,
|
|
389
|
-
process.env.SERVICE_NAME || 'default-app',
|
|
390
|
-
...toConfigRecord({
|
|
391
|
-
'database': {
|
|
392
|
-
host: process.env.DB_HOST || 'localhost',
|
|
393
|
-
port: parseInt(process.env.DB_PORT || '5432'),
|
|
394
|
-
ssl: process.env.NODE_ENV === 'production'
|
|
395
|
-
},
|
|
396
|
-
'redis': {
|
|
397
|
-
host: process.env.REDIS_HOST || 'localhost',
|
|
398
|
-
port: parseInt(process.env.REDIS_PORT || '6379')
|
|
399
|
-
}
|
|
400
|
-
}),
|
|
401
|
-
{
|
|
402
|
-
layer: process.env.NODE_ENV === 'production' ? Layer.Service : Layer.System,
|
|
403
|
-
port: parseInt(process.env.PORT || '3000'),
|
|
404
|
-
debug: {
|
|
405
|
-
all: process.env.NODE_ENV !== 'production'
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
const context = makeContext(appConfig)
|
|
411
|
-
await main(context, modules)
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
### API Route Management
|
|
415
|
-
|
|
416
|
-
```typescript
|
|
417
|
-
import {
|
|
418
|
-
module,
|
|
419
|
-
route,
|
|
420
|
-
broute,
|
|
421
|
-
filter,
|
|
422
|
-
body,
|
|
423
|
-
params,
|
|
424
|
-
guard,
|
|
425
|
-
handleRequest,
|
|
426
|
-
handleBody,
|
|
427
|
-
handleParams
|
|
428
|
-
} from '@owlmeans/server-app'
|
|
429
|
-
|
|
430
|
-
// Create REST API modules
|
|
431
|
-
const userRoutes = [
|
|
432
|
-
// GET /api/users
|
|
433
|
-
module(
|
|
434
|
-
broute('list-users', '/api/users'),
|
|
435
|
-
guard('authenticated')
|
|
436
|
-
),
|
|
437
|
-
|
|
438
|
-
// GET /api/users/:id
|
|
439
|
-
module(
|
|
440
|
-
broute('get-user', '/api/users/:id'),
|
|
441
|
-
filter(params({
|
|
442
|
-
type: 'object',
|
|
443
|
-
properties: {
|
|
444
|
-
id: { type: 'string', pattern: '^[0-9]+$' }
|
|
445
|
-
},
|
|
446
|
-
required: ['id']
|
|
447
|
-
}), guard('authenticated'))
|
|
448
|
-
),
|
|
449
|
-
|
|
450
|
-
// POST /api/users
|
|
451
|
-
module(
|
|
452
|
-
broute('create-user', '/api/users', { method: 'POST' }),
|
|
453
|
-
filter(body({
|
|
454
|
-
type: 'object',
|
|
455
|
-
properties: {
|
|
456
|
-
name: { type: 'string', minLength: 1 },
|
|
457
|
-
email: { type: 'string', format: 'email' }
|
|
458
|
-
},
|
|
459
|
-
required: ['name', 'email']
|
|
460
|
-
}), guard('authenticated'))
|
|
461
|
-
)
|
|
462
|
-
]
|
|
463
|
-
|
|
464
|
-
// Add handlers
|
|
465
|
-
userRoutes.forEach(userModule => {
|
|
466
|
-
switch (userModule.getAlias()) {
|
|
467
|
-
case 'list-users':
|
|
468
|
-
elevate(userModule, 'list-users', handleRequest(async (req, res) => {
|
|
469
|
-
const users = await listUsers()
|
|
470
|
-
res.resolve(users)
|
|
471
|
-
}))
|
|
472
|
-
break
|
|
473
|
-
case 'get-user':
|
|
474
|
-
elevate(userModule, 'get-user', handleParams(async (req, res) => {
|
|
475
|
-
const user = await getUserById(req.params.id)
|
|
476
|
-
res.resolve(user)
|
|
477
|
-
}))
|
|
478
|
-
break
|
|
479
|
-
case 'create-user':
|
|
480
|
-
elevate(userModule, 'create-user', handleBody(async (req, res) => {
|
|
481
|
-
const user = await createUser(req.body)
|
|
482
|
-
res.resolve(user, ModuleOutcome.Created)
|
|
483
|
-
}))
|
|
484
|
-
break
|
|
485
|
-
}
|
|
486
|
-
})
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
## Integration Patterns
|
|
490
|
-
|
|
491
|
-
### Microservice Architecture
|
|
73
|
+
### `modules`
|
|
492
74
|
|
|
75
|
+
Default entrypoint array providing auth and API config routes. Spread into `main()`:
|
|
493
76
|
```typescript
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
// Configure for Kubernetes deployment
|
|
497
|
-
const appConfig = config(
|
|
498
|
-
AppType.Backend,
|
|
499
|
-
'user-service',
|
|
500
|
-
klusterize({
|
|
501
|
-
namespace: 'production',
|
|
502
|
-
serviceName: 'user-service',
|
|
503
|
-
replicas: 3
|
|
504
|
-
}),
|
|
505
|
-
{
|
|
506
|
-
port: 8080,
|
|
507
|
-
services: {
|
|
508
|
-
'auth-service': {
|
|
509
|
-
host: 'auth-service.production.svc.cluster.local',
|
|
510
|
-
port: 8080
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
const context = makeContext(appConfig)
|
|
517
|
-
await main(context, [...modules, ...userServiceModules])
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
### API Gateway Pattern
|
|
521
|
-
|
|
522
|
-
```typescript
|
|
523
|
-
// API Gateway service
|
|
524
|
-
const gatewayConfig = config(
|
|
525
|
-
AppType.Backend,
|
|
526
|
-
'api-gateway',
|
|
527
|
-
{
|
|
528
|
-
port: 80,
|
|
529
|
-
services: {
|
|
530
|
-
'user-service': { host: 'user-service', port: 8080 },
|
|
531
|
-
'order-service': { host: 'order-service', port: 8080 },
|
|
532
|
-
'payment-service': { host: 'payment-service', port: 8080 }
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
)
|
|
536
|
-
|
|
537
|
-
// Proxy modules that forward requests to appropriate services
|
|
538
|
-
const proxyModules = [
|
|
539
|
-
createProxyModule('/api/users', 'user-service'),
|
|
540
|
-
createProxyModule('/api/orders', 'order-service'),
|
|
541
|
-
createProxyModule('/api/payments', 'payment-service')
|
|
542
|
-
]
|
|
77
|
+
await main(context, [...modules, ...myModules])
|
|
543
78
|
```
|
|
544
79
|
|
|
545
|
-
### Development vs Production
|
|
546
|
-
|
|
547
|
-
```typescript
|
|
548
|
-
import { makeContext, main, modules } from '@owlmeans/server-app'
|
|
549
|
-
|
|
550
|
-
const isDevelopment = process.env.NODE_ENV === 'development'
|
|
551
|
-
|
|
552
|
-
const appConfig = config(
|
|
553
|
-
AppType.Backend,
|
|
554
|
-
'app',
|
|
555
|
-
{
|
|
556
|
-
port: isDevelopment ? 3000 : 8080,
|
|
557
|
-
debug: { all: isDevelopment },
|
|
558
|
-
layer: isDevelopment ? Layer.System : Layer.Service,
|
|
559
|
-
services: isDevelopment ? {
|
|
560
|
-
'database': { host: 'localhost', port: 5432 }
|
|
561
|
-
} : {
|
|
562
|
-
'database': {
|
|
563
|
-
host: 'postgres.production.svc.cluster.local',
|
|
564
|
-
port: 5432
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
)
|
|
569
|
-
|
|
570
|
-
const context = makeContext(appConfig)
|
|
571
|
-
await main(context, modules)
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
## Error Handling
|
|
575
|
-
|
|
576
|
-
```typescript
|
|
577
|
-
import { main, makeContext } from '@owlmeans/server-app'
|
|
578
|
-
|
|
579
|
-
try {
|
|
580
|
-
const context = makeContext(appConfig)
|
|
581
|
-
await main(context, modules)
|
|
582
|
-
} catch (error) {
|
|
583
|
-
console.error('Application failed to start:', error)
|
|
584
|
-
|
|
585
|
-
// Graceful shutdown
|
|
586
|
-
process.exit(1)
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
// Handle process signals
|
|
590
|
-
process.on('SIGINT', async () => {
|
|
591
|
-
console.log('Received SIGINT, shutting down gracefully')
|
|
592
|
-
// Cleanup logic here
|
|
593
|
-
process.exit(0)
|
|
594
|
-
})
|
|
595
|
-
|
|
596
|
-
process.on('SIGTERM', async () => {
|
|
597
|
-
console.log('Received SIGTERM, shutting down gracefully')
|
|
598
|
-
// Cleanup logic here
|
|
599
|
-
process.exit(0)
|
|
600
|
-
})
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
## Best Practices
|
|
604
|
-
|
|
605
|
-
1. **Configuration Management**: Use environment variables for configuration
|
|
606
|
-
2. **Module Organization**: Group related functionality into modules
|
|
607
|
-
3. **Authentication**: Always implement proper authentication and authorization
|
|
608
|
-
4. **Error Handling**: Implement comprehensive error handling and logging
|
|
609
|
-
5. **Monitoring**: Add health check endpoints and monitoring capabilities
|
|
610
|
-
6. **Security**: Follow security best practices for API development
|
|
611
|
-
7. **Documentation**: Document your API endpoints and their contracts
|
|
612
|
-
8. **Testing**: Write comprehensive tests for your modules and handlers
|
|
613
|
-
|
|
614
|
-
## Dependencies
|
|
615
|
-
|
|
616
|
-
This package depends on:
|
|
617
|
-
- `@owlmeans/api` - API framework
|
|
618
|
-
- `@owlmeans/client-config` - Client configuration utilities
|
|
619
|
-
- `@owlmeans/config` - Configuration management
|
|
620
|
-
- `@owlmeans/context` - Context management system
|
|
621
|
-
- `@owlmeans/kluster` - Kubernetes integration
|
|
622
|
-
- `@owlmeans/module` - Module system
|
|
623
|
-
- `@owlmeans/route` - Routing functionality
|
|
624
|
-
- `@owlmeans/server-api` - Server API framework
|
|
625
|
-
- `@owlmeans/server-auth` - Server authentication
|
|
626
|
-
- `@owlmeans/server-context` - Server context management
|
|
627
|
-
- `@owlmeans/server-module` - Server module system
|
|
628
|
-
- `@owlmeans/server-route` - Server routing
|
|
629
|
-
- `@owlmeans/server-socket` - WebSocket support
|
|
630
|
-
- `@owlmeans/static-resource` - Static file serving
|
|
631
|
-
|
|
632
80
|
## Related Packages
|
|
633
81
|
|
|
634
|
-
- [`@owlmeans/server-context`](../server-context)
|
|
635
|
-
- [`@owlmeans/server-api`](../server-api)
|
|
636
|
-
- [`@owlmeans/server-
|
|
637
|
-
- [`@owlmeans/server-module`](../server-module) - Server module system
|
|
638
|
-
- [`@owlmeans/kluster`](../kluster) - Kubernetes integration
|
|
82
|
+
- [`@owlmeans/server-context`](../server-context) — `makeServerContext` called internally by `makeContext`
|
|
83
|
+
- [`@owlmeans/server-api`](../server-api) — handler wrappers re-exported here
|
|
84
|
+
- [`@owlmeans/server-entrypoint`](../server-entrypoint) — `elevate` re-exported here
|
package/build/exports.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ export { config } from '@owlmeans/server-context';
|
|
|
2
2
|
export { sservice } from '@owlmeans/server-config';
|
|
3
3
|
export { addWebService } from '@owlmeans/client-config';
|
|
4
4
|
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config';
|
|
5
|
-
export { parent, filter, body, params,
|
|
6
|
-
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/
|
|
5
|
+
export { parent, filter, body, params, EntrypointOutcome } from '@owlmeans/entrypoint';
|
|
6
|
+
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/entrypoint';
|
|
7
7
|
export { createListSchema, filterObject } from '@owlmeans/resource';
|
|
8
8
|
export type { ListResult } from '@owlmeans/resource';
|
|
9
9
|
export { AppType, BASE, Layer, assertContext } from '@owlmeans/context';
|
|
10
|
-
export { elevate,
|
|
11
|
-
export { elevate as celevate } from '@owlmeans/client-
|
|
12
|
-
export type {
|
|
13
|
-
export type {
|
|
10
|
+
export { elevate, entrypoint, guard } from '@owlmeans/server-entrypoint';
|
|
11
|
+
export { elevate as celevate } from '@owlmeans/client-entrypoint';
|
|
12
|
+
export type { ServerEntrypoint as Module, RefedEntrypointHandler } from '@owlmeans/server-entrypoint';
|
|
13
|
+
export type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
|
|
14
14
|
export { route as broute } from '@owlmeans/server-route';
|
|
15
15
|
export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api';
|
|
16
16
|
export { route } from '@owlmeans/route';
|
package/build/exports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACtF,YAAY,EAAE,eAAe,IAAI,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACnE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,YAAY,EAAE,gBAAgB,IAAI,MAAM,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACrG,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/build/exports.js
CHANGED
|
@@ -2,11 +2,11 @@ export { config } from '@owlmeans/server-context';
|
|
|
2
2
|
export { sservice } from '@owlmeans/server-config';
|
|
3
3
|
export { addWebService } from '@owlmeans/client-config';
|
|
4
4
|
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config';
|
|
5
|
-
export { parent, filter, body, params,
|
|
5
|
+
export { parent, filter, body, params, EntrypointOutcome } from '@owlmeans/entrypoint';
|
|
6
6
|
export { createListSchema, filterObject } from '@owlmeans/resource';
|
|
7
7
|
export { AppType, BASE, Layer, assertContext } from '@owlmeans/context';
|
|
8
|
-
export { elevate,
|
|
9
|
-
export { elevate as celevate } from '@owlmeans/client-
|
|
8
|
+
export { elevate, entrypoint, guard } from '@owlmeans/server-entrypoint';
|
|
9
|
+
export { elevate as celevate } from '@owlmeans/client-entrypoint';
|
|
10
10
|
export { route as broute } from '@owlmeans/server-route';
|
|
11
11
|
export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api';
|
|
12
12
|
export { route } from '@owlmeans/route';
|
package/build/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEtF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEnE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAGjE,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/build/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ServerEntrypoint } from '@owlmeans/server-entrypoint';
|
|
2
|
+
import type { CommonEntrypoint } from '@owlmeans/entrypoint';
|
|
3
3
|
import type { AppContext, AppConfig } from './types.js';
|
|
4
|
-
export declare const main: <R, C extends AppConfig, T extends AppContext<C>>(ctx: T, modules: (
|
|
4
|
+
export declare const main: <R, C extends AppConfig, T extends AppContext<C>>(ctx: T, modules: (CommonEntrypoint | ServerEntrypoint<R>)[]) => Promise<void>;
|
|
5
5
|
//# sourceMappingURL=main.d.ts.map
|
package/build/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAIvD,eAAO,MAAM,IAAI,GAAU,CAAC,EAAE,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EACxE,KAAK,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,kBAK5D,CAAA"}
|
package/build/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @TODO Remove or refactor request types. We actually don't use them and this make
|
|
2
2
|
// a mess with <R
|
|
3
3
|
export const main = async (ctx, modules) => {
|
|
4
|
-
ctx.
|
|
4
|
+
ctx.registerEntrypoints(modules);
|
|
5
5
|
await ctx.configure().init();
|
|
6
6
|
await ctx.getApiServer().listen();
|
|
7
7
|
};
|
package/build/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAMA,mFAAmF;AACnF,iBAAiB;AACjB,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAMA,mFAAmF;AACnF,iBAAiB;AACjB,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAAM,EAAE,OAAmD,EAC3D,EAAE;IACF,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAA;AACnC,CAAC,CAAA"}
|
package/build/modules.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const modules: import("@owlmeans/server-
|
|
1
|
+
export declare const modules: import("@owlmeans/server-entrypoint").ServerEntrypoint<unknown>[];
|
|
2
2
|
//# sourceMappingURL=modules.d.ts.map
|
package/build/modules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,mEAA0B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "tsc -b",
|
|
@@ -20,26 +21,27 @@
|
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@owlmeans/api": "^0.1.
|
|
24
|
-
"@owlmeans/client-config": "^0.1.
|
|
25
|
-
"@owlmeans/client-
|
|
26
|
-
"@owlmeans/config": "^0.1.
|
|
27
|
-
"@owlmeans/context": "^0.1.
|
|
28
|
-
"@owlmeans/kluster": "^0.1.
|
|
29
|
-
"@owlmeans/
|
|
30
|
-
"@owlmeans/route": "^0.1.
|
|
31
|
-
"@owlmeans/server-api": "^0.1.
|
|
32
|
-
"@owlmeans/server-auth": "^0.1.
|
|
33
|
-
"@owlmeans/server-context": "^0.1.
|
|
34
|
-
"@owlmeans/server-
|
|
35
|
-
"@owlmeans/server-route": "^0.1.
|
|
36
|
-
"@owlmeans/server-socket": "^0.1.
|
|
37
|
-
"@owlmeans/static-resource": "^0.1.
|
|
24
|
+
"@owlmeans/api": "^0.1.3",
|
|
25
|
+
"@owlmeans/client-config": "^0.1.3",
|
|
26
|
+
"@owlmeans/client-entrypoint": "^0.1.3",
|
|
27
|
+
"@owlmeans/config": "^0.1.3",
|
|
28
|
+
"@owlmeans/context": "^0.1.3",
|
|
29
|
+
"@owlmeans/kluster": "^0.1.3",
|
|
30
|
+
"@owlmeans/entrypoint": "^0.1.3",
|
|
31
|
+
"@owlmeans/route": "^0.1.3",
|
|
32
|
+
"@owlmeans/server-api": "^0.1.3",
|
|
33
|
+
"@owlmeans/server-auth": "^0.1.3",
|
|
34
|
+
"@owlmeans/server-context": "^0.1.3",
|
|
35
|
+
"@owlmeans/server-entrypoint": "^0.1.3",
|
|
36
|
+
"@owlmeans/server-route": "^0.1.3",
|
|
37
|
+
"@owlmeans/server-socket": "^0.1.3",
|
|
38
|
+
"@owlmeans/static-resource": "^0.1.3"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
41
|
+
"@owlmeans/dep-config": "workspace:*",
|
|
40
42
|
"@types/node": "^24.10.1",
|
|
41
43
|
"nodemon": "^3.1.11",
|
|
42
|
-
"typescript": "^
|
|
44
|
+
"typescript": "^6.0.2"
|
|
43
45
|
},
|
|
44
46
|
"publishConfig": {
|
|
45
47
|
"access": "public"
|
package/src/exports.ts
CHANGED
|
@@ -3,15 +3,15 @@ export { config } from '@owlmeans/server-context'
|
|
|
3
3
|
export { sservice } from '@owlmeans/server-config'
|
|
4
4
|
export { addWebService } from '@owlmeans/client-config'
|
|
5
5
|
export { service, toConfigRecord, PLUGINS } from '@owlmeans/config'
|
|
6
|
-
export { parent, filter, body, params,
|
|
7
|
-
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/
|
|
6
|
+
export { parent, filter, body, params, EntrypointOutcome } from '@owlmeans/entrypoint'
|
|
7
|
+
export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/entrypoint'
|
|
8
8
|
export { createListSchema, filterObject } from '@owlmeans/resource'
|
|
9
9
|
export type { ListResult } from '@owlmeans/resource'
|
|
10
10
|
export { AppType, BASE, Layer, assertContext } from '@owlmeans/context'
|
|
11
|
-
export { elevate,
|
|
12
|
-
export { elevate as celevate } from '@owlmeans/client-
|
|
13
|
-
export type {
|
|
14
|
-
export type {
|
|
11
|
+
export { elevate, entrypoint, guard } from '@owlmeans/server-entrypoint'
|
|
12
|
+
export { elevate as celevate } from '@owlmeans/client-entrypoint'
|
|
13
|
+
export type { ServerEntrypoint as Module, RefedEntrypointHandler } from '@owlmeans/server-entrypoint'
|
|
14
|
+
export type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
15
15
|
export { route as broute } from '@owlmeans/server-route'
|
|
16
16
|
export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api'
|
|
17
17
|
export { route } from '@owlmeans/route'
|
package/src/main.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { ServerEntrypoint } from '@owlmeans/server-entrypoint'
|
|
4
|
+
import type { CommonEntrypoint } from '@owlmeans/entrypoint'
|
|
5
5
|
import type { AppContext, AppConfig } from './types.js'
|
|
6
6
|
|
|
7
7
|
// @TODO Remove or refactor request types. We actually don't use them and this make
|
|
8
8
|
// a mess with <R
|
|
9
9
|
export const main = async <R, C extends AppConfig, T extends AppContext<C>>(
|
|
10
|
-
ctx: T, modules: (
|
|
10
|
+
ctx: T, modules: (CommonEntrypoint | ServerEntrypoint<R>)[]
|
|
11
11
|
) => {
|
|
12
|
-
ctx.
|
|
12
|
+
ctx.registerEntrypoints(modules)
|
|
13
13
|
await ctx.configure().init()
|
|
14
14
|
await ctx.getApiServer().listen()
|
|
15
15
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": [
|
|
3
|
-
"
|
|
3
|
+
"@owlmeans/dep-config/tsconfig.base.json",
|
|
4
|
+
"@owlmeans/dep-config/tsconfig.node.json"
|
|
4
5
|
],
|
|
5
6
|
"compilerOptions": {
|
|
6
|
-
"rootDir": "./src/",
|
|
7
|
-
"outDir": "./build/"
|
|
8
|
-
"moduleResolution": "Bundler",
|
|
7
|
+
"rootDir": "./src/",
|
|
8
|
+
"outDir": "./build/"
|
|
9
9
|
},
|
|
10
10
|
"exclude": [
|
|
11
11
|
"./dist/**/*",
|
|
12
12
|
"./build/**/*",
|
|
13
13
|
"./*.ts"
|
|
14
14
|
]
|
|
15
|
-
}
|
|
15
|
+
}
|