19 lines
379 B
TypeScript
19 lines
379 B
TypeScript
|
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);
|