gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit61c4012761c40127Mission 008: #19 + #21mre61c40127/lib/api-helpers.hl

943 B

  1. // lib/api-helpers.hl — the plumbing of the function routes (lib/api.hl): JSON answers, query numbers.
  2. import { Response } from 'hl:http1'
  3. import { leadingInt } from './util.hl'
  4. static jsonHeaders = { 'Content-Type' = 'application/json; charset=utf-8' 'X-Content-Type-Options' = 'nosniff' 'Cache-Control' = 'no-store' }
  5. static reply = (status, value) => {
  6. return new Response(JSON.stringify(value), { status = status headers = jsonHeaders })
  7. }
  8. static fail = (status, message) => { return reply(status, { error = message }) }
  9. // a query value as a non-negative whole Number, or null (missing or not a number)
  10. static queryNumber = (req, name) => {
  11. v = req.query == null ? null : req.query[name]
  12. if (v == null || hlTypeName(v) != 'String') { return null }
  13. return leadingInt(v)
  14. }
  15. static queryText = (req, name) => {
  16. v = req.query == null ? null : req.query[name]
  17. return v == null || hlTypeName(v) != 'String' || v == '' ? null : v
  18. }

Branches

Latest commits

  • 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
  • f80504e1Records: day38b repro sentmre
  • 8048258bRecords: day38b jb3 regression, L1 Chromes stoppedmre