Skip to content

Commit d2aa291

Browse files
committed
make the red go away
1 parent 6e60713 commit d2aa291

File tree

5 files changed

+134
-26295
lines changed

5 files changed

+134
-26295
lines changed

dist/cli.js

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,13 @@ class Polka extends trouter {
357357

358358
var polka = opts => new Polka(opts);
359359

360+
const { STATUS_CODES } = http__default['default'];
361+
362+
var send = function (res, code=200, data='', headers={}) {
363+
res.writeHead(code, headers);
364+
res.end(data || STATUS_CODES[code]);
365+
};
366+
360367
async function rc_read_file(file_path) {
361368
let file_or_dir = {
362369
name: file_path.split("/").pop(),
@@ -24901,11 +24908,57 @@ async function cli() {
2490124908

2490224909
console.log(is_valid ? "\nEVERYTHING IS VALID\n" : "\nTHIS IS NOT VALID\n");
2490324910

24911+
24912+
24913+
24914+
24915+
24916+
24917+
24918+
24919+
24920+
24921+
24922+
24923+
24924+
24925+
24926+
console.log(ready_for_cf);
24927+
2490424928
polka()
2490524929
.get("/docs/:project/:type", (req, res) => {
24906-
console.log(`~> Hello, ${req.hello}`);
24907-
res.end(`User: ${req.params.id}`);
24930+
const { project, type } = req.params;
24931+
const version = req.query.version || "latest";
24932+
const full = typeof req.query.content === "string";
24933+
24934+
// const docs = await Docs.list(project, type, version, full);
24935+
const _key = `${project}@${version}:${type}:${full ? "content" : "list"}`;
24936+
24937+
const match = ready_for_cf.find(({ key }) => key === _key);
24938+
if (match) send(res, 200, match.value);
24939+
else
24940+
send(res, 404, {
24941+
message: `'${project}@${version}' '${type}' entry not found.`,
24942+
});
24943+
// res.end(`Project: ${req.params.project}. Type: ${req.params.type}`);
2490824944
})
24945+
.get(
24946+
"/docs/:project/:type/:slug",
24947+
(req, res) => {
24948+
const { project, type, slug } = req.params;
24949+
const version = req.query.version || "latest";
24950+
24951+
const _key = `${project}@${version}:${type}:${slug}`;
24952+
const match = ready_for_cf.find(({ key }) => key === _key);
24953+
24954+
if (match) send(res, 200, match.value);
24955+
else
24956+
send(req, 404, {
24957+
message: `'${project}@${version}' '${type}' entry for '${slug}' not found.`,
24958+
});
24959+
// res.end(`Project: ${req.params.project}. Type: ${req.params.type}`);
24960+
}
24961+
)
2490924962
.listen(3456, (err) => {
2491024963
if (err) throw err;
2491124964
console.log(`> Running on localhost:3456`);

0 commit comments

Comments
 (0)