mirror of
https://github.com/directus/directus.git
synced 2026-01-30 23:08:15 -05:00
19 lines
467 B
TypeScript
19 lines
467 B
TypeScript
import { Request } from 'express';
|
|
import url from 'url';
|
|
import hash from 'object-hash';
|
|
import { pick } from 'lodash';
|
|
|
|
export function getCacheKey(req: Request): string {
|
|
const path = url.parse(req.originalUrl).pathname;
|
|
const isGraphQl = path?.includes('/graphql');
|
|
|
|
const info = {
|
|
user: req.accountability?.user || null,
|
|
path,
|
|
query: isGraphQl ? pick(req.query, ['query', 'variables']) : req.sanitizedQuery,
|
|
};
|
|
|
|
const key = hash(info);
|
|
return key;
|
|
}
|