@ultimabase/http 0.7.0 → 0.8.0-canary.20261112102022
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/CHANGELOG.md +17 -0
- package/dist/app.d.ts +4 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +2 -3
- package/dist/probes.d.ts.map +1 -1
- package/dist/probes.js +2 -1
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +2 -0
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +2 -1
- package/package.json +3 -3
- package/src/app.ts +8 -6
- package/src/probes.ts +2 -1
- package/src/request.ts +5 -2
- package/src/upgrade.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ultimabase/http
|
|
2
2
|
|
|
3
|
+
## 0.8.0-canary.20261112102022
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 20aec1b: The application's code logs with the application's logger, its lines named `app` (D-364): a function's `run` receives `logger`, bound to `{ function: name }`; each hook receives `logger`; a route reads `c.var.logger`; a job's `run` receives `logger`, bound to `{ job: name, run: id }`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 1520a09: The kernel publishes each model operation, hook, virtual field and function on Node's tracing channels `ultimabase:operation`, `ultimabase:hook`, `ultimabase:virtual` and `ultimabase:function`, nested, and each error the server logs at error level on `ultimabase:error` with its correlation id. A tool such as an error tracker subscribes to them; without a subscriber, nothing is built.
|
|
12
|
+
- Updated dependencies [20aec1b]
|
|
13
|
+
- Updated dependencies [94145f9]
|
|
14
|
+
- Updated dependencies [8f82820]
|
|
15
|
+
- Updated dependencies [1b9515a]
|
|
16
|
+
- Updated dependencies [3099475]
|
|
17
|
+
- Updated dependencies [1520a09]
|
|
18
|
+
- ultimabase@0.8.0-canary.20261112102022
|
|
19
|
+
|
|
3
20
|
## 0.7.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/app.d.ts
CHANGED
|
@@ -4,13 +4,15 @@ import type { Limiter, RateLimit } from './limit.ts';
|
|
|
4
4
|
import type { Probes } from './probes.ts';
|
|
5
5
|
import type { Gate } from './upgrade.ts';
|
|
6
6
|
/**
|
|
7
|
-
* What a route's context holds: `c.var.caller` (D-106)
|
|
8
|
-
* the client's, `''` when unknown (D-113, D-116).
|
|
7
|
+
* What a route's context holds: `c.var.caller` (D-106), `c.var.address`,
|
|
8
|
+
* the client's, `''` when unknown (D-113, D-116), and `c.var.logger`, the
|
|
9
|
+
* application's (D-364).
|
|
9
10
|
*/
|
|
10
11
|
export type HttpEnv = {
|
|
11
12
|
Variables: {
|
|
12
13
|
caller: Caller;
|
|
13
14
|
address: string;
|
|
15
|
+
logger: Logger;
|
|
14
16
|
};
|
|
15
17
|
};
|
|
16
18
|
/** Routes the application writes, read by `httpPlugin({ routes })`. */
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM3B,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,EAAE,MAAM,YAAY,CAAA;AAI3D,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGxC;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CA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AAC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAA;CAC5C,EACD,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,EAC/C,MAAM,EAAE,MAAM,GACZ,IAAI,CAAC,OAAO,CAAC,CA6If"}
|
package/dist/app.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// probes (D-204), CORS, the rate limit (D-218), the plugins' gates (D-205), forms from other
|
|
3
3
|
// origins, the body limit, each request's caller, the routes, the reset
|
|
4
4
|
// route outside production (D-188), and errors as D-72 sends them.
|
|
5
|
-
import { randomUUID } from 'node:crypto';
|
|
6
5
|
import { STATUS_CODES } from 'node:http';
|
|
7
6
|
import { Hono } from 'hono';
|
|
8
7
|
import { bodyLimit } from 'hono/body-limit';
|
|
@@ -10,6 +9,7 @@ import { cors } from 'hono/cors';
|
|
|
10
9
|
import { HTTPException } from 'hono/http-exception';
|
|
11
10
|
import { getPath } from 'hono/utils/url';
|
|
12
11
|
import { isLocalHost, PublicError } from 'ultimabase';
|
|
12
|
+
import { logFailure } from 'ultimabase/internal';
|
|
13
13
|
import { isOwnOrigin } from './address.js';
|
|
14
14
|
import { tooMany } from './limit.js';
|
|
15
15
|
import { probeRoutes } from './probes.js';
|
|
@@ -65,8 +65,7 @@ function failed(error, c, logger) {
|
|
|
65
65
|
? c.json({ code, message }, status)
|
|
66
66
|
: c.json({ code, message, details }, status);
|
|
67
67
|
}
|
|
68
|
-
const correlationId =
|
|
69
|
-
logger.error({ correlationId, err: error }, 'A request failed.');
|
|
68
|
+
const correlationId = logFailure(logger, error, 'A request failed.');
|
|
70
69
|
return c.json({ code: 'INTERNAL', message: 'Internal error.', correlationId }, 500);
|
|
71
70
|
}
|
|
72
71
|
/** A local host over `http:`, on any port. */
|
package/dist/probes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../src/probes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../src/probes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAEzD,mEAAmE;AACnE,MAAM,WAAW,MAAM;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAC7B;AAyBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAQjD;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAShE"}
|
package/dist/probes.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// whether the instance takes traffic. Until every plugin started, the
|
|
3
3
|
// server serves nothing else.
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
|
+
import { logFailure } from 'ultimabase/internal';
|
|
5
6
|
/** A check that throws fails, logged with its error. */
|
|
6
7
|
async function passes(check, logger) {
|
|
7
8
|
try {
|
|
8
9
|
return await check();
|
|
9
10
|
}
|
|
10
11
|
catch (error) {
|
|
11
|
-
logger
|
|
12
|
+
logFailure(logger, error, 'A readiness check failed.');
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
15
|
}
|
package/dist/request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAsBvC,wBAAgB,IAAI,CACnB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACb,IAAI,CASN"}
|
package/dist/request.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HTTPException } from 'hono/http-exception';
|
|
2
|
+
import { appLogger } from 'ultimabase/internal';
|
|
2
3
|
/** `c.req[method]`, its parsing failure, `parsing`, a 400. */
|
|
3
4
|
function malformed(c, method, parsing, message) {
|
|
4
5
|
const read = c.req[method].bind(c.req);
|
|
@@ -18,6 +19,7 @@ function malformed(c, method, parsing, message) {
|
|
|
18
19
|
export function hold(c, caller, address) {
|
|
19
20
|
c.set('caller', caller);
|
|
20
21
|
c.set('address', address);
|
|
22
|
+
c.set('logger', appLogger());
|
|
21
23
|
// Only parsing the body throws these here, not the server's code.
|
|
22
24
|
malformed(c, 'json', SyntaxError, 'Malformed JSON in request body');
|
|
23
25
|
const form = 'Malformed form data in request body';
|
package/dist/upgrade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../src/upgrade.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM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,5 @@
|
|
|
1
1
|
import { STATUS_CODES } from 'node:http';
|
|
2
|
+
import { logFailure } from 'ultimabase/internal';
|
|
2
3
|
import { isOwnOrigin } from './address.js';
|
|
3
4
|
import { tooMany } from './limit.js';
|
|
4
5
|
/** The first gate's refusal of `request`, or `undefined` when all let it through. */
|
|
@@ -87,7 +88,7 @@ export function upgrading(server, { takers, gates, rateLimit, allows, addressOf,
|
|
|
87
88
|
taker.accept({ request, address, incoming, socket, head, limit });
|
|
88
89
|
}
|
|
89
90
|
catch (error) {
|
|
90
|
-
logger
|
|
91
|
+
logFailure(logger, error, 'An upgrade failed.');
|
|
91
92
|
refuse(socket, 500, 'INTERNAL', 'Internal error.');
|
|
92
93
|
}
|
|
93
94
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimabase/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-canary.20261112102022",
|
|
4
4
|
"description": "An HTTP server for UltimaBase: Hono routes that read the caller, CORS and a body limit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"ipaddr.js": "2.5.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"ultimabase": "
|
|
41
|
+
"ultimabase": "0.8.0-canary.20261112102022"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"ultimabase": "0.
|
|
44
|
+
"ultimabase": "0.8.0-canary.20261112102022",
|
|
45
45
|
"vite": "8.3.4",
|
|
46
46
|
"vitest": "5.0.5"
|
|
47
47
|
}
|
package/src/app.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// probes (D-204), CORS, the rate limit (D-218), the plugins' gates (D-205), forms from other
|
|
3
3
|
// origins, the body limit, each request's caller, the routes, the reset
|
|
4
4
|
// route outside production (D-188), and errors as D-72 sends them.
|
|
5
|
-
import { randomUUID } from 'node:crypto'
|
|
6
5
|
import { STATUS_CODES } from 'node:http'
|
|
7
6
|
import type { Context } from 'hono'
|
|
8
7
|
import { Hono } from 'hono'
|
|
@@ -13,6 +12,7 @@ import type { ContentfulStatusCode } from 'hono/utils/http-status'
|
|
|
13
12
|
import { getPath } from 'hono/utils/url'
|
|
14
13
|
import type { Caller, ErrorCode, Logger } from 'ultimabase'
|
|
15
14
|
import { isLocalHost, PublicError } from 'ultimabase'
|
|
15
|
+
import { logFailure } from 'ultimabase/internal'
|
|
16
16
|
import { isOwnOrigin } from './address.ts'
|
|
17
17
|
import type { Limiter, RateLimit } from './limit.ts'
|
|
18
18
|
import { tooMany } from './limit.ts'
|
|
@@ -25,10 +25,13 @@ import type { Gate } from './upgrade.ts'
|
|
|
25
25
|
import { answer } from './upgrade.ts'
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* What a route's context holds: `c.var.caller` (D-106)
|
|
29
|
-
* the client's, `''` when unknown (D-113, D-116).
|
|
28
|
+
* What a route's context holds: `c.var.caller` (D-106), `c.var.address`,
|
|
29
|
+
* the client's, `''` when unknown (D-113, D-116), and `c.var.logger`, the
|
|
30
|
+
* application's (D-364).
|
|
30
31
|
*/
|
|
31
|
-
export type HttpEnv = {
|
|
32
|
+
export type HttpEnv = {
|
|
33
|
+
Variables: { caller: Caller; address: string; logger: Logger }
|
|
34
|
+
}
|
|
32
35
|
|
|
33
36
|
/** Routes the application writes, read by `httpPlugin({ routes })`. */
|
|
34
37
|
export type Routes = Hono<HttpEnv>
|
|
@@ -120,8 +123,7 @@ function failed(error: unknown, c: Context, logger: Logger): Response {
|
|
|
120
123
|
? c.json({ code, message }, status)
|
|
121
124
|
: c.json({ code, message, details }, status)
|
|
122
125
|
}
|
|
123
|
-
const correlationId =
|
|
124
|
-
logger.error({ correlationId, err: error }, 'A request failed.')
|
|
126
|
+
const correlationId = logFailure(logger, error, 'A request failed.')
|
|
125
127
|
return c.json(
|
|
126
128
|
{ code: 'INTERNAL', message: 'Internal error.', correlationId },
|
|
127
129
|
500,
|
package/src/probes.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// server serves nothing else.
|
|
4
4
|
import { Hono } from 'hono'
|
|
5
5
|
import type { Logger } from 'ultimabase'
|
|
6
|
+
import { logFailure } from 'ultimabase/internal'
|
|
6
7
|
import type { Gate } from './upgrade.ts'
|
|
7
8
|
|
|
8
9
|
/** Whether a service the instance needs is there, read on each `/ready`. */
|
|
@@ -20,7 +21,7 @@ async function passes(check: ReadyCheck, logger: Logger): Promise<boolean> {
|
|
|
20
21
|
try {
|
|
21
22
|
return await check()
|
|
22
23
|
} catch (error) {
|
|
23
|
-
logger
|
|
24
|
+
logFailure(logger, error, 'A readiness check failed.')
|
|
24
25
|
return false
|
|
25
26
|
}
|
|
26
27
|
}
|
package/src/request.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// What each route's context holds (D-106, D-108): the caller,
|
|
2
|
-
// that, when it is not the JSON or the form
|
|
1
|
+
// What each route's context holds (D-106, D-108, D-364): the caller, the
|
|
2
|
+
// application's logger, and a body that, when it is not the JSON or the form
|
|
3
|
+
// it claims, is the client's error.
|
|
3
4
|
import type { Context } from 'hono'
|
|
4
5
|
import { HTTPException } from 'hono/http-exception'
|
|
5
6
|
import type { Caller } from 'ultimabase'
|
|
7
|
+
import { appLogger } from 'ultimabase/internal'
|
|
6
8
|
import type { HttpEnv } from './app.ts'
|
|
7
9
|
|
|
8
10
|
/** `c.req[method]`, its parsing failure, `parsing`, a 400. */
|
|
@@ -32,6 +34,7 @@ export function hold(
|
|
|
32
34
|
): void {
|
|
33
35
|
c.set('caller', caller)
|
|
34
36
|
c.set('address', address)
|
|
37
|
+
c.set('logger', appLogger())
|
|
35
38
|
// Only parsing the body throws these here, not the server's code.
|
|
36
39
|
malformed(c, 'json', SyntaxError, 'Malformed JSON in request body')
|
|
37
40
|
const form = 'Malformed form data in request body'
|
package/src/upgrade.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { IncomingMessage, Server } from 'node:http'
|
|
|
6
6
|
import { STATUS_CODES } from 'node:http'
|
|
7
7
|
import type { Duplex } from 'node:stream'
|
|
8
8
|
import type { Logger } from 'ultimabase'
|
|
9
|
+
import { logFailure } from 'ultimabase/internal'
|
|
9
10
|
import { isOwnOrigin } from './address.ts'
|
|
10
11
|
import type { Limiter } from './limit.ts'
|
|
11
12
|
import { tooMany } from './limit.ts'
|
|
@@ -171,7 +172,7 @@ export function upgrading(
|
|
|
171
172
|
if (refused !== undefined) return await send(socket, refused)
|
|
172
173
|
taker.accept({ request, address, incoming, socket, head, limit })
|
|
173
174
|
} catch (error) {
|
|
174
|
-
logger
|
|
175
|
+
logFailure(logger, error, 'An upgrade failed.')
|
|
175
176
|
refuse(socket, 500, 'INTERNAL', 'Internal error.')
|
|
176
177
|
}
|
|
177
178
|
})()
|