@owlmeans/server-app 0.1.18-rc.8 → 0.1.19-rc.0

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,87 +1,306 @@
1
1
  # @owlmeans/server-app
2
2
 
3
- The main entry point for OwlMeans backend services — aggregates server packages and provides the `makeContext` + `main` bootstrap functions.
4
-
5
- ## Overview
6
-
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
3
+ The bootstrap package for an OwlMeans backend process. An application uses it in every HTTP or
4
+ WebSocket API service: `makeContext` builds the base server context (Fastify API server, API
5
+ client, socket service, static resources and the Ed25519 auth guard), `main` registers the
6
+ entrypoints, initializes the context and starts listening, and the package re-exports the server
7
+ vocabulary (`bind`, `handlers`, `config`, `sservice`, `route`, ...) so backend code has one import
8
+ target. Do not use it in a shared `common` package that only declares protocols (depend on
9
+ `@owlmeans/entrypoint` and `@owlmeans/route` there), in the auth manager process (use
10
+ `@owlmeans/server-auth/manager`, which has its own `makeContext` and `main`), or in a browser app
11
+ (use `@owlmeans/web-panel`).
11
12
 
12
13
  ## Installation
13
14
 
14
15
  ```bash
15
- bun add @owlmeans/server-app
16
+ bun add @owlmeans/server-app@^0.1.19-rc.0
16
17
  ```
17
18
 
19
+ ## Concepts
20
+
21
+ - **Application context** — one per process, built by the app's own factory that calls
22
+ `makeContext(cfg)` and then adds its own resources and services with idempotent `append*` mixins.
23
+ `AppConfig` / `AppContext` are the types that factory extends.
24
+ - **`customize` flag** — `makeContext(cfg, true)` skips the default in-process `AUTH_CACHE` and
25
+ `appendAuthService`, so the app can register a shared cache (Redis) and the auth guard itself.
26
+ - **Framework entrypoints** — `entrypoints` is the list of bindings every service carries: the
27
+ `@owlmeans/server-auth` dispatcher bindings and the `@owlmeans/api-config-server` config endpoint.
28
+ - **Bindings** — the app's server-local list of `bind(protocol, handler)` results, materialized from
29
+ the shared protocol tree and passed to `main`.
30
+ - **Port hold** — `holdApiPort` answers on the service port while the context initializes, so a
31
+ slow or failing boot answers 503 instead of a connection error.
32
+
18
33
  ## Usage
19
34
 
20
- Bootstrap a backend service:
35
+ ### 1. Config
36
+
37
+ `config(service, base?)` creates a backend config for the named service; `sservice` declares a
38
+ backend service route and `service` any other (frontend) one. A service with `opened: true` listens
39
+ on `0.0.0.0`, otherwise on `127.0.0.1`.
40
+
41
+ ```ts
42
+ import { AppType, config, service, sservice } from '@owlmeans/server-app'
43
+ import type { AppConfig } from '@owlmeans/server-app'
44
+ import { MY_APP_API, MY_APP_WEB, commonConfig } from 'my-app-common'
21
45
 
22
- ```typescript
23
- import { makeContext, main, modules, config, service, AppType, Layer } from '@owlmeans/server-app'
46
+ export interface Config extends AppConfig { }
24
47
 
25
- const appConfig = config(
26
- AppType.Backend,
27
- 'manager-api',
28
- service({ service: 'mongo', host: process.env.MONGO_HOST!, port: 27017 }),
29
- { layer: Layer.Service, port: 3000 }
30
- )
48
+ const cfg = config<Config>(MY_APP_API, commonConfig as Config)
31
49
 
32
- const context = makeContext(appConfig)
33
- await main(context, [...modules, ...appModules])
50
+ sservice({ service: MY_APP_API, internalHost: 'localhost', internalPort: 3000 }, cfg)
51
+ cfg.services[MY_APP_API].opened = true
52
+
53
+ service({ type: AppType.Frontend, service: MY_APP_WEB, host: 'localhost', port: 5173 }, cfg)
54
+
55
+ export default cfg
34
56
  ```
35
57
 
36
- Elevate an entrypoint with a handler:
58
+ ### 2. Context factory
59
+
60
+ The app's factory composes the base context and adds its own resources. For development or a
61
+ single replica the defaults are enough:
62
+
63
+ ```ts
64
+ import { makeContext as makeAppContext } from '@owlmeans/server-app'
65
+ import type { AppContext } from '@owlmeans/server-app'
66
+ import { appendStaticResource } from '@owlmeans/static-resource'
67
+ import type { StaticResourceAppend } from '@owlmeans/static-resource'
68
+ import type { Resource } from '@owlmeans/resource'
69
+ import type { Project } from 'my-app-common'
70
+ import type { Config } from './config.js'
71
+
72
+ export const PROJECTS = 'my-app:projects'
73
+
74
+ export interface Context<C extends Config = Config> extends AppContext<C>, StaticResourceAppend {
75
+ project: () => Resource<Project>
76
+ }
37
77
 
