mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
refactor(server): rate limit and permission (#4198)
Co-authored-by: LongYinan <lynweklm@gmail.com>
This commit is contained in:
@@ -215,7 +215,7 @@ export const gqlFetcherFactory = (endpoint: string) => {
|
||||
return gqlFetch;
|
||||
};
|
||||
|
||||
export const fetchWithTraceReport = (
|
||||
export const fetchWithTraceReport = async (
|
||||
input: RequestInfo | URL,
|
||||
init?: RequestInit,
|
||||
traceOptions?: { event: string }
|
||||
@@ -241,21 +241,20 @@ export const fetchWithTraceReport = (
|
||||
return fetch(input, init);
|
||||
}
|
||||
|
||||
return fetch(input, init)
|
||||
.then(response => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
traceReporter!.cacheTrace(traceId, spanId, startTime, {
|
||||
requestId,
|
||||
...(event ? { event } : {}),
|
||||
});
|
||||
return response;
|
||||
})
|
||||
.catch(err => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
traceReporter!.uploadTrace(traceId, spanId, startTime, {
|
||||
requestId,
|
||||
...(event ? { event } : {}),
|
||||
});
|
||||
return Promise.reject(err);
|
||||
try {
|
||||
const response = await fetch(input, init);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
traceReporter!.cacheTrace(traceId, spanId, startTime, {
|
||||
requestId,
|
||||
...(event ? { event } : {}),
|
||||
});
|
||||
return response;
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
traceReporter!.uploadTrace(traceId, spanId, startTime, {
|
||||
requestId,
|
||||
...(event ? { event } : {}),
|
||||
});
|
||||
return await Promise.reject(err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
query checkBlobSizes($workspaceId: String!, $size: Float!) {
|
||||
checkBlobSize(workspaceId: $workspaceId, size: $size) {
|
||||
size
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,19 @@ export interface GraphQLQuery {
|
||||
containsFile?: boolean;
|
||||
}
|
||||
|
||||
export const checkBlobSizesQuery = {
|
||||
id: 'checkBlobSizesQuery' as const,
|
||||
operationName: 'checkBlobSizes',
|
||||
definitionName: 'checkBlobSize',
|
||||
containsFile: false,
|
||||
query: `
|
||||
query checkBlobSizes($workspaceId: String!, $size: Float!) {
|
||||
checkBlobSize(workspaceId: $workspaceId, size: $size) {
|
||||
size
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const deleteBlobMutation = {
|
||||
id: 'deleteBlobMutation' as const,
|
||||
operationName: 'deleteBlob',
|
||||
|
||||
@@ -50,6 +50,16 @@ export interface UpdateWorkspaceInput {
|
||||
public: InputMaybe<Scalars['Boolean']['input']>;
|
||||
}
|
||||
|
||||
export type CheckBlobSizesQueryVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
size: Scalars['Float']['input'];
|
||||
}>;
|
||||
|
||||
export type CheckBlobSizesQuery = {
|
||||
__typename?: 'Query';
|
||||
checkBlobSize: { __typename?: 'WorkspaceBlobSizes'; size: number };
|
||||
};
|
||||
|
||||
export type DeleteBlobMutationVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
hash: Scalars['String']['input'];
|
||||
@@ -448,6 +458,11 @@ export type AcceptInviteByWorkspaceIdMutation = {
|
||||
};
|
||||
|
||||
export type Queries =
|
||||
| {
|
||||
name: 'checkBlobSizesQuery';
|
||||
variables: CheckBlobSizesQueryVariables;
|
||||
response: CheckBlobSizesQuery;
|
||||
}
|
||||
| {
|
||||
name: 'listBlobsQuery';
|
||||
variables: ListBlobsQueryVariables;
|
||||
|
||||
Reference in New Issue
Block a user