api-mixer/main.ts

19 lines
379 B
TypeScript
Raw Normal View History

2018-10-17 15:34:36 +00:00
import { createServer } from 'http'
import { Socket } from 'net';
import Mixer from './mixer'
const mixer: Mixer = new Mixer();
// 1. build server
const server = createServer(mixer.http_handler);
// 2. bind 404 error
server.on('clientError', (err: Error, sock: Socket) => {
sock.end('HTTP/1.1 400 Bad Request\r\n\r\n');
});
// 3. listen on given port
server.listen(8000);