38
- ```typescript
39
- import { elevate, handleBody, guard, GUARD_ED25519, modules } from '@owlmeans/server-app'
78
+ export const makeContext = <C extends Config, T extends Context<C>>(cfg: C): T => {
79
+ const context = makeAppContext<C, T>(cfg)
40
80
 
41
- elevate(modules, 'project-create', handleBody<CreateProject>(async (payload, ctx) => {
42
- return await (ctx as Context).project().create(payload)
43
- }), guard(GUARD_ED25519))
81
+ appendStaticResource<C, T>(context, PROJECTS)
82
+ context.project = () => context.getStaticResource<Project>(PROJECTS)
83
+
84
+ return context
85
+ }
44
86
  ```
45
87
 
46
- ## API
88
+ A scaled deployment passes `customize: true` and registers a shared auth cache before the guard:
89
+
90
+ ```ts
91
+ import { klusterize, makeContext as makeAppContext } from '@owlmeans/server-app'
92
+ import { appendMongo } from '@owlmeans/mongo'
93
+ import { appendRedis } from '@owlmeans/redis'
94
+ import { makeRedisResource } from '@owlmeans/redis-resource'
95
+ import { appendAuthService, AUTH_CACHE } from '@owlmeans/server-auth'
96
+ import { appendAuthIdentityResources } from '@owlmeans/server-auth-identity'
47
97
 
48
- ### `makeContext<C, T>(cfg, customize?): T`
98
+ export const makeContext = <C extends Config, T extends Context<C>>(cfg: C): T => {
99
+ const context = makeAppContext<C, T>(cfg, true)
100
+ klusterize<C, T>(context)
101
+ appendMongo<C, T>(context)
102
+ appendRedis<C, T>(context)
49
103
 
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.
104
+ context.registerResource(makeRedisResource(AUTH_CACHE))
105
+ appendAuthService<C, T>(context)
106
+ appendAuthIdentityResources(context)
107
+
108
+ // app-local Mongo resource factory, same `project()` accessor as above
109
+ context.registerResource(makeProjectResource(PROJECTS))
110
+ context.project = () => context.resource(PROJECTS)
111
+
112
+ return context
113
+ }
114
+ ```
51
115
 
52
- ### `main<R, C, T>(ctx, entrypoints): Promise<void>`
116
+ ### 3. Handlers bound to shared protocols
117
+
118
+ Protocols live in the shared package; guards and gates on a parent are inherited by its children.
119
+
120
+ ```ts
121
+ // my-app-common/src/protocols.ts
122
+ import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
123
+ import { route, RouteMethod, socket } from '@owlmeans/route'
124
+ import { DEFAULT_GUARD } from '@owlmeans/auth-common'
125
+
126
+ const projectBase = openProtocol(route('my-app:api:project', '/project'), {
127
+ guards: DEFAULT_GUARD,
128
+ gate: { alias: MY_APP_GATE, params: ['my-app-project-{entity}'] },
129
+ })
130
+
131
+ export const projectProtocols = {
132
+ base: projectBase,
133
+ list: protocol(
134
+ route('my-app:api:project:list', '/', { parent: projectBase, method: RouteMethod.GET }),
135
+ contract(typed<Project[]>()),
136
+ ),
137
+ create: protocol(
138
+ route('my-app:api:project:create', '/', { parent: projectBase, method: RouteMethod.POST }),
139
+ contract.request({ body: typed<CreateProject>(CreateProjectSchema) }, typed<Project>()),
140
+ ),
141
+ get: protocol(
142
+ route('my-app:api:project:get', '/:id', { parent: projectBase, method: RouteMethod.GET }),
143
+ contract.request({ params: typed<ProjectParams>(ProjectParamsSchema) }, typed<Project>()),
144
+ ),
145
+ watch: protocol(
146
+ route('my-app:api:project:watch', '/:id/watch', socket({ parent: projectBase })),
147
+ contract.request({ params: typed<ProjectParams>(ProjectParamsSchema) }, typed<void>()),
148
+ ),
149
+ }
150
+ ```
53
151
 
