packages: add shared

This commit is contained in:
vchikalkin 2024-03-04 15:39:40 +03:00
parent 8f12447eaf
commit abb3874248
10 changed files with 62 additions and 2 deletions

View File

@ -45,6 +45,7 @@
"fastify": "^4.26.1",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"shared": "workspace:*",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "29.1.1",

View File

@ -15,6 +15,7 @@ import {
} from '@nestjs/common';
import type { Cache } from 'cache-manager';
import { FastifyReply, FastifyRequest } from 'fastify';
import type { QueryItem } from 'shared/types/cache';
import { env } from 'src/config/env';
type RedisStore = Omit<Cache, 'set'> & {
@ -71,7 +72,7 @@ export class ProxyController {
return acc;
},
{} as Record<string, unknown>,
{} as Record<string, QueryItem>,
);
return reply.send(res);

View File

@ -1,3 +1,4 @@
import type { ResponseQueries } from './types';
import getUrls from '@/config/urls';
import { withHandleError } from '@/utils/axios';
import type { QueryFunctionContext } from '@tanstack/react-query';
@ -6,7 +7,9 @@ import axios from 'axios';
const { URL_CACHE_GET_QUERIES, URL_CACHE_DELETE_QUERY, URL_CACHE_FLUSH_ALL } = getUrls();
export function getQueries({ signal }: QueryFunctionContext) {
return withHandleError(axios.get(URL_CACHE_GET_QUERIES, { signal })).then(({ data }) => data);
return withHandleError(axios.get<ResponseQueries>(URL_CACHE_GET_QUERIES, { signal })).then(
({ data }) => data
);
}
export function deleteQuery(queryName: string) {

3
apps/web/api/cache/types.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import type { QueryItem } from 'shared/types/cache';
export type ResponseQueries = Record<string, QueryItem>;

View File

@ -58,6 +58,7 @@
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.3.1",
"msw": "^1.1.0",
"shared": "workspace:*",
"ts-jest": "^29.0.5",
"typescript": "^5.3.3"
},

View File

@ -0,0 +1,10 @@
const { createConfig } = require('@vchikalkin/eslint-config-awesome');
module.exports = createConfig('typescript', {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
ignorePatterns: ['*.config.js', '.eslintrc.js'],
root: true,
});

View File

@ -0,0 +1,13 @@
{
"name": "shared",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"lint": "TIMING=1 eslint \"**/*.ts*\""
},
"devDependencies": {
"@vchikalkin/eslint-config-awesome": "^1.1.6",
"eslint": "^8.52.0",
"tsconfig": "workspace:*"
}
}

View File

@ -0,0 +1,6 @@
{
"extends": "tsconfig/common.json",
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": { "outDir": "./build", "lib": ["DOM", "ES2020"] }
}

View File

@ -0,0 +1,4 @@
export type QueryItem = {
queries: string[];
ttl: number | false;
};

18
pnpm-lock.yaml generated
View File

@ -96,6 +96,9 @@ importers:
prettier:
specifier: ^3.0.0
version: 3.2.5
shared:
specifier: workspace:*
version: link:../../packages/shared
source-map-support:
specifier: ^0.5.21
version: 0.5.21
@ -250,6 +253,9 @@ importers:
msw:
specifier: ^1.1.0
version: 1.3.2(typescript@5.3.3)
shared:
specifier: workspace:*
version: link:../../packages/shared
ts-jest:
specifier: ^29.0.5
version: 29.1.1(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3)
@ -257,6 +263,18 @@ importers:
specifier: ^5.3.3
version: 5.3.3
packages/shared:
devDependencies:
'@vchikalkin/eslint-config-awesome':
specifier: ^1.1.6
version: 1.1.6(@babel/eslint-plugin@7.23.5)(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(eslint-plugin-import@2.29.1)(eslint@8.57.0)(graphql@16.8.1)(prettier@3.2.5)(typescript@5.3.3)
eslint:
specifier: ^8.52.0
version: 8.57.0
tsconfig:
specifier: workspace:*
version: link:../tsconfig
packages/tools:
devDependencies:
'@vchikalkin/eslint-config-awesome':