@owlmeans/server-app 0.1.7 → 0.1.9
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
|
@@ -82,3 +82,20 @@ await main(context, [...modules, ...myModules])
|
|
|
82
82
|
- [`@owlmeans/server-context`](../server-context) — `makeServerContext` called internally by `makeContext`
|
|
83
83
|
- [`@owlmeans/server-api`](../server-api) — handler wrappers re-exported here
|
|
84
84
|
- [`@owlmeans/server-entrypoint`](../server-entrypoint) — `elevate` re-exported here
|
|
85
|
+
|
|
86
|
+
<!-- owlmeans:agent-guidance:start -->
|
|
87
|
+
## Agent guidance
|
|
88
|
+
|
|
89
|
+
This package ships embedded Claude Code skills and GitHub Copilot instructions under
|
|
90
|
+
`agent-meta/`. After installing your `@owlmeans/*` packages, run the OwlMeans
|
|
91
|
+
agent-skills installer to place them into your project's native locations
|
|
92
|
+
(`.claude/skills/` and `.github/instructions/`):
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
npx @owlmeans/agent-skills
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The embedded files are version-matched to this package release. Do not edit them
|
|
99
|
+
directly — they are regenerated on each publish. To contribute guidance edits,
|
|
100
|
+
open a PR against the source monorepo.
|
|
101
|
+
<!-- owlmeans:agent-guidance:end -->
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
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."
|
|
3
|
+
applyTo: "**/*.ts, **/*.tsx"
|
|
4
|
+
---
|
|
5
|
+
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
|
+
|
|
7
|
+
# @owlmeans/server-app
|
|
8
|
+
|
|
9
|
+
**Layer:** Server
|
|
10
|
+
**Install:** `"@owlmeans/server-app": "^0.1.9"` in `dependencies`
|
|
11
|
+
|
|
12
|
+
## Key Exports
|
|
13
|
+
|
|
14
|
+
| Export | Description |
|
|
15
|
+
|--------|-------------|
|
|
16
|
+
| `main<E, C, T>(context, modules)` | Entry point — boots Express, registers entrypoints |
|
|
17
|
+
| `handleRequest(fn)` | Wrap a server handler `(req, context) => result` |
|
|
18
|
+
| `handleBody<T>(fn)` | Wrap with validated body — `(payload, context, req) => result` |
|
|
19
|
+
| `elevate(modules, alias, handler)` | Attach handler to an entrypoint declaration |
|
|
20
|
+
| `celevate(modules, alias, handler)` | Conditional elevate |
|
|
21
|
+
| `sservice(options, cfg)` | Register a server-side service in the config |
|
|
22
|
+
| `modules` | Built-in system entrypoints to spread |
|
|
23
|
+
| `Context`, `Config`, `ClientEntrypoint` re-exports | Common types |
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// index.ts
|
|
29
|
+
import { main } from '@owlmeans/server-app'
|
|
30
|
+
const context = makeContext(config)
|
|
31
|
+
main<{}, Config, Context>(context, appModules)
|
|
32
|
+
|
|
33
|
+
// Handlers
|
|
34
|
+
import { handleRequest, handleBody } from '@owlmeans/server-app'
|
|
35
|
+
export const list = handleRequest(async (req, context) => {
|
|
36
|
+
if (req.auth?.entityId == null) throw new AuthUnknown('entity')
|
|
37
|
+
return await (context as Context).project().list({ entityId: req.auth.entityId })
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Elevation
|
|
41
|
+
import { elevate, modules } from '@owlmeans/server-app'
|
|
42
|
+
elevate(managerModules, manager.back.project.create, create)
|
|
43
|
+
export const appModules = [...modules, ...managerModules]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Depends On
|
|
47
|
+
|
|
48
|
+
- `@owlmeans/server-context`, `@owlmeans/server-entrypoint`, `@owlmeans/server-route`, `@owlmeans/server-api`
|
|
49
|
+
- `@owlmeans/entrypoint`, `@owlmeans/route`, `@owlmeans/auth`, `@owlmeans/error`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"package": "@owlmeans/server-app",
|
|
4
|
+
"version": "0.1.9",
|
|
5
|
+
"generatedAt": "2026-06-14T13:34:06.133Z",
|
|
6
|
+
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
|
+
"entries": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "skill",
|
|
10
|
+
"name": "server-app",
|
|
11
|
+
"category": "package-specific",
|
|
12
|
+
"file": "skills/server-app/SKILL.md",
|
|
13
|
+
"canonicalPath": ".claude/skills/server-app/SKILL.md"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"kind": "instruction",
|
|
17
|
+
"name": "server-app",
|
|
18
|
+
"category": "package-specific",
|
|
19
|
+
"file": "instructions/server-app.instructions.md",
|
|
20
|
+
"canonicalPath": ".github/instructions/server-app.instructions.md"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
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
|
|
5
|
+
---
|
|
6
|
+
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
7
|
+
|
|
8
|
+
# @owlmeans/server-app
|
|
9
|
+
|
|
10
|
+
**Layer:** Server
|
|
11
|
+
**Install:** `"@owlmeans/server-app": "^0.1.9"` in `dependencies`
|
|
12
|
+
|
|
13
|
+
## Key Exports
|
|
14
|
+
|
|
15
|
+
| Export | Description |
|
|
16
|
+
|--------|-------------|
|
|
17
|
+
| `main<E, C, T>(context, modules)` | Entry point — boots Express, registers all entrypoints as routes |
|
|
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 `appModules` |
|
|
24
|
+
| `Context`, `Config`, `ClientEntrypoint` re-exports | Common types |
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
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 { appModules } from './modules.js'
|
|
35
|
+
|
|
36
|
+
const context = makeContext(config)
|
|
37
|
+
main<{}, Config, Context>(context, appModules)
|
|
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
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Module elevation
|
|
63
|
+
```typescript
|
|
64
|
+
import { elevate, modules } from '@owlmeans/server-app'
|
|
65
|
+
import { managerModules } from 'my-common'
|
|
66
|
+
import { create, list } from './app/project/index.js'
|
|
67
|
+
|
|
68
|
+
elevate(managerModules, manager.back.project.create, create)
|
|
69
|
+
elevate(managerModules, manager.back.project.list, list)
|
|
70
|
+
|
|
71
|
+
export const appModules = [...modules, ...paymentModules, ...managerModules]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Depends On
|
|
75
|
+
|
|
76
|
+
- `@owlmeans/server-context`, `@owlmeans/server-entrypoint`, `@owlmeans/server-route`, `@owlmeans/server-api`
|
|
77
|
+
- `@owlmeans/entrypoint`, `@owlmeans/route`, `@owlmeans/auth`, `@owlmeans/error`
|
|
78
|
+
- `express` / `fastify` (server runtime)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/api": "^0.1.
|
|
25
|
-
"@owlmeans/client-config": "^0.1.
|
|
26
|
-
"@owlmeans/client-entrypoint": "^0.1.
|
|
27
|
-
"@owlmeans/config": "^0.1.
|
|
28
|
-
"@owlmeans/context": "^0.1.
|
|
29
|
-
"@owlmeans/kluster": "^0.1.
|
|
30
|
-
"@owlmeans/entrypoint": "^0.1.
|
|
31
|
-
"@owlmeans/route": "^0.1.
|
|
32
|
-
"@owlmeans/server-api": "^0.1.
|
|
33
|
-
"@owlmeans/server-auth": "^0.1.
|
|
34
|
-
"@owlmeans/server-context": "^0.1.
|
|
35
|
-
"@owlmeans/server-entrypoint": "^0.1.
|
|
36
|
-
"@owlmeans/server-route": "^0.1.
|
|
37
|
-
"@owlmeans/server-socket": "^0.1.
|
|
38
|
-
"@owlmeans/static-resource": "^0.1.
|
|
24
|
+
"@owlmeans/api": "^0.1.9",
|
|
25
|
+
"@owlmeans/client-config": "^0.1.9",
|
|
26
|
+
"@owlmeans/client-entrypoint": "^0.1.9",
|
|
27
|
+
"@owlmeans/config": "^0.1.9",
|
|
28
|
+
"@owlmeans/context": "^0.1.9",
|
|
29
|
+
"@owlmeans/kluster": "^0.1.9",
|
|
30
|
+
"@owlmeans/entrypoint": "^0.1.9",
|
|
31
|
+
"@owlmeans/route": "^0.1.9",
|
|
32
|
+
"@owlmeans/server-api": "^0.1.9",
|
|
33
|
+
"@owlmeans/server-auth": "^0.1.9",
|
|
34
|
+
"@owlmeans/server-context": "^0.1.9",
|
|
35
|
+
"@owlmeans/server-entrypoint": "^0.1.9",
|
|
36
|
+
"@owlmeans/server-route": "^0.1.9",
|
|
37
|
+
"@owlmeans/server-socket": "^0.1.9",
|
|
38
|
+
"@owlmeans/static-resource": "^0.1.9"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@owlmeans/dep-config": "workspace:*",
|