Skip to content

Commit 9173fea

Browse files
committed
pass onConnection and handleCommand hooks to server
1 parent 17e9db2 commit 9173fea

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ exports.createQuery = Connection.createQuery;
2929

3030
exports.Pool = Pool;
3131

32-
exports.createServer = function(handler) {
32+
exports.createServer = function(opts = {}) {
33+
let handler;
34+
if (typeof opts === 'function') {
35+
handler = opts;
36+
} else {
37+
handler = opts.onConnection;
38+
}
3339
const Server = require('./lib/server.js');
34-
const s = new Server();
40+
const s = new Server({ handleCommand: opts.handleCommand, encoding: opts.encoding || 'cesu8' });
3541
if (handler) {
3642
s.on('connection', handler);
3743
}

0 commit comments

Comments
 (0)