Skip to content

Commit 0dbe0a8

Browse files
committed
fix private documentation (1.5.1)
1 parent b303832 commit 0dbe0a8

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dapir",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"type": "module",
55
"description": "An api wrapper",
66
"source": "src/index.ts",

‎src/Server.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ export class Server<
160160
}
161161
log('debug', `Loaded GET ${this.config.routes.documentation.path}`);
162162
this.express.get(this.config.routes.documentation.path, (req, res, next) => {
163-
// @ts-expect-error Documentation is enabled
164-
res.send(this.documentation?.build(req.query?.key != (this.config.routes.documentation.private_key as string)));
163+
if (this.config.routes.documentation.enabled == false) {
164+
// This will likely not happen, but just in case the config is changed after the server has started somehow
165+
res.status(404).send({ error: true, status: 404, code: HttpStatus[404], message: 'Documentation not found' });
166+
return;
167+
}
168+
res.send(this.documentation?.build(req.query?.key == (this.config.routes.documentation.private_key as string)));
165169
return;
166170
});
167171
runMiddleware('postdocs');

0 commit comments

Comments
 (0)