spooder 6.1.5 → 6.1.7

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/bun.lock CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "lockfileVersion": 1,
3
+ "configVersion": 1,
3
4
  "workspaces": {
4
5
  "": {
5
6
  "name": "spooder",
@@ -9,15 +10,11 @@
9
10
  },
10
11
  },
11
12
  "packages": {
12
- "@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
13
+ "@types/bun": ["@types/bun@1.3.3", "", { "dependencies": { "bun-types": "1.3.3" } }, "sha512-ogrKbJ2X5N0kWLLFKeytG0eHDleBYtngtlbu9cyBKFtNL3cnpDZkNdQj8flVf6WTZUX5ulI9AY1oa7ljhSrp+g=="],
13
14
 
14
- "@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
15
+ "@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
15
16
 
16
- "@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
17
-
18
- "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
19
-
20
- "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
17
+ "bun-types": ["bun-types@1.3.3", "", { "dependencies": { "@types/node": "*" } }, "sha512-z3Xwlg7j2l9JY27x5Qn3Wlyos8YAp0kKRlrePAOjgjMGS5IG6E7Jnlx736vH9UVI4wUICwwhC9anYL++XeOgTQ=="],
21
18
 
22
19
  "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
23
20
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "spooder",
3
3
  "author": "Kruithne <kruithne@gmail.com>",
4
4
  "type": "module",
5
- "version": "6.1.5",
5
+ "version": "6.1.7",
6
6
  "module": "./src/api.ts",
7
7
  "bin": {
8
8
  "spooder": "./src/cli.ts"
package/src/api.ts CHANGED
@@ -1841,24 +1841,37 @@ export function http_serve(port: number, hostname?: string) {
1841
1841
  /** Register a JSON endpoint with automatic content validation. */
1842
1842
  json: (path: string, handler: JSONRequestHandler, method: HTTP_METHODS = 'POST'): void => {
1843
1843
  const json_wrapper: RequestHandler = async (req: Request, url: URL) => {
1844
+ // handle CORS preflight
1845
+ if (req.method === 'OPTIONS') {
1846
+ return new Response(null, {
1847
+ status: 204,
1848
+ headers: {
1849
+ 'Access-Control-Allow-Origin': '*',
1850
+ 'Access-Control-Allow-Methods': `${Array.isArray(method) ? method.join(', ') : method}, OPTIONS`,
1851
+ 'Access-Control-Allow-Headers': 'Content-Type, User-Agent'
1852
+ }
1853
+ });
1854
+ }
1855
+
1844
1856
  try {
1845
1857
  if (req.headers.get('Content-Type') !== 'application/json')
1846
1858
  return 400; // Bad Request
1847
-
1859
+
1848
1860
  const json = await req.json();
1849
1861
  if (json === null || typeof json !== 'object' || Array.isArray(json))
1850
1862
  return 400; // Bad Request
1851
-
1863
+
1852
1864
  return handler(req, url, json as JsonObject);
1853
1865
  } catch (e) {
1854
1866
  return 400; // Bad Request
1855
1867
  }
1856
1868
  };
1857
-
1869
+
1858
1870
  if (path.length > 1 && path.endsWith('/'))
1859
1871
  path = path.slice(0, -1);
1860
-
1861
- routes.push([path.split('/'), json_wrapper, method]);
1872
+
1873
+ const methods: HTTP_METHODS = Array.isArray(method) ? [...method, 'OPTIONS'] : [method, 'OPTIONS'];
1874
+ routes.push([path.split('/'), json_wrapper, methods]);
1862
1875
  },
1863
1876
 
1864
1877
  /** Unregister a specific route */
package/src/cli.ts CHANGED
@@ -296,6 +296,8 @@ async function start_server() {
296
296
 
297
297
  const config = await get_config();
298
298
 
299
+ await apply_updates(config);
300
+
299
301
  const instances = config.instances;
300
302
  const n_instances = instances.length;
301
303