(req: express.Request, res: express.Response, next: express.NextFunction)
| 118 | } |
| 119 | |
| 120 | storedStateHandler(req: express.Request, res: express.Response, next: express.NextFunction) { |
| 121 | const id = unwrapString(req.params.id); |
| 122 | this.storageHandler |
| 123 | .expandId(id) |
| 124 | .then(result => { |
| 125 | let config = JSON.parse(result.config); |
| 126 | if (config.sessions) { |
| 127 | config = this.getGoldenLayoutFromClientState(new ClientState(config)); |
| 128 | } |
| 129 | const metadata = this.getMetaDataFromLink(req, result, config); |
| 130 | this.renderGoldenLayout(config, metadata, req, res); |
| 131 | // And finally, increment the view count |
| 132 | // If any errors pop up, they are just logged, but the response should still be valid |
| 133 | // It's really unlikely that it happens as a result of the id not being there though, |
| 134 | // but can be triggered with a missing implementation for a derived storage (s3/local...) |
| 135 | this.storageHandler.incrementViewCount(id).catch(err => { |
| 136 | logger.error(`Error incrementing view counts for ${id} - ${err}`); |
| 137 | }); |
| 138 | }) |
| 139 | .catch(err => { |
| 140 | logger.warn(`Could not expand ${id}: ${err}`); |
| 141 | next({ |
| 142 | statusCode: 404, |
| 143 | message: `ID "${id}" could not be found`, |
| 144 | }); |
| 145 | }); |
| 146 | } |
| 147 | |
| 148 | getGoldenLayoutFromClientState(state: ClientState) { |
| 149 | const goldenifier = new ClientStateGoldenifier(); |
no test coverage detected