cloud-take-home-assignment-2/external-service/index.js

21 lines
554 B
JavaScript
Raw Normal View History

2024-05-10 13:03:05 +00:00
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}`);