@kitledger/server 0.0.8 → 0.0.9

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/main.d.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  import { type KitledgerConfig } from "@kitledger/core";
2
2
  import { StaticUIConfig } from "@kitledger/core/ui";
3
3
  import { Hono } from "hono";
4
- type ServerConfig = ServerOptions;
4
+ type CorsConfig = {
5
+ origin: string | string[];
6
+ allowMethods: string[];
7
+ allowHeaders: string[];
8
+ maxAge: number;
9
+ credentials: boolean;
10
+ exposeHeaders: string[];
11
+ };
5
12
  type KitledgerContext = {
6
13
  Variables: {
7
14
  config: KitledgerConfig;
@@ -14,11 +21,8 @@ export type ServerOptions = {
14
21
  systemConfig: KitledgerConfig;
15
22
  staticPaths?: string[];
16
23
  staticUIs?: StaticUIConfig[];
24
+ corsConfig?: CorsConfig;
17
25
  };
18
- /**
19
- * Factory function to define the server configuration.
20
- */
21
- export declare function defineServerConfig(options: ServerOptions): ServerConfig;
22
26
  /**
23
27
  * Prints the Kitledger ASCII logo to the console.
24
28
  */
@@ -93,5 +97,5 @@ export declare function printAsciiLogo(): void;
93
97
  * export const POST = server.fetch;
94
98
  * ```
95
99
  */
96
- export declare function createServer(config: ServerConfig): Promise<Hono<KitledgerContext, import("hono/types").BlankSchema, "/">>;
100
+ export declare function createServer(options: ServerOptions): Promise<Hono<KitledgerContext, import("hono/types").BlankSchema, "/">>;
97
101
  export {};
package/dist/main.js CHANGED
@@ -14,8 +14,26 @@ function detectRuntime() {
14
14
  /**
15
15
  * Factory function to define the server configuration.
16
16
  */
17
- export function defineServerConfig(options) {
18
- return options;
17
+ function defineServerConfig(options) {
18
+ /**
19
+ * CORS configuration values and defaults.
20
+ */
21
+ const defaultCorsConfig = {
22
+ origin: "*",
23
+ allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
24
+ allowHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
25
+ exposeHeaders: [],
26
+ credentials: false,
27
+ maxAge: 86400,
28
+ };
29
+ const corsConfig = {
30
+ ...defaultCorsConfig,
31
+ ...options.corsConfig,
32
+ };
33
+ return {
34
+ ...options,
35
+ corsConfig,
36
+ };
19
37
  }
20
38
  /**
21
39
  * Prints the Kitledger ASCII logo to the console.
@@ -93,7 +111,8 @@ export function printAsciiLogo() {
93
111
  * export const POST = server.fetch;
94
112
  * ```
95
113
  */
96
- export async function createServer(config) {
114
+ export async function createServer(options) {
115
+ const config = defineServerConfig(options);
97
116
  const server = new Hono();
98
117
  /**
99
118
  * Ensure all requests have access to the system config.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitledger/server",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",