vchikalkin b8b8ca6004 Add cache-proxy application with initial setup and configuration
- Created a new cache-proxy application using NestJS, including essential files such as Dockerfile, .gitignore, and .eslintrc.js.
- Implemented core application structure with AppModule, ProxyModule, and ProxyController for handling GraphQL requests.
- Configured caching with Redis and established environment variable management using Zod for validation.
- Added utility functions for query handling and time management, enhancing the application's functionality.
- Included README.md for project documentation and setup instructions.
2025-10-06 20:01:18 +03:00

17 lines
454 B
TypeScript

import { ApolloLink, from, HttpLink } from '@apollo/client/core';
type Parameters = { token: null | string | undefined; uri: string };
export function createLink({ token, uri }: Parameters) {
const cacheLink = new ApolloLink((operation, forward) => {
return forward(operation);
});
const httpLink = new HttpLink({
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
uri,
});
return from([cacheLink, httpLink]);
}