File tree Expand file tree Collapse file tree 6 files changed +554
-8
lines changed Expand file tree Collapse file tree 6 files changed +554
-8
lines changed Original file line number Diff line number Diff line change
1
+ # GitHub Actions workflow
2
+ # https://help.github.com/actions
3
+
4
+ name : CI/CD
5
+
6
+ on :
7
+ push :
8
+ branches : [main]
9
+ pull_request :
10
+ branches : [main]
11
+ release :
12
+ types : [published]
13
+
14
+ jobs :
15
+ test :
16
+ runs-on : ubuntu-latest
17
+ strategy :
18
+ matrix :
19
+ bun-version : [latest, canary]
20
+ steps :
21
+ - name : Checkout repository
22
+ uses : actions/checkout@v4
23
+
24
+ - name : Setup Bun
25
+ uses : oven-sh/setup-bun@v2
26
+ with :
27
+ bun-version : ${{ matrix.bun-version }}
28
+
29
+ - name : Install dependencies
30
+ run : bun install
31
+
32
+ - name : Run tests
33
+ run : bun test
34
+
35
+ - name : Check types
36
+ run : bun run tsc --noEmit
37
+
38
+ lint :
39
+ runs-on : ubuntu-latest
40
+ steps :
41
+ - name : Checkout repository
42
+ uses : actions/checkout@v4
43
+
44
+ - name : Setup Bun
45
+ uses : oven-sh/setup-bun@v2
46
+
47
+ - name : Install dependencies
48
+ run : bun install
49
+
50
+ - name : Run lint checks
51
+ run : bun run tsc --noEmit
52
+
53
+ # publish:
54
+ # needs: [test, lint]
55
+ # if: github.event_name == 'release' && github.event.action == 'published'
56
+ # runs-on: ubuntu-latest
57
+ # steps:
58
+ # - name: Checkout repository
59
+ # uses: actions/checkout@v4
60
+
61
+ # - name: Setup Bun
62
+ # uses: oven-sh/setup-bun@v2
63
+
64
+ # - name: Install dependencies
65
+ # run: bun install
66
+
67
+ # - name: Publish to npm
68
+ # run: npm publish
69
+ # env:
70
+ # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 1
1
import { WebSocketRouter } from "../router" ;
2
- import { JoinRoomSchema , UserJoinedSchema } from "./schema" ;
2
+ import { JoinRoom , UserJoined } from "./schema" ;
3
3
4
4
const ws = new WebSocketRouter ( ) ;
5
5
6
- ws . onMessage ( JoinRoomSchema , ( c ) => {
6
+ ws . onMessage ( JoinRoom , ( c ) => {
7
7
const { roomId } = c . payload ;
8
8
console . log ( `User joined room: ${ roomId } ` ) ;
9
9
10
- c . send ( UserJoinedSchema , {
10
+ c . send ( UserJoined , {
11
11
roomId,
12
12
userId : c . meta . clientId ,
13
13
} ) ;
@@ -17,4 +17,4 @@ ws.onClose((c) => {
17
17
console . log ( `Connection closed` ) ;
18
18
} ) ;
19
19
20
- export { ws as exampleRouter } ;
20
+ export { ws as chatRouter } ;
Original file line number Diff line number Diff line change 1
1
import { Hono } from "hono" ;
2
2
import { WebSocketRouter } from "../index" ;
3
- import { exampleRouter } from "./example " ;
3
+ import { chatRouter } from "./chat " ;
4
4
5
5
// HTTP router
6
6
const app = new Hono ( ) ;
7
7
app . get ( "/" , ( c ) => c . text ( "Welcome to Hono!" ) ) ;
8
8
9
9
// WebSocket router
10
10
const ws = new WebSocketRouter ( ) ;
11
- ws . addRoutes ( exampleRouter ) ;
11
+ ws . addRoutes ( chatRouter ) ;
12
12
13
13
Bun . serve ( {
14
14
port : 3000 ,
Original file line number Diff line number Diff line change 1
1
import { z } from "zod" ;
2
2
import { MessageSchema } from "../schema" ;
3
3
4
- export const JoinRoomSchema = MessageSchema . extend ( {
4
+ export const JoinRoom = MessageSchema . extend ( {
5
5
type : z . literal ( "JOIN_ROOM" ) ,
6
6
payload : z . object ( {
7
7
roomId : z . string ( ) ,
8
8
} ) ,
9
9
} ) ;
10
10
11
- export const UserJoinedSchema = MessageSchema . extend ( {
11
+ export const UserJoined = MessageSchema . extend ( {
12
12
type : z . literal ( "USER_JOINED" ) ,
13
13
payload : z . object ( {
14
14
roomId : z . string ( ) ,
You can’t perform that action at this time.
0 commit comments