* Handle a GET request. * * @param {Object} req The request object * @param {Object} res The response object
(req: express.Request, res: express.Response)
| 137 | * @param {Object} res The response object |
| 138 | */ |
| 139 | get(req: express.Request, res: express.Response): void { |
| 140 | const wsHref = `${req.secure ? 'wss' : 'ws'}://${req.headers.host}`; |
| 141 | res.json( |
| 142 | this.things.getThings().map((thing) => { |
| 143 | const description = thing.asThingDescription(); |
| 144 | description.href = thing.getHref(); |
| 145 | description.links.push({ |
| 146 | rel: 'alternate', |
| 147 | href: `${wsHref}${thing.getHref()}`, |
| 148 | }); |
| 149 | description.base = |
| 150 | `${req.protocol}://${req.headers.host}${thing.getHref()}`; |
| 151 | description.securityDefinitions = { |
| 152 | nosec_sc: { |
| 153 | scheme: 'nosec', |
| 154 | }, |
| 155 | }; |
| 156 | description.security = 'nosec_sc'; |
| 157 | return description; |
| 158 | }) |
| 159 | ); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
no test coverage detected