(res, status, body)
| 113 | } |
| 114 | |
| 115 | function json(res, status, body) { |
| 116 | const data = JSON.stringify(body); |
| 117 | res.writeHead(status, { |
| 118 | 'Content-Type': 'application/json', |
| 119 | 'Access-Control-Allow-Origin': '*', |
| 120 | 'Access-Control-Allow-Methods': 'GET, POST, DELETE, OPTIONS', |
| 121 | 'Access-Control-Allow-Headers': 'Content-Type, Authorization', |
| 122 | // Per-request dynamic responses must not be cached by intermediaries. |
| 123 | // Some upstream aggregators (e.g. sub2api, #97) priority-cache responses |
| 124 | // when they don't see an explicit Cache-Control directive and serve |
| 125 | // stale content for fresh requests. |
| 126 | 'Cache-Control': 'no-store', |
| 127 | }); |
| 128 | res.end(data); |
| 129 | } |
| 130 | |
| 131 | async function route(req, res) { |
| 132 | const { method } = req; |
no outgoing calls
no test coverage detected