api-mixer/mixer.ts

24 lines
590 B
TypeScript
Raw Normal View History

2018-10-17 15:34:36 +00:00
import { IncomingMessage, ServerResponse, Server } from "http";
export default class Mixer {
constructor(){
console.log("mixer created");
}
http_handler(req: IncomingMessage, res: ServerResponse){
// reject invalid requests
if( req.method != 'POST' ){
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({reason: 'invalid HTTP method; only POST allowed'}))
}else if( req.url != "/" ){
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({reason: 'invalid URI; only / allowed'}))
}
res.end();
}
}