Skip to content

Commit

Permalink
feat: added ass version to Request metadata (see #223 for info)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Moore committed Oct 14, 2023
1 parent d0a2bf7 commit 35fcee6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const App = {
*/
const assMetaMiddleware = (port: number, proxied: boolean): RequestHandler =>
(req: Request, _res: Response, next: NextFunction) => {
req.ass = { host: `${req.protocol}://${req.hostname}${proxied ? '' : `:${port}`}` };
req.ass = {
host: `${req.protocol}://${req.hostname}${proxied ? '' : `:${port}`}`,
version: App.pkgVersion
};
next();
};

Expand Down Expand Up @@ -107,7 +110,9 @@ async function main() {
warn: (warning: Error) => log.warn('PostCSS', warning.toString())
}));

app.get('/.ass.host', (req, res) => res.send(req.ass.host));
// Metadata routes
app.get('/.ass.host', (req, res) => res.type('text').send(req.ass.host));
app.get('/.ass.version', (req, res) => res.type('text').send(req.ass.version));

// ! I did not want to do it like this how tf did I back myself into this shit
app.get('/admin', (req, res) => res.render('admin', { version: App.pkgVersion }));
Expand Down
5 changes: 5 additions & 0 deletions common/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ declare global {
* Combination of {protocol}://{hostname}
*/
host: string

/**
* ass version
*/
version: string
}

files: { [key: string]: BusBoyFile }
Expand Down

0 comments on commit 35fcee6

Please sign in to comment.