jukebox
All repositories: gitoria
943 B
// lib/api-helpers.hl — the plumbing of the function routes (lib/api.hl): JSON answers, query numbers.import { Response } from 'hl:http1'import { leadingInt } from './util.hl'static jsonHeaders = { 'Content-Type' = 'application/json; charset=utf-8' 'X-Content-Type-Options' = 'nosniff' 'Cache-Control' = 'no-store' }static reply = (status, value) => {return new Response(JSON.stringify(value), { status = status headers = jsonHeaders })}static fail = (status, message) => { return reply(status, { error = message }) }// a query value as a non-negative whole Number, or null (missing or not a number)static queryNumber = (req, name) => {v = req.query == null ? null : req.query[name]if (v == null || hlTypeName(v) != 'String') { return null }return leadingInt(v)}static queryText = (req, name) => {v = req.query == null ? null : req.query[name]return v == null || hlTypeName(v) != 'String' || v == '' ? null : v}
Branches
Latest commits
- b264e5deRecords: P1 icons stopmre
- 514d7cbeRecords: mission 008 startedmre
- 61c40127Mission 008: #19 + #21mre
- 6dcaeb46Records: resetKey planmre
- c5dbf2ecRecords: R2 resultmre
- 956069b8Records: R1 result, mission 007mre
- 3c8a2e12Mission 007: #20 sort scrollmre
- deb8cef5Records: mission 006 startedmre
- 4f0ad42fMission 006: jukebox#20mre
- 800cae06Records: #21 planmre
- 64bc7823Records: #21 causemre
- 76639655Records: B1 questionmre
- d7906b36Records: mission 005 startedmre
- d3df773cMission 005: doc linemre
- 6a5d840aMission 005: jukebox#22mre
- 13e5e748Records: mission 004 startedmre
- a8098271Mission 004: jukebox#21mre
- df8f5205Records: jukebox#19-21, #11 closedmre
- b7a4e692Records: hybriel#298mre
- 9bcbb017Records: day38b waits for day39 fixmre