54
- Registers entrypoints, calls `configure().init()`, then starts the Fastify server.
152
+ ```ts
153
+ // my-app-api/src/app/project.ts
154
+ import { handlers } from '@owlmeans/server-app'
155
+ import { makeEntityScope } from '@owlmeans/auth-common'
156
+ import { projectProtocols } from 'my-app-common'
157
+ import type { Context } from '../context.js'
55
158
 
56
- ### Re-exported symbols (for convenience)
159
+ const api = handlers<Context>()
57
160
 
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 |
161
+ export const list = api.request(projectProtocols.list, async (request, context) => {
162
+ const { items } = await context.project().list({ entityId: makeEntityScope(request).requireEntityKey() })
163
+ return items
164
+ })
72
165
 
73
- ### `modules`
166
+ export const create = api.body(projectProtocols.create, async (body, context, request) =>
167
+ context.project().create({ ...body, entityId: makeEntityScope(request).requireEntityKey() }))
74
168
 
75
- Default entrypoint array providing auth and API config routes. Spread into `main()`:
76
- ```typescript
77
- await main(context, [...modules, ...myModules])
169
+ export const get = api.params(projectProtocols.get, async ({ id }, context, request) =>
170
+ context.project().load({ id, entityId: makeEntityScope(request).requireEntityKey() }))
78
171
  ```
79
172
 
80
- ## Related Packages
173
+ ### 4. Entrypoint list and `main`
174
+
175
+ ```ts
176
+ // my-app-api/src/entrypoints.ts
177
+ import { bind, entrypoints } from '@owlmeans/server-app'
178
+ import { connection } from '@owlmeans/server-socket'
179
+ import { projectProtocols } from 'my-app-common'
180
+ import * as project from './app/project.js'
181
+
182
+ export const appEntrypoints = [
183
+ ...entrypoints,
184
+ bind(projectProtocols.base),
185
+ bind(projectProtocols.list, project.list),
186
+ bind(projectProtocols.create, project.create),
187
+ bind(projectProtocols.get, project.get),
188
+ // socket protocols bind the same way; see @owlmeans/server-socket
189
+ bind(projectProtocols.watch, connection(projectProtocols.watch, async (conn, context, request) => {
190
+ await conn.notify('project:ready', { id: request.params.id })
191
+ })),
192
+ ]
193
+
194
+ // my-app-api/src/index.ts
195
+ import { main } from '@owlmeans/server-app'
196
+ import config from './config.js'
197
+ import { makeContext } from './context.js'
198
+ import { appEntrypoints } from './entrypoints.js'
199
+
200
+ await main(makeContext(config), appEntrypoints)
201
+ ```
202
+
203
+ ### 5. A boot that holds the port
204
+
205
+ `main` is `registerEntrypoints` + `configure().init()` + `getApiServer().listen()`. Write it out when
206
+ something must run between init and listen, or when the port must answer during a long boot:
207
+
208
+ ```ts
209
+ import { holdApiPort } from '@owlmeans/server-app'
210
+ import type { ApiPortHold } from '@owlmeans/server-app'
211
+
212
+ const boot = async () => {
213
+ let hold: ApiPortHold
214
+ try {
215
+ hold = await holdApiPort(config, { okPath: '/healthz', payload: () => ({ status: 'booting' }) })
216
+ } catch (error) {
217
+ console.error('port is taken', error)
218
+ process.exit(1) // a failed bind must be fatal
219
+ }
220
+
221
+ const context = makeContext(config)
222
+ context.registerEntrypoints(appEntrypoints)
223
+ try {
224
+ await context.configure().init()
225
+ await seed(context)
226
+ } catch (error) {
227
+ console.error('boot failed', error) // the hold keeps answering 503
228
+ return
229
+ }
230
+
231
+ await hold.release()
232
+ await context.getApiServer().listen()
233
+ }
234
+
235
+ await boot()
236
+ ```
237
+
238
+ ## API
239
+
240
+ ### Bootstrap
241
+
242
+ | Symbol | Kind | Purpose |
243
+ |---|---|---|
244
+ | `makeContext<C, T>(cfg, customize = false)` | function | Server context with API server, API client, socket service and middleware, default static resource; unless `customize`, also a static `AUTH_CACHE` and `appendAuthService` |
245
+ | `main<R, C, T>(ctx, entrypoints)` | function | Register entrypoints, `configure().init()`, then `getApiServer().listen()` |
246
+ | `entrypoints` | const | Framework bindings: `@owlmeans/server-auth` dispatcher + `@owlmeans/api-config-server` |
247
+ | `AppConfig` | type | `ServerConfig & KlusterConfig` with `services: Record<string, ServiceRoute>` |
248
+ | `AppContext<C>` | type | `ServerContext<C> & AuthServiceAppend & ApiServerAppend` |
249
+
250
+ ### Re-exports
251
+
252
+ | Symbol | Kind | Source |
253
+ |---|---|---|
254
+ | `config` | function | `@owlmeans/server-context` — `config(service, cfg?)` |
255
+ | `sservice` | function | `@owlmeans/server-config` — declare a backend service route |
256
+ | `service`, `configHelper`, `PLUGINS` | function / helper / const | `@owlmeans/config` |
257
+ | `PluginConfig` | type | `@owlmeans/config` |
258
+ | `addWebService` | function | `@owlmeans/client-config` |
259
+ | `contract`, `protocol`, `typed`, `EntrypointOutcome` | function / enum | `@owlmeans/entrypoint` |
260
+ | `Request`, `Response` | type | `AbstractRequest`, `AbstractResponse` from `@owlmeans/entrypoint` |
261
+ | `bind`, `bindAll` | function | `@owlmeans/server-entrypoint` |
262
+ | `handlers`, `holdApiPort` | function | `@owlmeans/server-api` |
263
+ | `handleBody`, `handleParams`, `handleRequest`, `handleIntermediate` | function | `@owlmeans/server-api` — unbound compatibility wrappers |
264
+ | `ApiPortHold`, `ApiPortHoldOptions` | type | `@owlmeans/server-api` |
265
+ | `route` | function | `@owlmeans/route` |
266
+ | `broute` | function | `route` from `@owlmeans/server-route` |
267
+ | `ClientEntrypoint` | type | `@owlmeans/client-entrypoint` |
268
+ | `AppType`, `BASE`, `assertContext` | enum / const / function | `@owlmeans/context` |
269
+ | `DAUTH_GUARD` | const | `DEFAULT_ALIAS` (`'auth'`) from `@owlmeans/server-auth` |
270
+ | `GUARD_ED25519`, `BED255_CASHE_RESOURCE` | const | `@owlmeans/auth-common` |
271
+ | `klusterize` | function | `@owlmeans/kluster` |
272
+ | `createListSchema`, `filterObject` | function | `@owlmeans/resource` |
273
+ | `Criteria`, `ListOptions`, `ListQuery`, `ListResult`, `Sort` | type | `@owlmeans/resource` |
274
+
275
+ ## Common pitfalls
276
+
277
+ - Keep `protocol()` declarations in the shared package; a server supplies implementations with
278
+ `bind()` and `handlers()` and never changes a declaration or finds it by alias.
279
+ - Bind parent and group declarations (`bind(projectProtocols.base)`) as well as leaves — parents
280
+ establish inherited paths, guards and gates.
281
+ - `entrypoints` holds framework registrations. Spread it into a new local array; do not mutate it.
282
+ - The default `makeContext(cfg)` backs `AUTH_CACHE` with an in-process static resource, correct for
283
+ one replica only. A scaled service passes `customize: true` and registers a Redis resource under
284
+ `AUTH_CACHE` before `appendAuthService`.
285
+ - Validation belongs in `contract()` with `typed()` or `schema()`, not in a wrapper around a handler.
286
+ Prefer `handlers<Context>()` over the unbound `handleBody` / `handleParams` / `handleRequest`.
287
+ - Key organization-scoped records on `makeEntityScope(request).requireEntityKey()` / `.requireEntity()`; never
288
+ read an organization id from the token — `entitySlug` is the only organization value on the wire.
289
+ - Reference other services' entrypoints with `context.entrypoint(protocol)` and the protocol object,
290
+ without a caller-side response generic.
291
+ - A `holdApiPort` bind failure (`EADDRINUSE`) must end the process with a non-zero exit.
292
+
293
+ ## Related packages
81
294
 
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
295
+ - [`@owlmeans/server-context`](../server-context) — `makeServerContext`, called by `makeContext`
296
+ - [`@owlmeans/server-api`](../server-api) — the Fastify API server and `handlers`
297
+ - [`@owlmeans/server-entrypoint`](../server-entrypoint) — `bind` / `bindAll`
298
+ - [`@owlmeans/server-socket`](../server-socket) — WebSocket bindings
299
+ - [`@owlmeans/server-auth`](../server-auth) — the Ed25519 guard and `AUTH_CACHE`
300
+ - [`@owlmeans/server-auth-identity`](../server-auth-identity) — local identity and entity resolver
301
+ - [`@owlmeans/entrypoint`](../entrypoint) and [`@owlmeans/route`](../route) — shared protocol declarations
302
+ - [`@owlmeans/static-resource`](../static-resource) — in-memory resources
303
+ - [`@owlmeans/kluster`](../kluster) — `klusterize`
85
304
 
86
305
  <!-- owlmeans:agent-guidance:start -->
87
306
  ## Agent guidance
@@ -91,7 +310,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
91
310
  your project's skill store (`.agents/skills/`):
92
311
 
93
312
  ```sh
