Skip to content

Commit

Permalink
lib/server: expose router in browser (for mocking).
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Dec 16, 2023
1 parent 74c98db commit 0a6c29c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/server-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'use strict';

const EventEmitter = require('events');
const Router = require('./router');
const RPC = require('./rpc');

/**
Expand All @@ -28,6 +29,7 @@ class Server extends EventEmitter {
this.server = new EventEmitter();
this.io = new EventEmitter();
this.rpc = new RPC();
this.routes = new Router();
}

async open() {
Expand All @@ -42,17 +44,29 @@ class Server extends EventEmitter {

use() {}

hook() {}
hook(path, handler) {
this.routes.hook(path, handler);
}

get() {}
get(path, handler) {
this.routes.get(path, handler);
}

post() {}
post(path, handler) {
this.routes.post(path, handler);
}

put() {}
put(path, handler) {
this.routes.put(path, handler);
}

del() {}
del(path, handler) {
this.routes.del(path, handler);
}

patch() {}
patch(path, handler) {
this.routes.patch(path, handler);
}

channel() {
return null;
Expand Down

0 comments on commit 0a6c29c

Please sign in to comment.