MCPcopy Index your code
hub / github.com/WebThingsIO/webthing-node / get

Method get

lib/server.ts:139–160  ·  view source on GitHub ↗

* Handle a GET request. * * @param {Object} req The request object * @param {Object} res The response object

(req: express.Request, res: express.Response)

Source from the content-addressed store, hash-verified

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/**

Callers 1

constructorMethod · 0.95

Calls 3

asThingDescriptionMethod · 0.80
getThingsMethod · 0.45
getHrefMethod · 0.45

Tested by

no test coverage detected