94
- npx @owlmeans/agent-skills
313
+ npx @owlmeans/agent-skills@^0.1.19-rc.0
95
314
  ```
96
315
 
97
316
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
- "schemaVersion": 2,
2
+ "schemaVersion": 3,
3
3
  "package": "@owlmeans/server-app",
4
- "version": "0.1.18-rc.7",
5
- "generatedAt": "2026-08-21T09:53:56.642Z",
4
+ "version": "0.1.19-rc.0",
5
+ "generatedAt": "2026-10-31T12:13:02.383Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,82 +1,45 @@
1
1
  ---
2
2
  name: server-app
3
- description: How to use @owlmeans/server-app — main() entry point, handleRequest()/handleBody() handler wrappers, elevate()/celevate() to attach handlers to module declarations, sservice() to register backend services. Auto-invoked when working with the server entry point or request handlers.
4
- user-invocable: false
3
+ description: Build OwlMeans server applications from immutable entrypoint protocol declarations. Use when starting a server, binding endpoint implementations, configuring services, or registering server entrypoints.
5
4
  ---
6
5
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
7
6
 
8
- # @owlmeans/server-app
7
+ # Server application entrypoints
9
8
 
10
- **Layer:** Server
11
- **Install:** `"@owlmeans/server-app": "^0.1.18-rc.7"` in `dependencies`
9
+ **Install:** `bun add @owlmeans/server-app@^0.1.19-rc.0`
12
10
 
13
- ## Key Exports
11
+ Declare routes and request/response contracts in a shared package with `protocol()` or
12
+ `openProtocol()`. A server package supplies local implementations with `bind()` and `handlers()`;
13
+ it never changes a shared declaration by alias.
14
14
 
15
- | Export | Description |
16
- |--------|-------------|
17
- | `main<E, C, T>(context, entrypoints)` | Entry point — registers all entrypoints, configures/inits the context, then boots the Fastify API server (`@owlmeans/server-api`) |
18
- | `handleRequest(fn)` | Wrap an async function as a server handler `(req, context) => result` |
19
- | `handleBody<T>(fn)` | Wrap an async function with validated body — `(payload, context, req) => result` |
20
- | `elevate(modules, alias, handler)` | Attach a handler to an entrypoint declaration |
21
- | `celevate(modules, alias, handler)` | Conditional elevate — only if entrypoint exists |
22
- | `sservice(options, cfg)` | Register a server-side service entry in the config |
23
- | `modules` | Built-in system entrypoints — spread into `appEntrypoints` |
24
- | `Context`, `Config`, `ClientEntrypoint` re-exports | Common types |
15
+ ```ts
16
+ import { bind, entrypoints, handlers } from '@owlmeans/server-app'
17
+ import { projectProtocols } from 'project-common'
18
+ import { createProject } from './app/project.js'
25
19
 
