mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -05:00
18 lines
395 B
JavaScript
18 lines
395 B
JavaScript
|
import { createServer } from 'http';
|
||
|
import { apiHandler } from './api.mjs';
|
||
|
|
||
|
const PORT = process.env.PORT || 8085;
|
||
|
|
||
|
const server = createServer((req, res) => {
|
||
|
apiHandler(req, res).catch(err => {
|
||
|
console.error(err);
|
||
|
res.writeHead(500, {
|
||
|
'Content-Type': 'text/plain'
|
||
|
});
|
||
|
res.end(err.toString());
|
||
|
})
|
||
|
});
|
||
|
|
||
|
server.listen(PORT);
|
||
|
console.log(`API running at http://localhost:${PORT}`);
|