@fougere/app 0.8.4-alpha.0 → 0.9.0-alpha.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/dist/boot.d.ts +1 -1
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js +6 -18
- package/dist/boot.js.map +1 -1
- package/dist/express.d.ts +4 -4
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +5 -5
- package/dist/express.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/web.d.ts +4 -4
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +4 -4
- package/dist/web.js.map +1 -1
- package/package.json +12 -12
- package/src/boot.ts +5 -18
- package/src/express.ts +5 -5
- package/src/index.ts +1 -9
- package/src/web.ts +4 -4
package/dist/boot.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { App, CreateAppOptions, FougereConfig, Transport } from '@fougere/core';
|
|
2
|
-
import type
|
|
2
|
+
import { type ResolvedStorage } from '@fougere/defaults';
|
|
3
3
|
export interface FougereServerConfig {
|
|
4
4
|
/**
|
|
5
5
|
* The whole data layer, as `resolveStorage` composed it — where the rows are, which source
|
package/dist/boot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAW,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAW,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKlE,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,8FAA8F;IAC9F,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC5C,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;CAC9C;AASD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,QAG3D;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAGjE;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,CAK5C;AAED,qBAAqB;AACrB,wBAAsB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAWpE"}
|
package/dist/boot.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/** Fougere server bootstrap — single entry point for an app's lifecycle, whatever hosts it. */
|
|
2
|
-
import { applyConfig, createApp, identityFromEnv, Logger
|
|
2
|
+
import { applyConfig, createApp, identityFromEnv, Logger } from '@fougere/core';
|
|
3
3
|
import { scanProject, frondAliases } from '@fougere/compiler';
|
|
4
4
|
import { resolveConventions } from '@fougere/core';
|
|
5
5
|
import { loadCascadedConfig, setModuleLoader } from '@fougere/core/node';
|
|
6
6
|
import { createContainer } from '@fougere/container';
|
|
7
7
|
import { createMemoryStorage } from '@fougere/adapter-memory';
|
|
8
|
+
import { layerOf } from '@fougere/defaults';
|
|
8
9
|
// ── State ────────────────────────────────────────
|
|
9
10
|
let _config = {};
|
|
10
11
|
let _appPromise = null;
|
|
@@ -97,8 +98,6 @@ async function boot() {
|
|
|
97
98
|
}
|
|
98
99
|
// The storage's two halves, kept together: its ascent is an extension, its connection
|
|
99
100
|
// is not — it is opened here, before the container, so it closes after the container.
|
|
100
|
-
const storageFactory = storage.storageFactory ?? createMemoryStorage;
|
|
101
|
-
const storageMigrate = storage.migrate;
|
|
102
101
|
// Layer-2 wiring: `remotes: { catalog: 'http://...' }` in fougere.config.ts
|
|
103
102
|
// is all the user writes — the default transport comes from here.
|
|
104
103
|
// The host's word wins here too — and where it speaks, nothing below runs: building
|
|
@@ -128,25 +127,14 @@ async function boot() {
|
|
|
128
127
|
? { scan: await scanProject(root, undefined, conventions) }
|
|
129
128
|
: {}),
|
|
130
129
|
createContainer,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
enforces: storage.enforces,
|
|
135
|
-
transacted: storage.transacted,
|
|
136
|
-
db: storage.db,
|
|
130
|
+
// The layer, spread whole. Naming a few of its members is how `transacted` and `close`
|
|
131
|
+
// were left behind once, under Nuxt only.
|
|
132
|
+
...layerOf(storage, createMemoryStorage),
|
|
137
133
|
auth: fileConfig.auth,
|
|
138
134
|
adapters: fileConfig.adapters,
|
|
139
135
|
remotes: fileConfig.remotes,
|
|
140
136
|
remoteTransport,
|
|
141
|
-
|
|
142
|
-
extensions: [
|
|
143
|
-
// The slot is declared even when this host resolved no storage — a host that resolved
|
|
144
|
-
// its own (the Nitro plugin does, for its bundler) then REPLACES this member in place
|
|
145
|
-
// instead of adding one after the seeds, which is rows before tables.
|
|
146
|
-
migrating(storageMigrate, (message) => log.warn(message)),
|
|
147
|
-
seeding((message) => log.info(`[seed]${message}`)),
|
|
148
|
-
...(_config.extensions ?? []),
|
|
149
|
-
],
|
|
137
|
+
extensions: _config.extensions ?? [],
|
|
150
138
|
// Opened before the container, so released after it. Never wired here until now:
|
|
151
139
|
// this host boots the storage and no host closed one, which is what made a reload
|
|
152
140
|
// leak the pool of every app it discarded.
|
package/dist/boot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAsB,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAwB,MAAM,mBAAmB,CAAC;AA0BlE,oDAAoD;AAEpD,IAAI,OAAO,GAAwB,EAAE,CAAC;AACtC,IAAI,WAAW,GAAwB,IAAI,CAAC;AAE5C,oDAAoD;AAEpD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA2B;IAC1D,OAAO,GAAG,MAAM,CAAC;IACjB,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,MAAoC;IAChE,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;IACpC,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,2EAA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|
|
3
3
|
/** The call envelope, at `/_fougere/call` — the door the browser primitives use. */
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function call(mountPath?: string): ExpressMiddleware;
|
|
5
5
|
/** The session view, at `/_fougere/session`. */
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function session(mountPath?: string): ExpressMiddleware;
|
|
7
7
|
/** The REST projection, under `/api` by default. */
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function rest(mountPath?: string): ExpressMiddleware;
|
|
9
9
|
/** GraphQL, at `/graphql` by default. Declines when the app declares no such adapter. */
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function graphql(mountPath?: string): ExpressMiddleware;
|
|
11
11
|
/** Every door, for an app that wants all of them. What each one SERVES is still the
|
|
12
12
|
* app's declaration — mounting is not publishing. */
|
|
13
13
|
export declare function fougere(): ExpressMiddleware;
|
package/dist/express.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AA2BA,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AACpC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AA+BzE,oFAAoF;AACpF,wBAAgB,
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AA2BA,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AACpC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AA+BzE,oFAAoF;AACpF,wBAAgB,IAAI,CAAC,SAAS,SAAmB,GAAG,iBAAiB,CAqBpE;AAED,gDAAgD;AAChD,wBAAgB,OAAO,CAAC,SAAS,SAAsB,GAAG,iBAAiB,CAK1E;AAED,oDAAoD;AACpD,wBAAgB,IAAI,CAAC,SAAS,SAAS,GAAG,iBAAiB,CA4B1D;AAED,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,SAAS,SAAa,GAAG,iBAAiB,CAoBjE;AAED;sDACsD;AACtD,wBAAgB,OAAO,IAAI,iBAAiB,CAY3C"}
|
package/dist/express.js
CHANGED
|
@@ -29,7 +29,7 @@ function fail(res, next, err) {
|
|
|
29
29
|
next(err);
|
|
30
30
|
}
|
|
31
31
|
/** The call envelope, at `/_fougere/call` — the door the browser primitives use. */
|
|
32
|
-
export function
|
|
32
|
+
export function call(mountPath = '/_fougere/call') {
|
|
33
33
|
return (req, res, next) => {
|
|
34
34
|
const path = pathOf(req);
|
|
35
35
|
if (req.method !== 'POST' || !path.startsWith(mountPath))
|
|
@@ -54,7 +54,7 @@ export function fougereCall(mountPath = '/_fougere/call') {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
/** The session view, at `/_fougere/session`. */
|
|
57
|
-
export function
|
|
57
|
+
export function session(mountPath = '/_fougere/session') {
|
|
58
58
|
return (req, res, next) => {
|
|
59
59
|
if (req.method !== 'GET' || pathOf(req) !== mountPath)
|
|
60
60
|
return next();
|
|
@@ -62,7 +62,7 @@ export function fougereSession(mountPath = '/_fougere/session') {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
/** The REST projection, under `/api` by default. */
|
|
65
|
-
export function
|
|
65
|
+
export function rest(mountPath = '/api') {
|
|
66
66
|
return (req, res, next) => {
|
|
67
67
|
const path = pathOf(req);
|
|
68
68
|
if (!path.startsWith(`${mountPath}/`))
|
|
@@ -93,7 +93,7 @@ export function fougereRest(mountPath = '/api') {
|
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
/** GraphQL, at `/graphql` by default. Declines when the app declares no such adapter. */
|
|
96
|
-
export function
|
|
96
|
+
export function graphql(mountPath = '/graphql') {
|
|
97
97
|
return (req, res, next) => {
|
|
98
98
|
if (req.method !== 'POST' || pathOf(req) !== mountPath)
|
|
99
99
|
return next();
|
|
@@ -115,7 +115,7 @@ export function fougereGraphQL(mountPath = '/graphql') {
|
|
|
115
115
|
/** Every door, for an app that wants all of them. What each one SERVES is still the
|
|
116
116
|
* app's declaration — mounting is not publishing. */
|
|
117
117
|
export function fougere() {
|
|
118
|
-
const doors = [
|
|
118
|
+
const doors = [call(), session(), rest(), graphql()];
|
|
119
119
|
return (req, res, next) => {
|
|
120
120
|
let index = 0;
|
|
121
121
|
const step = (err) => {
|
package/dist/express.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAyB1C,+CAA+C;AAC/C,SAAS,OAAO,CAAC,GAAmB;IAClC,IAAI,GAAG,CAAC,YAAY;QAAE,OAAO,GAAG,CAAC,YAAY,CAAC;IAC9C,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,GAAmB;IACjC,OAAO,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;AAC7E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EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACxB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,CAAC,GAAa,EAAE,EAAE;YAC7B,IAAI,GAAG;gBAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAC5B,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** `@fougere/app` — what an app host needs and what no host owns. */
|
|
2
2
|
export { configureFougere, extendFougere, useFougereApp, reloadFougere, type FougereServerConfig, } from './boot.js';
|
|
3
3
|
export { useFougereAuth } from './auth.js';
|
|
4
|
-
export { tableOf
|
|
5
|
-
export { serveRest,
|
|
4
|
+
export { tableOf } from './rest.js';
|
|
5
|
+
export { serveRest, serveRpc, surfaceOf, rpcParseError, invokeOn, } from './serve.js';
|
|
6
6
|
export { formFieldsOf, tableColumnsOf, payloadOf, errorsByField, type FormEntity, type FormField, type TableColumn, } from './form.js';
|
|
7
7
|
export { sessionViewOf, type SessionView } from './session.js';
|
|
8
8
|
export { stateFor } from './state.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,aAAa,EACb,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** `@fougere/app` — what an app host needs and what no host owns. */
|
|
2
2
|
export { configureFougere, extendFougere, useFougereApp, reloadFougere, } from './boot.js';
|
|
3
3
|
export { useFougereAuth } from './auth.js';
|
|
4
|
-
export { tableOf
|
|
5
|
-
export { serveRest,
|
|
4
|
+
export { tableOf } from './rest.js';
|
|
5
|
+
export { serveRest, serveRpc, surfaceOf, rpcParseError, invokeOn, } from './serve.js';
|
|
6
6
|
export { formFieldsOf, tableColumnsOf, payloadOf, errorsByField, } from './form.js';
|
|
7
7
|
export { sessionViewOf } from './session.js';
|
|
8
8
|
export { stateFor } from './state.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,aAAa,GAId,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAoB,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAuB,MAAM,cAAc,CAAC;AAEjE,sFAAsF;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/web.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** The call envelope. */
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function call(request: Request): Promise<Response>;
|
|
3
3
|
/** The REST projection, mounted under `/api`. */
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function rest(request: Request): Promise<Response>;
|
|
5
5
|
/** The session view over the wire, for a client refreshing after login or logout. */
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function session(request: Request): Promise<Response>;
|
|
7
7
|
/** GraphQL, at whatever path the host mounted it — `/graphql` by convention. */
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function graphql(request: Request): Promise<Response>;
|
|
9
9
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAQA,yBAAyB;AACzB,wBAAsB,
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAQA,yBAAyB;AACzB,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqB9D;AAED,iDAAiD;AACjD,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoB9D;AAED,qFAAqF;AACrF,wBAAsB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEjE;AAED,gFAAgF;AAChF,wBAAsB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkBjE"}
|
package/dist/web.js
CHANGED
|
@@ -5,7 +5,7 @@ import { sessionViewOf } from './session.js';
|
|
|
5
5
|
import { stateFor } from './state.js';
|
|
6
6
|
const WITH_BODY = new Set(['POST', 'PUT', 'PATCH']);
|
|
7
7
|
/** The call envelope. */
|
|
8
|
-
export async function
|
|
8
|
+
export async function call(request) {
|
|
9
9
|
const declared = Number(request.headers.get('content-length'));
|
|
10
10
|
if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
|
|
11
11
|
return Response.json({ message: 'Payload too large' }, { status: 413 });
|
|
@@ -25,7 +25,7 @@ export async function fougereCall(request) {
|
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
27
|
/** The REST projection, mounted under `/api`. */
|
|
28
|
-
export async function
|
|
28
|
+
export async function rest(request) {
|
|
29
29
|
const app = await useFougereApp();
|
|
30
30
|
const url = new URL(request.url);
|
|
31
31
|
const method = request.method.toUpperCase();
|
|
@@ -45,11 +45,11 @@ export async function fougereRest(request) {
|
|
|
45
45
|
return Response.json(outcome.body, { status: outcome.status });
|
|
46
46
|
}
|
|
47
47
|
/** The session view over the wire, for a client refreshing after login or logout. */
|
|
48
|
-
export async function
|
|
48
|
+
export async function session(request) {
|
|
49
49
|
return Response.json(sessionViewOf(await stateFor(request.headers)));
|
|
50
50
|
}
|
|
51
51
|
/** GraphQL, at whatever path the host mounted it — `/graphql` by convention. */
|
|
52
|
-
export async function
|
|
52
|
+
export async function graphql(request) {
|
|
53
53
|
const app = await useFougereApp();
|
|
54
54
|
const body = (await request.json().catch(() => ({})));
|
|
55
55
|
const outcome = await serveGraphQL(app, {
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAEpD,yBAAyB;AACzB,MAAM,CAAC,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAA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,CAAC,OAAgB;IAC5C,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAgB;IAC5C,MAAM,GAAG,GAAG,MAAM,aAAa,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAInD,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE;QACtC,GAAG,IAAI;QACP,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACpE,KAAK,EAAE,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;KACvC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,mCAAmC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fougere/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-alpha.0",
|
|
4
4
|
"description": "The host-independent half of a Fougere app: boot, call envelope, REST table, form contract.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fougere",
|
|
@@ -42,25 +42,25 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"jiti": "^2.6.1",
|
|
45
|
-
"@fougere/
|
|
46
|
-
"@fougere/
|
|
47
|
-
"@fougere/
|
|
48
|
-
"@fougere/
|
|
49
|
-
"@fougere/
|
|
50
|
-
"@fougere/http": "0.
|
|
51
|
-
"@fougere/
|
|
52
|
-
"@fougere/
|
|
53
|
-
"@fougere/
|
|
45
|
+
"@fougere/defaults": "0.9.0-alpha.0",
|
|
46
|
+
"@fougere/schema": "0.9.0-alpha.0",
|
|
47
|
+
"@fougere/core": "0.9.0-alpha.0",
|
|
48
|
+
"@fougere/container": "0.9.0-alpha.0",
|
|
49
|
+
"@fougere/adapter-memory": "0.9.0-alpha.0",
|
|
50
|
+
"@fougere/http": "0.9.0-alpha.0",
|
|
51
|
+
"@fougere/compiler": "0.9.0-alpha.0",
|
|
52
|
+
"@fougere/transport-http": "0.9.0-alpha.0",
|
|
53
|
+
"@fougere/adapter-rest": "0.9.0-alpha.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"vitest": "^4.1.0",
|
|
57
|
-
"@fougere/adapter-graphql": "0.
|
|
57
|
+
"@fougere/adapter-graphql": "0.9.0-alpha.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@fougere/adapter-graphql": "0.
|
|
63
|
+
"@fougere/adapter-graphql": "0.9.0-alpha.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"@fougere/adapter-graphql": {
|
package/src/boot.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { Extension } from '@fougere/core';
|
|
|
9
9
|
import { createContainer } from '@fougere/container';
|
|
10
10
|
import { createMemoryStorage } from '@fougere/adapter-memory';
|
|
11
11
|
import type { App, CreateAppOptions, Storage, FougereConfig, Transport } from '@fougere/core';
|
|
12
|
-
import type
|
|
12
|
+
import { layerOf, type ResolvedStorage } from '@fougere/defaults';
|
|
13
13
|
import { applyCreate, applyUpdate, type SchemaView } from '@fougere/schema';
|
|
14
14
|
|
|
15
15
|
// ── Public types ─────────────────────────────────
|
|
@@ -138,8 +138,6 @@ async function boot(): Promise<App> {
|
|
|
138
138
|
}
|
|
139
139
|
// The storage's two halves, kept together: its ascent is an extension, its connection
|
|
140
140
|
// is not — it is opened here, before the container, so it closes after the container.
|
|
141
|
-
const storageFactory = storage.storageFactory ?? createMemoryStorage;
|
|
142
|
-
const storageMigrate: Extension['up'] | undefined = storage.migrate;
|
|
143
141
|
|
|
144
142
|
// Layer-2 wiring: `remotes: { catalog: 'http://...' }` in fougere.config.ts
|
|
145
143
|
// is all the user writes — the default transport comes from here.
|
|
@@ -171,25 +169,14 @@ async function boot(): Promise<App> {
|
|
|
171
169
|
? { scan: await scanProject(root, undefined, conventions) }
|
|
172
170
|
: {}),
|
|
173
171
|
createContainer,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
enforces: storage.enforces,
|
|
178
|
-
transacted: storage.transacted as never,
|
|
179
|
-
db: storage.db,
|
|
172
|
+
// The layer, spread whole. Naming a few of its members is how `transacted` and `close`
|
|
173
|
+
// were left behind once, under Nuxt only.
|
|
174
|
+
...layerOf(storage, createMemoryStorage),
|
|
180
175
|
auth: fileConfig.auth,
|
|
181
176
|
adapters: fileConfig.adapters,
|
|
182
177
|
remotes: fileConfig.remotes,
|
|
183
178
|
remoteTransport,
|
|
184
|
-
|
|
185
|
-
extensions: [
|
|
186
|
-
// The slot is declared even when this host resolved no storage — a host that resolved
|
|
187
|
-
// its own (the Nitro plugin does, for its bundler) then REPLACES this member in place
|
|
188
|
-
// instead of adding one after the seeds, which is rows before tables.
|
|
189
|
-
migrating(storageMigrate, (message) => log.warn(message)),
|
|
190
|
-
seeding((message) => log.info(`[seed]${message}`)),
|
|
191
|
-
...(_config.extensions ?? []),
|
|
192
|
-
],
|
|
179
|
+
extensions: _config.extensions ?? [],
|
|
193
180
|
// Opened before the container, so released after it. Never wired here until now:
|
|
194
181
|
// this host boots the storage and no host closed one, which is what made a reload
|
|
195
182
|
// leak the pool of every app it discarded.
|
package/src/express.ts
CHANGED
|
@@ -58,7 +58,7 @@ function fail(res: ExpressResponse, next: Next, err: unknown): void {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/** The call envelope, at `/_fougere/call` — the door the browser primitives use. */
|
|
61
|
-
export function
|
|
61
|
+
export function call(mountPath = '/_fougere/call'): ExpressMiddleware {
|
|
62
62
|
return (req, res, next) => {
|
|
63
63
|
const path = pathOf(req);
|
|
64
64
|
if (req.method !== 'POST' || !path.startsWith(mountPath)) return next();
|
|
@@ -82,7 +82,7 @@ export function fougereCall(mountPath = '/_fougere/call'): ExpressMiddleware {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/** The session view, at `/_fougere/session`. */
|
|
85
|
-
export function
|
|
85
|
+
export function session(mountPath = '/_fougere/session'): ExpressMiddleware {
|
|
86
86
|
return (req, res, next) => {
|
|
87
87
|
if (req.method !== 'GET' || pathOf(req) !== mountPath) return next();
|
|
88
88
|
res.status(200).json(sessionViewOf(stateOf(req)));
|
|
@@ -90,7 +90,7 @@ export function fougereSession(mountPath = '/_fougere/session'): ExpressMiddlewa
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/** The REST projection, under `/api` by default. */
|
|
93
|
-
export function
|
|
93
|
+
export function rest(mountPath = '/api'): ExpressMiddleware {
|
|
94
94
|
return (req, res, next) => {
|
|
95
95
|
const path = pathOf(req);
|
|
96
96
|
if (!path.startsWith(`${mountPath}/`)) return next();
|
|
@@ -121,7 +121,7 @@ export function fougereRest(mountPath = '/api'): ExpressMiddleware {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** GraphQL, at `/graphql` by default. Declines when the app declares no such adapter. */
|
|
124
|
-
export function
|
|
124
|
+
export function graphql(mountPath = '/graphql'): ExpressMiddleware {
|
|
125
125
|
return (req, res, next) => {
|
|
126
126
|
if (req.method !== 'POST' || pathOf(req) !== mountPath) return next();
|
|
127
127
|
|
|
@@ -146,7 +146,7 @@ export function fougereGraphQL(mountPath = '/graphql'): ExpressMiddleware {
|
|
|
146
146
|
/** Every door, for an app that wants all of them. What each one SERVES is still the
|
|
147
147
|
* app's declaration — mounting is not publishing. */
|
|
148
148
|
export function fougere(): ExpressMiddleware {
|
|
149
|
-
const doors = [
|
|
149
|
+
const doors = [call(), session(), rest(), graphql()];
|
|
150
150
|
return (req, res, next) => {
|
|
151
151
|
let index = 0;
|
|
152
152
|
const step = (err?: unknown) => {
|
package/src/index.ts
CHANGED
|
@@ -9,22 +9,14 @@ export {
|
|
|
9
9
|
|
|
10
10
|
export { useFougereAuth } from './auth.js';
|
|
11
11
|
|
|
12
|
-
export {
|
|
13
|
-
tableOf,
|
|
14
|
-
matchRoute,
|
|
15
|
-
type Matchable,
|
|
16
|
-
type RouteMatch,
|
|
17
|
-
} from './rest.js';
|
|
12
|
+
export { tableOf } from './rest.js';
|
|
18
13
|
|
|
19
14
|
export {
|
|
20
15
|
serveRest,
|
|
21
|
-
shapeRest,
|
|
22
16
|
serveRpc,
|
|
23
17
|
surfaceOf,
|
|
24
18
|
rpcParseError,
|
|
25
19
|
invokeOn,
|
|
26
|
-
type DoorRequest,
|
|
27
|
-
type Outcome,
|
|
28
20
|
} from './serve.js';
|
|
29
21
|
|
|
30
22
|
export {
|
package/src/web.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { stateFor } from './state.js';
|
|
|
7
7
|
const WITH_BODY = new Set(['POST', 'PUT', 'PATCH']);
|
|
8
8
|
|
|
9
9
|
/** The call envelope. */
|
|
10
|
-
export async function
|
|
10
|
+
export async function call(request: Request): Promise<Response> {
|
|
11
11
|
const declared = Number(request.headers.get('content-length'));
|
|
12
12
|
if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
|
|
13
13
|
return Response.json({ message: 'Payload too large' }, { status: 413 });
|
|
@@ -31,7 +31,7 @@ export async function fougereCall(request: Request): Promise<Response> {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** The REST projection, mounted under `/api`. */
|
|
34
|
-
export async function
|
|
34
|
+
export async function rest(request: Request): Promise<Response> {
|
|
35
35
|
const app = await useFougereApp();
|
|
36
36
|
const url = new URL(request.url);
|
|
37
37
|
const method = request.method.toUpperCase();
|
|
@@ -54,12 +54,12 @@ export async function fougereRest(request: Request): Promise<Response> {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/** The session view over the wire, for a client refreshing after login or logout. */
|
|
57
|
-
export async function
|
|
57
|
+
export async function session(request: Request): Promise<Response> {
|
|
58
58
|
return Response.json(sessionViewOf(await stateFor(request.headers)));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/** GraphQL, at whatever path the host mounted it — `/graphql` by convention. */
|
|
62
|
-
export async function
|
|
62
|
+
export async function graphql(request: Request): Promise<Response> {
|
|
63
63
|
const app = await useFougereApp();
|
|
64
64
|
const body = (await request.json().catch(() => ({}))) as {
|
|
65
65
|
query?: string;
|