26
- ## Usage
20
+ const api = handlers<Context>()
27
21
 
28
- ### Entry point
29
- ```typescript
30
- // index.ts
31
- import { main } from '@owlmeans/server-app'
32
- import config from './config.js'
33
- import { makeContext } from './context.js'
34
- import { appEntrypoints } from './entrypoints.js'
35
-
36
- const context = makeContext(config)
37
- main<{}, Config, Context>(context, appEntrypoints)
38
- ```
39
-
40
- ### Handlers
41
- ```typescript
42
- import { handleRequest, handleBody } from '@owlmeans/server-app'
43
- import { AuthUnknown } from '@owlmeans/auth'
44
- import type { ClientEntrypoint } from '@owlmeans/server-app'
45
-
46
- export const list = handleRequest(async (req, context) => {
47
- if (req.auth?.entityId == null) throw new AuthUnknown('entity')
48
- const ctx = context as Context
49
- const { items } = await ctx.project().list({ entityId: req.auth.entityId })
50
- return items
51
- })
52
-
53
- export const create = handleBody<CreateProject>(async (payload, context, req) => {
54
- const ctx = context as Context
55
- const [result] = await ctx.entrypoint<ClientEntrypoint<Project>>(agent.project.create).call({
56
- body: { prompt: payload.prompt, entity: req.auth?.entityId }
57
- })
58
- return result
59
- })
22
+ export const serverBindings = [
23
+ ...entrypoints,
24
+ bind(projectProtocols.base),
25
+ bind(projectProtocols.create, api.body(projectProtocols.create, createProject)),
26
+ ]
60
27
  ```
61
28
 
62
- ### Entrypoint elevation
63
- ```typescript
64
- // entrypoints.ts
65
- import { elevate, modules as systemEntrypoints } from '@owlmeans/server-app'
66
- import { managerEntrypoints } from 'my-common'
67
- import { create, list } from './app/project/index.js'
68
-
69
- elevate(managerEntrypoints, manager.back.project.create, create)
70
- elevate(managerEntrypoints, manager.back.project.list, list)
71
-
72
- export const appEntrypoints = [...systemEntrypoints, ...paymentEntrypoints, ...managerEntrypoints]
73
- ```
29
+ `handlers<Context>().body`, `.params` and `.request` infer request sections and response values
30
+ from the declaration. Use `.request` for a transport-level handler that needs the complete request
31
+ boundary.
74
32
 
75
- A backend alias that carries only a `guard()`/`gate()` for its children still needs a **bare**
76
- `elevate(entrypoints, alias)` — that is what makes the declaration a live server route group.
33
+ ## Rules
77
34
 
78
- ## Depends On
35
+ - Keep `protocol()` declarations in the common package shared by callers and servers.
36
+ - Bind parent/group declarations as well as leaves; parents establish inherited paths and access.
37
+ - Use direct protocol references in `context.entrypoint(protocol)`; do not supply a caller-side
38
+ response generic.
39
+ - Model validation belongs in `contract()` with `typed()` or `schema()`, not in a wrapper around a
40
+ handler.
41
+ - `entrypoints` contains framework registrations. Add local entrypoints to a new array and register
42
+ that array during context initialization.
79
43
 
