@deslop/gateway 0.1.1227 → 0.1.1228

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.
@@ -15,7 +15,7 @@
15
15
  <link rel="manifest" href="/manifest.webmanifest" />
16
16
 
17
17
  <title>Gateway</title>
18
- <script type="module" crossorigin src="/assets/index-MrBwOWwH.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-BJcI2a-l.js"></script>
19
19
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-WkwZ5CU-.js">
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-JWBKvPy0.css">
21
21
  </head>
package/dist/server.js CHANGED
@@ -50708,6 +50708,23 @@ const compressBody = /*#__PURE__*/ dual((args) => isHttpClientRequest(args[0]),
50708
50708
  */
50709
50709
  const bodyJson = /*#__PURE__*/ dual(2, (self, body) => map$5(json$1(body), (body) => setBody$1(self, body)));
50710
50710
  /**
50711
+ * Sets a JSON request body using unsafe JSON encoding.
50712
+ *
50713
+ * **When to use**
50714
+ *
50715
+ * Use when the request body is known to be JSON-serializable and a synchronous
50716
+ * `HttpClientRequest` result is needed.
50717
+ *
50718
+ * **Gotchas**
50719
+ *
50720
+ * JSON encoding may throw instead of failing in the Effect error channel.
50721
+ *
50722
+ * @stability unstable
50723
+ * @category combinators
50724
+ * @since 4.0.0
50725
+ */
50726
+ const bodyJsonUnsafe = /*#__PURE__*/ dual(2, (self, body) => setBody$1(self, jsonUnsafe$1(body)));
50727
+ /**
50711
50728
  * Sets an `application/x-www-form-urlencoded` request body from URL parameter input.
50712
50729
  *
50713
50730
  * @stability unstable
@@ -77273,6 +77290,8 @@ const SecureOrigin = Origin.check(makeFilter((value) => {
77273
77290
  const Port = String$6.check(isPattern(/^\d{1,5}$/u), makeFilter((value) => exists(parse$3(value), (port) => port >= 1 && port <= 65535), { expected: "a port between 1 and 65535" }));
77274
77291
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
77275
77292
  const RuntimeConfig = Struct({
77293
+ auth: optionalKey(String$6),
77294
+ name: String$6,
77276
77295
  traces: String$6,
77277
77296
  version: AppVersion
77278
77297
  });
@@ -87931,10 +87950,17 @@ const layerRoutes = use((router) => gen(function* () {
87931
87950
  })
87932
87951
  });
87933
87952
  });
87934
- yield* router.add("GET", "/api/runtime", flatMap$2(packageMetadata, (metadata) => schemaJson(RuntimeConfig)({
87935
- traces,
87936
- version: metadata.version
87937
- })));
87953
+ yield* router.add("GET", "/api/runtime", gen(function* () {
87954
+ return yield* schemaJson(RuntimeConfig)({
87955
+ ...match$8(issuer, {
87956
+ onNone: () => ({}),
87957
+ onSome: (origin) => ({ auth: origin })
87958
+ }),
87959
+ name: yield* appName,
87960
+ traces,
87961
+ version: (yield* packageMetadata).version
87962
+ });
87963
+ }));
87938
87964
  yield* router.add("GET", "/auth/sign-in", toIssuer({}));
87939
87965
  yield* router.add("GET", "/auth/sign-out", toIssuer({ "sign-out": "" }));
87940
87966
  yield* router.add("GET", "/auth/user", gen(function* () {
@@ -87946,6 +87972,22 @@ const layerRoutes = use((router) => gen(function* () {
87946
87972
  }, { headers: { "cache-control": "no-store" } });
87947
87973
  }));
87948
87974
  }));
87975
+ const layerAnnounce = effectDiscard(gen(function* () {
87976
+ const origin = new URL(yield* String$5("APP_URL")).origin;
87977
+ const client = filterStatusOk(yield* HttpClient);
87978
+ yield* match$8(yield* option(String$5("AUTH_URL")), {
87979
+ onNone: () => void_$1,
87980
+ onSome: fnUntraced(function* (issuer) {
87981
+ yield* pipe$1(post(new URL("/api/apps", issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
87982
+ schedule: spaced("1 minute"),
87983
+ times: 60
87984
+ }), ignore$1({
87985
+ log: "Warn",
87986
+ message: "Auth did not list this app"
87987
+ }), forkScoped);
87988
+ })
87989
+ });
87990
+ }));
87949
87991
  function layerIcon(icon) {
87950
87992
  return add("GET", "/icon", succeed$5(text(icon, {
87951
87993
  contentType: "image/svg+xml",
@@ -88192,7 +88234,7 @@ const provider = fnUntraced(function* (given) {
88192
88234
  });
88193
88235
  const layerPlatform = mergeAll$1(layer$5, layer$13, layer$16);
88194
88236
  function server(app) {
88195
- return pipe$1(serve(pipe$1(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb), provide$2(Auth.layer)), {
88237
+ return pipe$1(serve(pipe$1(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(Auth.layer)), {
88196
88238
  disableLogger: true,
88197
88239
  middleware: (http) => guard(app.middleware?.(http) ?? http)
88198
88240
  }), provide$2(mergeAll$1(layerProtocol, match$1(app.telemetry === false, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/gateway",
3
- "version": "0.1.1227",
3
+ "version": "0.1.1228",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MP281X/deslop",
@@ -32,5 +32,5 @@
32
32
  "engines": {
33
33
  "node": ">=26"
34
34
  },
35
- "fingerprint": "597187977bf016b9194966c09b59ee797c5b75fd6c56ad35f76106ac243bc992"
35
+ "fingerprint": "e186eed4666dc10312a1ec045b4618be5dbbaf170dfae59bb59c836731493fcd"
36
36
  }