spooder 4.5.2 → 4.5.4

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/api.ts +8 -3
package/README.md CHANGED
@@ -1485,7 +1485,7 @@ const connection = await pool.getConnection();
1485
1485
  The schema directory is expected to contain an SQL file for each table in the database with the file name matching the name of the table.
1486
1486
 
1487
1487
  > [!NOTE]
1488
- > Files without the `.sql` extension (case-insensitive) will be ignored.
1488
+ > The schema directory is searched recursively and files without the `.sql` extension (case-insensitive) will be ignored.
1489
1489
 
1490
1490
  ```
1491
1491
  - database.sqlite
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spooder",
3
3
  "type": "module",
4
- "version": "4.5.2",
4
+ "version": "4.5.4",
5
5
  "exports": {
6
6
  ".": {
7
7
  "bun": "./src/api.ts",
package/src/api.ts CHANGED
@@ -104,8 +104,9 @@ export async function caution(err_message_or_obj: string | object, ...err: objec
104
104
  await handle_error('caution: ', err_message_or_obj, ...err);
105
105
  }
106
106
 
107
+ type WebsocketAcceptReturn = object | boolean;
107
108
  type WebsocketHandlers = {
108
- accept?: (req: Request) => boolean | Promise<boolean>,
109
+ accept?: (req: Request) => WebsocketAcceptReturn | Promise<WebsocketAcceptReturn>,
109
110
  message?: (ws: WebSocket, message: string) => void,
110
111
  message_json?: (ws: WebSocket, message: JsonSerializable) => void,
111
112
  open?: (ws: WebSocket) => void,
@@ -231,9 +232,13 @@ type SchemaVersionMap = Map<string, number>;
231
232
 
232
233
  async function db_load_schema(schema_dir: string, schema_versions: SchemaVersionMap) {
233
234
  const schema_out = [];
234
- const schema_files = await fs.readdir(schema_dir);
235
+ const schema_files = await fs.readdir(schema_dir, { recursive: true, withFileTypes: true });
235
236
 
236
- for (const schema_file of schema_files) {
237
+ for (const schema_file_ent of schema_files) {
238
+ if (schema_file_ent.isDirectory())
239
+ continue;
240
+
241
+ const schema_file = schema_file_ent.name;
237
242
  const schema_file_lower = schema_file.toLowerCase();
238
243
  if (!schema_file_lower.endsWith('.sql'))
239
244
  continue;