80
- - `@owlmeans/server-context`, `@owlmeans/server-entrypoint`, `@owlmeans/server-route`, `@owlmeans/server-api`
81
- - `@owlmeans/entrypoint`, `@owlmeans/route`, `@owlmeans/auth`, `@owlmeans/error`
82
- - `fastify` (server runtime — the HTTP server is created by `@owlmeans/server-api`; there is no Express here)
44
+ `holdApiPort`, `config`, `sservice`, `service`, `AppType` and the context bootstrap exports remain
45
+ available from this package for process wiring.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,YAAW,OAAe,MAkB3G,CAAA"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,cAAa,OAAO,KAAW,CAgB9G,CAAA"}
package/build/context.js CHANGED
@@ -15,7 +15,6 @@ export const makeContext = (cfg, customize = false) => {
15
15
  appendStaticResource(context, AUTH_CACHE);
16
16
  appendAuthService(context);
17
17
  }
18
- context.makeContext = cfg => makeContext(cfg, customize);
19
18
  return context;
20
19
  };
21
20
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAErF,MAAM,CAAC,MAAM,WAAW,GAAG,CAA+C,GAAM,EAAE,YAAqB,KAAK,EAAE,EAAE;IAC9G,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAM,CAAA;IAE3C,eAAe,CAAO,OAAO,CAAC,CAAA;IAC9B,eAAe,CAAO,OAAO,CAAC,CAAA;IAC9B,mBAAmB,CAAO,OAAO,CAAC,CAAA;IAElC,OAAO,CAAC,kBA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,EAAE,CAAC;QACnD,oBAAoB,CAAO,OAAO,EAAE,UAAU,CAAC,CAAA;QAC/C,iBAAiB,CAAO,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Framework server entrypoints every application receives. */
2
+ export declare const entrypoints: import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocolDeclaration>[];
3
+ //# sourceMappingURL=entrypoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAGA,+DAA+D;AAC/D,eAAO,MAAM,WAAW,gIAA0C,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { entrypoints as apiConfigBindings } from '@owlmeans/api-config-server';
2
+ import { entrypoints as authBindings } from '@owlmeans/server-auth';
3
+ /** Framework server entrypoints every application receives. */
4
+ export const entrypoints = [...authBindings, ...apiConfigBindings];
5
+ //# sourceMappingURL=entrypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEnE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,iBAAiB,CAAC,CAAA"}
@@ -1,21 +1,25 @@
1
1
  export { config } from '@owlmeans/server-context';
2
+ export { makeContext } from './context.js';
3
+ export { main } from './main.js';
4
+ export type { AppConfig, AppContext } from './types.js';
2
5
  export { sservice } from '@owlmeans/server-config';
3
6
  export { addWebService } from '@owlmeans/client-config';
4
- export { service, toConfigRecord, PLUGINS } from '@owlmeans/config';
5
- export { parent, filter, body, params, EntrypointOutcome } from '@owlmeans/entrypoint';
7
+ export { service, toConfigRecord, configHelper, PLUGINS } from '@owlmeans/config';
8
+ export { contract, protocol, typed, EntrypointOutcome } from '@owlmeans/entrypoint';
6
9
  export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/entrypoint';
7
10
  export { createListSchema, filterObject } from '@owlmeans/resource';
8
- export type { ListResult } from '@owlmeans/resource';
9
- export { AppType, BASE, Layer, assertContext } from '@owlmeans/context';
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';
11
+ export type { Criteria, ListOptions, ListQuery, ListResult, Sort } from '@owlmeans/resource';
12
+ export { AppType, BASE, assertContext } from '@owlmeans/context';
13
+ export { bind, bindAll } from '@owlmeans/server-entrypoint';
14
14
  export { route as broute } from '@owlmeans/server-route';
15
- export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api';
15
+ export { handlers, holdApiPort } from '@owlmeans/server-api';
16
+ export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api';
17
+ export type { ApiPortHold, ApiPortHoldOptions } from '@owlmeans/server-api';
18
+ export type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
16
19
  export { route } from '@owlmeans/route';
17
20
  export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth';
18
21
  export { klusterize } from '@owlmeans/kluster';
19
22
  export type { PluginConfig } from '@owlmeans/config';
20
23
  export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common';
24
+ export { entrypoints } from './entrypoints.js';
21
25
  //# sourceMappingURL=exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE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AE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,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;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
package/build/exports.js CHANGED
@@ -1,16 +1,19 @@
1
1
  export { config } from '@owlmeans/server-context';
2
+ export { makeContext } from './context.js';
3
+ export { main } from './main.js';
2
4
  export { sservice } from '@owlmeans/server-config';
3
5
  export { addWebService } from '@owlmeans/client-config';
4
- export { service, toConfigRecord, PLUGINS } from '@owlmeans/config';
5
- export { parent, filter, body, params, EntrypointOutcome } from '@owlmeans/entrypoint';
6
+ export { service, toConfigRecord, configHelper, PLUGINS } from '@owlmeans/config';
7
+ export { contract, protocol, typed, EntrypointOutcome } from '@owlmeans/entrypoint';
6
8
  export { createListSchema, filterObject } from '@owlmeans/resource';
