create-seiro 0.1.4 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-seiro",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Scaffold a new Seiro project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "test": "bun test server.test.ts"
11
11
  },
12
12
  "dependencies": {
13
- "seiro": "^0.1.3",
13
+ "seiro": "^0.1.6",
14
14
  "@preact/signals-core": "^1.12.2",
15
15
  "postgres": "^3.4.8"
16
16
  },
@@ -1,26 +1,33 @@
1
1
  import { expect, test, beforeAll, afterAll } from "bun:test";
2
+ import { $ } from "bun";
2
3
  import { createClient } from "seiro/client";
3
4
  import type { Commands, Queries, Events, User } from "./types";
4
5
 
5
6
  const DATABASE_URL = "postgres://seiro:seiro@localhost:5433/seiro_test";
6
7
  process.env.DATABASE_URL = DATABASE_URL;
7
-
8
- // Dynamic import to use test database
9
- const serverModule = await import("./server");
8
+ process.env.PORT = "3001";
10
9
 
11
10
  type TestClient = ReturnType<typeof createClient<Commands, Queries, Events>>;
12
11
  let client: TestClient;
13
12
 
14
13
  beforeAll(async () => {
14
+ // Start test database
15
+ await $`docker compose -f compose.test.yml up -d --wait`.quiet();
16
+
17
+ // Dynamic import to use test database
18
+ await import("./server");
19
+
15
20
  // Wait for server to be ready
16
21
  await new Promise((r) => setTimeout(r, 500));
17
22
 
18
- client = createClient<Commands, Queries, Events>("ws://localhost:3000/ws");
23
+ client = createClient<Commands, Queries, Events>("ws://localhost:3001/ws");
19
24
  await client.connect<User>();
20
25
  });
21
26
 
22
- afterAll(() => {
27
+ afterAll(async () => {
23
28
  client.close();
29
+ // Stop test database
30
+ await $`docker compose -f compose.test.yml down -v`.quiet();
24
31
  });
25
32
 
26
33
  test("register creates user and returns token", async () => {
@@ -5,11 +5,12 @@ import * as auth from "./auth/server";
5
5
 
6
6
  const DATABASE_URL =
7
7
  process.env.DATABASE_URL ?? "postgres://seiro:seiro@localhost:5432/seiro";
8
+ const PORT = parseInt(process.env.PORT ?? "3000", 10);
8
9
 
9
10
  const sql = postgres(DATABASE_URL);
10
11
 
11
12
  const server = createServer({
12
- port: 3000,
13
+ port: PORT,
13
14
  auth: {
14
15
  verify: auth.verifyToken,
15
16
  public: ["auth.register", "auth.login"],
@@ -26,4 +27,4 @@ auth.register(server, sql);
26
27
  const app = await server.start({ "/": homepage });
27
28
 
28
29
  console.log(`Server running at ${app.url}`);
29
- console.log(`WebSocket at ws://localhost:3000/ws`);
30
+ console.log(`WebSocket at ws://localhost:${PORT}/ws`);