@storecraft/database-sqlite 1.0.20 → 1.3.0

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/README.md CHANGED
@@ -38,17 +38,16 @@ const app = new App(
38
38
  )
39
39
  )
40
40
  .withStorage(new NodeLocalStorage())
41
+ .init();
41
42
 
42
- await app.init();
43
- await migrateToLatest(app.db, false);
44
-
45
- const server = http.createServer(app.handler).listen(
43
+ await migrateToLatest(app.__show_me_everything.db, false);
44
+
45
+ http.createServer(app.handler).listen(
46
46
  8000,
47
47
  () => {
48
- console.log(`Server is running on http://localhost:8000`);
48
+ app.print_banner('http://localhost:8000');
49
49
  }
50
50
  );
51
-
52
51
  ```
53
52
 
54
53
  Storecraft will search the following `env` variables
package/index.js CHANGED
@@ -9,13 +9,12 @@ import BetterSQLite from 'better-sqlite3';
9
9
 
10
10
 
11
11
  /**
12
- * @description `better-sqlite` driver for `storecraft`
13
- *
12
+ * @description `better-sqlite3` driver for `storecraft`
14
13
  */
15
14
  export class SQLite extends SQL {
16
15
 
17
16
  /** @satisfies {ENV<Config>} */
18
- static EnvConfig = /** @type{const} */ (
17
+ static EnvConfig = /** @type {const} */ (
19
18
  {
20
19
  filepath: 'SQLITE_FILEPATH',
21
20
  }
@@ -46,7 +45,7 @@ export class SQLite extends SQL {
46
45
 
47
46
  /** @type {SQL["init"]} */
48
47
  init = (app) => {
49
- this.dialect_config.filepath ??= app.platform.env[SQLite.EnvConfig.filepath];
48
+ this.dialect_config.filepath ??= app.env[SQLite.EnvConfig.filepath];
50
49
  super.init(app);
51
50
  }
52
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/database-sqlite",
3
- "version": "1.0.20",
3
+ "version": "1.3.0",
4
4
  "description": "Official SQLite Database driver for storecraft",
5
5
  "license": "MIT",
6
6
  "author": "Tomer Shalev (https://github.com/store-craft)",
@@ -31,7 +31,6 @@
31
31
  "scripts": {
32
32
  "database-sqlite:test": "node ./tests/runner.test.js",
33
33
  "test": "npm run database-sqlite:test",
34
- "prepublishOnly": "npm version patch --force",
35
34
  "sc-publish": "npm publish"
36
35
  },
37
36
  "dependencies": {
@@ -5,6 +5,7 @@ import { NodePlatform } from '@storecraft/core/platform/node';
5
5
  import { api } from '@storecraft/core/test-runner';
6
6
  import { homedir } from 'node:os';
7
7
  import { join } from 'node:path';
8
+ import { NodeLocalStorage } from '@storecraft/core/storage/node';
8
9
 
9
10
  export const create_app = async () => {
10
11
  const app = new App(
@@ -18,11 +19,10 @@ export const create_app = async () => {
18
19
  )
19
20
  .withPlatform(new NodePlatform())
20
21
  .withDatabase(
21
- new SQLite({ filepath: join(homedir(), 'db.sqlite') })
22
- );
22
+ new SQLite({ filepath: ':memory:' })
23
+ ).init();
23
24
 
24
- await app.init();
25
- await migrateToLatest(app.db, false);
25
+ await migrateToLatest(app._.db, false);
26
26
 
27
27
  return app;
28
28
  }
@@ -32,11 +32,11 @@ async function test() {
32
32
 
33
33
  Object.entries(api).slice(0, -1).forEach(
34
34
  ([name, runner]) => {
35
- runner.create(app).run();
35
+ runner.create(app._.app).run();
36
36
  }
37
37
  );
38
- const last_test = Object.values(api).at(-1).create(app);
39
- last_test.after(async () => { await app.db.disconnect() });
38
+ const last_test = Object.values(api).at(-1).create(app._.app);
39
+ last_test.after(async () => { await app._.db.disconnect() });
40
40
  last_test.run();
41
41
  }
42
42