@lde/search-api-server 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -120
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -5,14 +5,11 @@ Docker image: mount a schema-declaration module, point it at Typesense, and it
|
|
|
5
5
|
serves `/graphql` – POST execution, the self-contained playground, the SDL –
|
|
6
6
|
plus `/health`, with CORS and depth/cost limits on by default.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
([#600](https://github.com/ldelements/lde/issues/600), layer 3) that binds the
|
|
10
|
-
engine-agnostic [`@lde/search-api-graphql`](../search-api-graphql) handler
|
|
11
|
-
(layer 2) to the [`@lde/search-typesense`](../search-typesense) engine. Use it
|
|
12
|
-
for turnkey, non-JS and ops-driven deployments; a JS host that wants custom
|
|
13
|
-
GraphQL fields mounts the handler itself instead (or builds `FROM` this image).
|
|
8
|
+
## Installation
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
```sh
|
|
11
|
+
npm install @lde/search-api-server
|
|
12
|
+
```
|
|
16
13
|
|
|
17
14
|
```sh
|
|
18
15
|
docker run --publish 4000:4000 \
|
|
@@ -22,117 +19,6 @@ docker run --publish 4000:4000 \
|
|
|
22
19
|
ghcr.io/ldelements/search-api-server
|
|
23
20
|
```
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```sh
|
|
28
|
-
npx @lde/search-api-server
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## The schema module
|
|
32
|
-
|
|
33
|
-
The mounted module default-exports the deployment’s search type declarations as
|
|
34
|
-
**plain data** – it must not import `@lde/search` (bare specifiers do not
|
|
35
|
-
resolve from a mounted file), and does not need to: the server validates the
|
|
36
|
-
declarations at boot, exactly as it would a SHACL generator’s output. Optional
|
|
37
|
-
functions (`derive`, `transform`) are allowed – it is a real JS module, only
|
|
38
|
-
without imports; they are projection-time declarations a serving process never
|
|
39
|
-
calls, carried so one module can drive both the indexer and this API.
|
|
40
|
-
|
|
41
|
-
Authoring in TypeScript works fine: compile the module to `.mjs` first
|
|
42
|
-
(`tsc` or esbuild) and mount the output – with `satisfies SearchType[]` you
|
|
43
|
-
get the full compile-time checking, and functions survive compilation. If the
|
|
44
|
-
module must import, bundle it (e.g. esbuild) before mounting.
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
// search-schema.mjs
|
|
48
|
-
export default [
|
|
49
|
-
{
|
|
50
|
-
name: 'Dataset',
|
|
51
|
-
class: 'http://www.w3.org/ns/dcat#Dataset',
|
|
52
|
-
fields: [
|
|
53
|
-
{
|
|
54
|
-
name: 'title',
|
|
55
|
-
kind: 'text',
|
|
56
|
-
locales: ['nl', 'en'],
|
|
57
|
-
output: true,
|
|
58
|
-
searchable: { weight: 5 },
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'keyword',
|
|
62
|
-
kind: 'keyword',
|
|
63
|
-
array: true,
|
|
64
|
-
facetable: true,
|
|
65
|
-
output: true,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
// Optional: forwarded to buildGraphQLSchema (per-type options, maxPerPage, …).
|
|
72
|
-
export const schemaOptions = { maxPerPage: 50 };
|
|
73
|
-
|
|
74
|
-
// Optional: forwarded to createTypesenseSearchEngine (collection overrides, …).
|
|
75
|
-
export const engineOptions = {};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Once the SHACL + `search:` generator lands
|
|
79
|
-
([#495](https://github.com/ldelements/lde/issues/495)), mounted SHACL becomes
|
|
80
|
-
an additional source for the same schema.
|
|
81
|
-
|
|
82
|
-
## Configuration
|
|
83
|
-
|
|
84
|
-
| Variable | Default | Meaning |
|
|
85
|
-
| -------------------- | --------------------------- | -------------------------------------------------- |
|
|
86
|
-
| `SCHEMA_MODULE` | `/config/search-schema.mjs` | Path of the mounted schema-declaration module |
|
|
87
|
-
| `PORT` | `4000` | TCP port the server binds |
|
|
88
|
-
| `GRAPHQL_ENDPOINT` | `/graphql` | Path serving GraphQL, the playground and the SDL |
|
|
89
|
-
| `PLAYGROUND` | `true` | Serve the playground on GET (`false`/`0` disables) |
|
|
90
|
-
| `MAX_DEPTH` | handler default (15) | Query depth cap |
|
|
91
|
-
| `MAX_COST` | handler default (5000) | Query cost cap |
|
|
92
|
-
| `TYPESENSE_HOST` | **required** | Typesense host |
|
|
93
|
-
| `TYPESENSE_PORT` | `8108` | Typesense port |
|
|
94
|
-
| `TYPESENSE_PROTOCOL` | `http` | `http` or `https` |
|
|
95
|
-
| `TYPESENSE_API_KEY` | **required** | Use a search-only key: the server only ever reads |
|
|
96
|
-
|
|
97
|
-
A misconfigured boot reports **all** problems in one error, not one per crash
|
|
98
|
-
loop.
|
|
99
|
-
|
|
100
|
-
## Endpoints
|
|
101
|
-
|
|
102
|
-
- `POST /graphql` – GraphQL execution.
|
|
103
|
-
- `GET /graphql` – the self-contained playground (no external CDN, no framing
|
|
104
|
-
headers, so a docs site can `<iframe>` it as a live client).
|
|
105
|
-
- `GET /graphql?sdl` – the printed SDL: the contract without a running
|
|
106
|
-
introspection query.
|
|
107
|
-
- `GET /health` – liveness; the Docker image’s `HEALTHCHECK` uses it.
|
|
108
|
-
- `GET /` – redirects to the endpoint.
|
|
109
|
-
|
|
110
|
-
## Building the image
|
|
111
|
-
|
|
112
|
-
The image is built from the workspace’s own outputs – the compiled package,
|
|
113
|
-
the same-commit builds of its `@lde/*` dependencies and a pruned lockfile –
|
|
114
|
-
never from npm, so it exists for any commit
|
|
115
|
-
([ADR 15](../../docs/decisions/0015-ship-the-served-search-api-as-a-docker-image-built-from-the-workspace.md)):
|
|
116
|
-
|
|
117
|
-
```sh
|
|
118
|
-
npx nx run @lde/search-api-server:docker:build # → packages-search-api-server
|
|
119
|
-
npx nx run @lde/search-api-server:docker:smoke # boots it and probes /health + ?sdl
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
CI runs `docker:smoke` for affected PRs; each release rebuilds and pushes
|
|
123
|
-
`ghcr.io/ldelements/search-api-server:<version>` (`.github/workflows/docker.yml`).
|
|
124
|
-
|
|
125
|
-
## Programmatic use
|
|
22
|
+
## Documentation
|
|
126
23
|
|
|
127
|
-
|
|
128
|
-
boot:
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
import {
|
|
132
|
-
configFromEnvironment,
|
|
133
|
-
createSearchApiServer,
|
|
134
|
-
} from '@lde/search-api-server';
|
|
135
|
-
|
|
136
|
-
const server = await createSearchApiServer(configFromEnvironment(process.env));
|
|
137
|
-
const port = await server.start();
|
|
138
|
-
```
|
|
24
|
+
See the [full documentation](https://ldelements.org/reference/search-api-server).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-api-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "The served @lde/search API as a bootable process and prebuilt Docker image: loads a mounted schema-declaration module and Typesense connection details from the environment, then serves /graphql (execution, playground, SDL) plus /health over node:http. The composition layer that binds the engine-agnostic @lde/search-api-graphql handler to @lde/search-typesense – for turnkey, non-JS and ops-driven deployments.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"!**/*.tsbuildinfo"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@lde/search": "^0.12.
|
|
32
|
-
"@lde/search-api-graphql": "^0.12.
|
|
33
|
-
"@lde/search-typesense": "^0.15.
|
|
31
|
+
"@lde/search": "^0.12.3",
|
|
32
|
+
"@lde/search-api-graphql": "^0.12.3",
|
|
33
|
+
"@lde/search-typesense": "^0.15.6",
|
|
34
34
|
"@whatwg-node/server": "^0.11.0",
|
|
35
35
|
"tslib": "^2.3.0",
|
|
36
36
|
"typesense": "^3.0.6"
|