cloud-take-home-assignment-2/external-service/index.js
2024-05-10 14:03:05 +01:00

21 lines
554 B
JavaScript

const http = require('http');
const { getResponse } = require('./getResponse');
const { postResponse } = require('./postResponse');
const { unsupportedMethodResponse } = require('./unsupportedMethodResponse');
const port = 3000;
http
.createServer((req, res) => {
switch (req.method) {
case 'GET':
return getResponse(res);
case 'POST':
return postResponse(req, res);
default:
return unsupportedMethodResponse(res);
}
})
.listen(port);
console.log(`Server listening on http://localhost:${port}`);