Conduit Blueprint typedef bugfix
diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js
index b7bfe60..ffb937b 100644
--- a/docs/docusaurus.config.js
+++ b/docs/docusaurus.config.js
@@ -50,7 +50,7 @@
},
footer: {
style: 'dark',
- copyright: "Copyright (c) jottocraft 2024"
+ copyright: "Copyright (c) jottocraft 2024-2025"
},
prism: {
theme: prismThemes.github,
diff --git a/yggdrasil/package.json b/yggdrasil/package.json
index 1c29621..95b164e 100644
--- a/yggdrasil/package.json
+++ b/yggdrasil/package.json
@@ -1,7 +1,7 @@
{
"name": "@jottocraft/yggdrasil",
"description": "A simple and flexible TypeScript library for streamlining web request handling.",
- "version": "0.0.1-alpha.8",
+ "version": "0.0.1-alpha.9",
"license": "LGPL-2.1-only",
"author": "jottocraft <[email protected]>",
"main": "lib/index.js",
diff --git a/yggdrasil/src/YggdrasilConduitServer.ts b/yggdrasil/src/YggdrasilConduitServer.ts
index cacbbb5..5855744 100644
--- a/yggdrasil/src/YggdrasilConduitServer.ts
+++ b/yggdrasil/src/YggdrasilConduitServer.ts
@@ -16,14 +16,14 @@
* An object that stores the server's Conduit function implementations.
*/
export type YggdrasilConduitApiClientImpl<AppTypes extends YggdrasilAppTypes, ApiSpec extends YggdrasilConduitAPI> = {
- [Property in keyof ApiSpec["client"]]: ApiSpec["client"][Property] extends AnyFn ? YggdrasilConduitAPIHandler<AppTypes, ApiSpec, ApiSpec["client"][Property]> : YggdrasilConduitApiClientImpl<AppTypes, ApiSpec>;
+ [Property in keyof ApiSpec["client"]]: ApiSpec["client"][Property] extends AnyFn ? YggdrasilConduitAPIHandler<AppTypes, ApiSpec, ApiSpec["client"][Property]> : YggdrasilConduitApiClientImpl<AppTypes, Omit<ApiSpec, "client"> & { client: ApiSpec["client"][Property] }>;
};
/**
* A helper object for defining Conduit function implementations with automatic type safety.
*/
export type YggdrasilConduitApiClientBlueprint<AppTypes extends YggdrasilAppTypes, ApiSpec extends YggdrasilConduitAPI> = {
- [Property in keyof ApiSpec["client"]]: ApiSpec["client"][Property] extends AnyFn ? (impl: YggdrasilConduitAPIHandler<AppTypes, ApiSpec, ApiSpec["client"][Property]>) => YggdrasilConduitAPIHandler<AppTypes, ApiSpec, ApiSpec["client"][Property]> : YggdrasilConduitApiClientBlueprint<AppTypes, ApiSpec>;
+ [Property in keyof ApiSpec["client"]]: ApiSpec["client"][Property] extends AnyFn ? (impl: YggdrasilConduitAPIHandler<AppTypes, ApiSpec, ApiSpec["client"][Property]>) => YggdrasilConduitAPIHandler<AppTypes, ApiSpec, ApiSpec["client"][Property]> : YggdrasilConduitApiClientBlueprint<AppTypes, Omit<ApiSpec, "client"> & { client: ApiSpec["client"][Property] }>;
};
/**
@@ -44,7 +44,7 @@
async handleRequest(ygg: YggdrasilServerContext<AppTypes>): Promise<Response> {
if (!ygg.options.conduitBasePath) throw ygg.status(500, "YGG_BADLY_CONFIGURED", "conduitBasePath must be configured to use Yggdrasil Server Conduit.");
-
+
let requestedPath = ygg.pathname.requested.replace(ygg.options.conduitBasePath, "");
if (!ygg.pathname.requested.startsWith(ygg.options.conduitBasePath) || (requestedPath === "/") || requestedPath.endsWith("/")) throw ygg.status(404, "YGG_API_NOT_FOUND", "The requested API can't be located.");
@@ -64,11 +64,11 @@
if (requestedApi) {
if (ygg.request.headers.get("Content-Type") !== "application/json+jottocraft-ygg-req") throw ygg.status(400, "YGG_BAD_API_REQUEST", "Badly formatted Conduit request.");
-
+
let request: YggdrasilConduitRequest<ApiSpec["context"], unknown[]>;
try {
request = await ygg.request.json();
- } catch(e) {
+ } catch (e) {
throw ygg.status(400, "YGG_BAD_API_REQUEST", "Failed to parse Conduit request body.");
}