mirror of
https://github.com/directus/directus.git
synced 2026-01-28 04:58:07 -05:00
* Declare return types on functions And a very few other type related minor fixes * Minor syntax fixes * Remove unnecessary escape chars in regexes * Remove unnecessary awaits * Replace deprecated req.connection with req.socket * Replace deprecated upload with uploadOne * Remove unnecessary eslint-disable-next-line comments * Comment empty functions / catch or finally clauses * Fix irregular whitespaces * Add missing returns (null) * Remove unreachable code * A few logical fixes * Remove / Handle non-null assertions which are certainly unnecessary (e.g. in tests)
17 lines
434 B
TypeScript
17 lines
434 B
TypeScript
import { Request } from 'express';
|
|
import url from 'url';
|
|
|
|
export function getCacheKey(req: Request): string {
|
|
const path = url.parse(req.originalUrl).pathname;
|
|
|
|
let key: string;
|
|
|
|
if (path?.includes('/graphql')) {
|
|
key = `${req.accountability?.user || 'null'}-${path}-${JSON.stringify(req.params.query)}`;
|
|
} else {
|
|
key = `${req.accountability?.user || 'null'}-${path}-${JSON.stringify(req.sanitizedQuery)}`;
|
|
}
|
|
|
|
return key;
|
|
}
|