7
- export { AppType, BASE, Layer, assertContext } from '@owlmeans/context';
8
- export { elevate, entrypoint, guard } from '@owlmeans/server-entrypoint';
9
- export { elevate as celevate } from '@owlmeans/client-entrypoint';
9
+ export { AppType, BASE, assertContext } from '@owlmeans/context';
10
+ export { bind, bindAll } from '@owlmeans/server-entrypoint';
10
11
  export { route as broute } from '@owlmeans/server-route';
11
- export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api';
12
+ export { handlers, holdApiPort } from '@owlmeans/server-api';
13
+ export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api';
12
14
  export { route } from '@owlmeans/route';
13
15
  export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth';
14
16
  export { klusterize } from '@owlmeans/kluster';
15
17
  export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common';
18
+ export { entrypoints } from './entrypoints.js';
16
19
  //# sourceMappingURL=exports.js.map
@@ -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,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,MA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CHANGED
@@ -2,5 +2,5 @@ export * from './exports.js';
2
2
  export * from './main.js';
3
3
  export type * from './types.js';
4
4
  export * from './context.js';
5
- export * from './modules.js';
5
+ export * from './entrypoints.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './exports.js';
2
2
  export * from './main.js';
3
3
  export * from './context.js';
4
- export * from './modules.js';
4
+ export * from './entrypoints.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AAEzB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AAEzB,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
package/build/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ServerEntrypoint } from '@owlmeans/server-entrypoint';
2
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: (CommonEntrypoint | ServerEntrypoint<R>)[]) => Promise<void>;
4
+ export declare const main: <R, C extends AppConfig, T extends AppContext<C>>(ctx: T, entrypoints: (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,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"}
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,OACnE,CAAC,eAAe,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,kBAKhE,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
- export const main = async (ctx, modules) => {
4
- ctx.registerEntrypoints(modules);
3
+ export const main = async (ctx, entrypoints) => {
4
+ ctx.registerEntrypoints(entrypoints);
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,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
+ {"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,WAAuD,EAC/D,EAAE;IACF,GAAG,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAA;IACpC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAA;AACnC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/server-app",
3
- "version": "0.1.18-rc.8",
3
+ "version": "0.1.19-rc.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -21,25 +21,25 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@owlmeans/api": "^0.1.18-rc.6",
25
- "@owlmeans/client-config": "^0.1.18-rc.6",
26
- "@owlmeans/client-entrypoint": "^0.1.18-rc.6",
27
- "@owlmeans/config": "^0.1.18-rc.6",
28
- "@owlmeans/context": "^0.1.18-rc.6",
29
- "@owlmeans/kluster": "^0.1.18-rc.6",
30
- "@owlmeans/entrypoint": "^0.1.18-rc.6",
31
- "@owlmeans/route": "^0.1.18-rc.6",
32
- "@owlmeans/server-api": "^0.1.18-rc.8",
33
- "@owlmeans/server-auth": "^0.1.18-rc.8",
34
- "@owlmeans/server-context": "^0.1.18-rc.6",
35
- "@owlmeans/server-entrypoint": "^0.1.18-rc.6",
36
- "@owlmeans/server-route": "^0.1.18-rc.6",
37
- "@owlmeans/server-socket": "^0.1.18-rc.8",
38
- "@owlmeans/static-resource": "^0.1.18-rc.6"
24
+ "@owlmeans/api": "^0.1.19-rc.0",
25
+ "@owlmeans/client-config": "^0.1.19-rc.0",
26
+ "@owlmeans/client-entrypoint": "^0.1.19-rc.0",
27
+ "@owlmeans/config": "^0.1.19-rc.0",
28
+ "@owlmeans/context": "^0.1.18",
29
+ "@owlmeans/kluster": "^0.1.19-rc.0",
30
+ "@owlmeans/entrypoint": "^0.1.19-rc.0",
31
+ "@owlmeans/route": "^0.1.18",
32
+ "@owlmeans/server-api": "^0.1.19-rc.0",
33
+ "@owlmeans/server-auth": "^0.1.19-rc.0",
34
+ "@owlmeans/server-context": "^0.1.19-rc.0",
35
+ "@owlmeans/server-entrypoint": "^0.1.19-rc.0",
36
+ "@owlmeans/server-route": "^0.1.19-rc.0",
37
+ "@owlmeans/server-socket": "^0.1.19-rc.0",
38
+ "@owlmeans/static-resource": "^0.1.19-rc.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@owlmeans/dep-config": "workspace:*",
42
- "@types/node": "^26.1.0",
41
+ "@owlmeans/dep-config": "^0.1.18",
42
+ "@types/node": "^26.6.5",
43
43
  "nodemon": "^3.1.14",
44
44
  "typescript": "^7.0.2"
45
45
  },
package/src/context.ts CHANGED
@@ -6,7 +6,7 @@ import { appendApiClient } from '@owlmeans/api'
6
6
  import { appendStaticResource } from '@owlmeans/static-resource'
7
7
  import { appendSocketService, createSocketMiddleware } from '@owlmeans/server-socket'
8
8
 
9
- export const makeContext = <C extends AppConfig, T extends AppContext<C>>(cfg: C, customize: boolean = false) => {
9
+ export const makeContext = <C extends AppConfig, T extends AppContext<C>>(cfg: C, customize: boolean = false): T => {
10
10
  const context = makeServerContext(cfg) as T
11
11
 
12
12
  appendApiServer<C, T>(context)
@@ -21,7 +21,5 @@ export const makeContext = <C extends AppConfig, T extends AppContext<C>>(cfg: C
21
21
  appendAuthService<C, T>(context)
22
22
  }
23
23
 
24
- context.makeContext = cfg => makeContext(cfg, customize) as any
25
-
26
24
  return context
27
25
  }
@@ -0,0 +1,5 @@
1
+ import { entrypoints as apiConfigBindings } from '@owlmeans/api-config-server'
2
+ import { entrypoints as authBindings } from '@owlmeans/server-auth'
3
+
4
+ /** Framework server entrypoints every application receives. */
5
+ export const entrypoints = [...authBindings, ...apiConfigBindings]
package/src/exports.ts CHANGED
@@ -1,21 +1,25 @@
1
1
 
2
2
  export { config } from '@owlmeans/server-context'
3
+ export { makeContext } from './context.js'
4
+ export { main } from './main.js'
5
+ export type { AppConfig, AppContext } from './types.js'
3
6
  export { sservice } from '@owlmeans/server-config'
4
7
  export { addWebService } from '@owlmeans/client-config'
5
- export { service, toConfigRecord, PLUGINS } from '@owlmeans/config'
6
- export { parent, filter, body, params, EntrypointOutcome } from '@owlmeans/entrypoint'
8
+ export { service, toConfigRecord, configHelper, PLUGINS } from '@owlmeans/config'
9
+ export { contract, protocol, typed, EntrypointOutcome } from '@owlmeans/entrypoint'
7
10
  export type { AbstractRequest as Request, AbstractResponse as Response } from '@owlmeans/entrypoint'
8
11
  export { createListSchema, filterObject } from '@owlmeans/resource'
9
- export type { ListResult } from '@owlmeans/resource'
10
- export { AppType, BASE, Layer, assertContext } from '@owlmeans/context'
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'
12
+ export type { Criteria, ListOptions, ListQuery, ListResult, Sort } from '@owlmeans/resource'
13
+ export { AppType, BASE, assertContext } from '@owlmeans/context'
14
+ export { bind, bindAll } from '@owlmeans/server-entrypoint'
15
15
  export { route as broute } from '@owlmeans/server-route'
16
- export { handleRequest, handleBody, handleParams } from '@owlmeans/server-api'
16
+ export { handlers, holdApiPort } from '@owlmeans/server-api'
17
+ export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api'
18
+ export type { ApiPortHold, ApiPortHoldOptions } from '@owlmeans/server-api'
19
+ export type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
17
20
  export { route } from '@owlmeans/route'
18
21
  export { DEFAULT_ALIAS as DAUTH_GUARD } from '@owlmeans/server-auth'
19
22
  export { klusterize } from '@owlmeans/kluster'
20
23
  export type { PluginConfig } from '@owlmeans/config'
21
24
  export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common'
25
+ export { entrypoints } from './entrypoints.js'
package/src/index.ts CHANGED
@@ -3,4 +3,4 @@ export * from './exports.js'
3
3
  export * from './main.js'
4
4
  export type * from './types.js'
5
5
  export * from './context.js'
6
- export * from './modules.js'
6
+ export * from './entrypoints.js'
package/src/main.ts CHANGED
@@ -7,9 +7,9 @@ import type { AppContext, AppConfig } from './types.js'
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: (CommonEntrypoint | ServerEntrypoint<R>)[]
10
+ ctx: T, entrypoints: (CommonEntrypoint | ServerEntrypoint<R>)[]
11
11
  ) => {
12
- ctx.registerEntrypoints(modules)
12
+ ctx.registerEntrypoints(entrypoints)
13
13
  await ctx.configure().init()
14
14
  await ctx.getApiServer().listen()
15
15
  }
package/build/.gitkeep DELETED
File without changes
@@ -1,2 +0,0 @@
1
- export declare const modules: import("@owlmeans/server-entrypoint").ServerEntrypoint<unknown>[];
2
- //# sourceMappingURL=modules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,mEAA0B,CAAA"}
package/build/modules.js DELETED
@@ -1,4 +0,0 @@
1
- import { modules as apiConfig } from '@owlmeans/api-config-server';
2
- import { modules as list } from '@owlmeans/server-auth';
3
- export const modules = [...list, ...apiConfig];
4
- //# sourceMappingURL=modules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,CAAA"}
package/src/modules.ts DELETED
@@ -1,4 +0,0 @@
1
- import { modules as apiConfig } from '@owlmeans/api-config-server'
2
- import { modules as list } from '@owlmeans/server-auth'
3
-
4
- export const modules = [...list, ...apiConfig]