forked from vercel/hazel
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.ts
More file actions
22 lines (17 loc) · 681 Bytes
/
Copy pathserver.ts
File metadata and controls
22 lines (17 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import "dotenv/config";
import http from "http";
import { carrots } from "./lib/index.js";
// Never let a stray rejection kill the long-running process.
process.on("unhandledRejection", (e) => console.error(e));
if (!process.env.ACCOUNT) throw new Error("Missing ACCOUNT");
if (!process.env.REPOSITORY) throw new Error("Missing REPOSITORY");
const port = process.env.PORT || 3000;
const listener = await carrots({
account: process.env.ACCOUNT,
repository: process.env.REPOSITORY,
token: process.env.TOKEN,
hideVersions: !!process.env.HIDE_VERSIONS,
});
http.createServer(listener).listen(port, () => {
console.log(`Carrots running on http://localhost:${port}`);
});