2022-02-14 17:48:52 +00:00
|
|
|
import { createServer } from 'http';
|
|
|
|
import { apiHandler } from './api.mjs';
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 8085;
|
|
|
|
|
|
|
|
const server = createServer((req, res) => {
|
2022-02-14 17:50:16 +00:00
|
|
|
apiHandler(req, res).catch((err) => {
|
2022-02-14 17:48:52 +00:00
|
|
|
console.error(err);
|
|
|
|
res.writeHead(500, {
|
2022-02-14 17:50:16 +00:00
|
|
|
'Content-Type': 'text/plain',
|
2022-02-14 17:48:52 +00:00
|
|
|
});
|
|
|
|
res.end(err.toString());
|
2022-02-14 17:50:16 +00:00
|
|
|
});
|
2022-02-14 17:48:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(PORT);
|
|
|
|
console.log(`API running at http://localhost:${PORT}`);
|