@owlmeans/server-app 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -1,638 +1,84 @@
1
1
  # @owlmeans/server-app
2
2
 
3
- The **@owlmeans/server-app** package provides a comprehensive server application framework for OwlMeans Common Libraries, offering a complete foundation for building secure, scalable backend applications with authentication, API services, and module management.
3
+ The main entry point for OwlMeans backend services — aggregates server packages and provides the `makeContext` + `main` bootstrap functions.
4
4
 
5
- ## Purpose
5
+ ## Overview
6
6
 
7
- This package serves as a high-level application framework that combines multiple OwlMeans packages into a cohesive server application foundation, specifically designed for:
8
-
9
- - **Complete Application Setup**: Quickly bootstrap full-featured server applications
10
- - **Integrated Authentication**: Built-in authentication and authorization capabilities
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
- npm install @owlmeans/server-app
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
- #### `main<R, C extends AppConfig, T extends AppContext<C>>(ctx: T, modules: (CommonModule | ServerModule<R>)[]): Promise<void>`
88
-
89
- Main application entry point that registers modules, initializes the context, and starts the API server.
18
+ ## Usage
90
19
 
91
- **Parameters:**
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, makeContext } from '@owlmeans/server-app'
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
- 'my-server-app',
177
- service('database', {
178
- host: process.env.DB_HOST || 'localhost',
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
- ### Custom Module Integration
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
- // Create custom modules
215
- const userModule = module(
216
- route('users', '/api/users', { method: 'GET' }),
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
- ### Database Integration
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
- // Register database-related modules
273
- const databaseModules = [
274
- // Your database modules here
275
- ]
48
+ ### `makeContext<C, T>(cfg, customize?): T`
276
49
 
277
- await main(context, [...modules, ...databaseModules])
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
- ### Authentication and Authorization
52
+ ### `main<R, C, T>(ctx, entrypoints): Promise<void>`
281
53
 
282
- ```typescript
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
- // Create protected admin module
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
- elevate(adminModule, 'admin', handleRequest(async (req, res) => {
301
- // Only authenticated users with proper keys can access
302
- const adminData = await getAdminData()
303
- res.resolve(adminData)
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
- const context = makeContext(appConfig)
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
- import { makeContext, main, klusterize } from '@owlmeans/server-app'
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) - Server context management
635
- - [`@owlmeans/server-api`](../server-api) - Server API framework
636
- - [`@owlmeans/server-auth`](../server-auth) - Server authentication
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
@@ -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, ModuleOutcome } from '@owlmeans/module';
6
- export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/module';
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, module, guard } from '@owlmeans/server-module';
11
- export { elevate as celevate } from '@owlmeans/client-module';
12
- export type { ServerModule as Module, RefedModuleHandler } from '@owlmeans/server-module';
13
- export type { ClientModule } from '@owlmeans/client-module';
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';
@@ -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,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC9E,YAAY,EAAE,eAAe,IAAI,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChG,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,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAC7D,YAAY,EAAE,YAAY,IAAI,MAAM,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACzF,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,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"}
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, ModuleOutcome } from '@owlmeans/module';
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, module, guard } from '@owlmeans/server-module';
9
- export { elevate as celevate } from '@owlmeans/client-module';
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';
@@ -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,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAE9E,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,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAG7D,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"}
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 { ServerModule } from '@owlmeans/server-module';
2
- import type { CommonModule } from '@owlmeans/module';
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: (CommonModule | ServerModule<R>)[]) => Promise<void>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,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,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,kBAKpD,CAAA"}
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.registerModules(modules);
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,OAA2C,EACnD,EAAE;IACF,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAC5B,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAA;AACnC,CAAC,CAAA"}
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"}
@@ -1,2 +1,2 @@
1
- export declare const modules: import("@owlmeans/server-module").ServerModule<unknown>[];
1
+ export declare const modules: import("@owlmeans/server-entrypoint").ServerEntrypoint<unknown>[];
2
2
  //# sourceMappingURL=modules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,2DAA0B,CAAA"}
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,6 @@
1
1
  {
2
2
  "name": "@owlmeans/server-app",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -21,26 +21,27 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@owlmeans/api": "^0.1.2",
25
- "@owlmeans/client-config": "^0.1.2",
26
- "@owlmeans/client-module": "^0.1.2",
27
- "@owlmeans/config": "^0.1.2",
28
- "@owlmeans/context": "^0.1.2",
29
- "@owlmeans/kluster": "^0.1.2",
30
- "@owlmeans/module": "^0.1.2",
31
- "@owlmeans/route": "^0.1.2",
32
- "@owlmeans/server-api": "^0.1.2",
33
- "@owlmeans/server-auth": "^0.1.2",
34
- "@owlmeans/server-context": "^0.1.2",
35
- "@owlmeans/server-module": "^0.1.2",
36
- "@owlmeans/server-route": "^0.1.2",
37
- "@owlmeans/server-socket": "^0.1.2",
38
- "@owlmeans/static-resource": "^0.1.2"
24
+ "@owlmeans/api": "^0.1.4",
25
+ "@owlmeans/client-config": "^0.1.4",
26
+ "@owlmeans/client-entrypoint": "^0.1.4",
27
+ "@owlmeans/config": "^0.1.4",
28
+ "@owlmeans/context": "^0.1.4",
29
+ "@owlmeans/kluster": "^0.1.4",
30
+ "@owlmeans/entrypoint": "^0.1.4",
31
+ "@owlmeans/route": "^0.1.4",
32
+ "@owlmeans/server-api": "^0.1.4",
33
+ "@owlmeans/server-auth": "^0.1.4",
34
+ "@owlmeans/server-context": "^0.1.4",
35
+ "@owlmeans/server-entrypoint": "^0.1.4",
36
+ "@owlmeans/server-route": "^0.1.4",
37
+ "@owlmeans/server-socket": "^0.1.4",
38
+ "@owlmeans/static-resource": "^0.1.4"
39
39
  },
40
40
  "devDependencies": {
41
+ "@owlmeans/dep-config": "workspace:*",
41
42
  "@types/node": "^24.10.1",
42
43
  "nodemon": "^3.1.11",
43
- "typescript": "^5.8.3"
44
+ "typescript": "^6.0.2"
44
45
  },
45
46
  "publishConfig": {
46
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, ModuleOutcome } from '@owlmeans/module'
7
- export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/module'
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, module, guard } from '@owlmeans/server-module'
12
- export { elevate as celevate } from '@owlmeans/client-module'
13
- export type { ServerModule as Module, RefedModuleHandler } from '@owlmeans/server-module'
14
- export type { ClientModule } from '@owlmeans/client-module'
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 { ServerModule } from '@owlmeans/server-module'
4
- import type { CommonModule } from '@owlmeans/module'
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: (CommonModule | ServerModule<R>)[]
10
+ ctx: T, modules: (CommonEntrypoint | ServerEntrypoint<R>)[]
11
11
  ) => {
12
- ctx.registerModules(modules)
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
- "../tsconfig.default.json",
3
+ "@owlmeans/dep-config/tsconfig.base.json",
4
+ "@owlmeans/dep-config/tsconfig.node.json"
4
5
  ],
5
6
  "compilerOptions": {
6
- "rootDir": "./src/", /* Specify the root folder within your source files. */
7
- "outDir": "./build/", /* Specify an output folder for all emitted files. */
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
+ }