ci: speedup ci by reduce installation packages in certain job (#4457)

This commit is contained in:
LongYinan
2023-09-29 11:02:26 +08:00
committed by GitHub
parent b012e615ba
commit dd94ea5b45
84 changed files with 2954 additions and 2271 deletions
@@ -81,7 +81,6 @@ export const NextAuthOptionsProvider: FactoryProvider<NextAuthOptions> = {
sendVerificationRequest(config, logger, mailer, session, params),
}),
],
// @ts-expect-error Third part library type mismatch
adapter: prismaAdapter,
debug: !config.node.prod,
session: {
@@ -50,7 +50,12 @@ export class NextAuthController {
}
@UseGuards(AuthThrottlerGuard)
@Throttle(60, 60)
@Throttle({
default: {
limit: 60,
ttl: 60,
},
})
@All('*')
async auth(
@Req() req: Request,
+54 -9
View File
@@ -50,7 +50,12 @@ export class AuthResolver {
private readonly session: SessionService
) {}
@Throttle(20, 60)
@Throttle({
default: {
limit: 20,
ttl: 60,
},
})
@ResolveField(() => TokenType)
async token(
@Context() ctx: { req: Request },
@@ -82,7 +87,12 @@ export class AuthResolver {
};
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Mutation(() => UserType)
async signUp(
@Context() ctx: { req: Request },
@@ -95,7 +105,12 @@ export class AuthResolver {
return user;
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Mutation(() => UserType)
async signIn(
@Context() ctx: { req: Request },
@@ -107,7 +122,12 @@ export class AuthResolver {
return user;
}
@Throttle(5, 60)
@Throttle({
default: {
limit: 5,
ttl: 60,
},
})
@Mutation(() => UserType)
@Auth()
async changePassword(
@@ -126,7 +146,12 @@ export class AuthResolver {
return user;
}
@Throttle(5, 60)
@Throttle({
default: {
limit: 5,
ttl: 60,
},
})
@Mutation(() => UserType)
@Auth()
async changeEmail(
@@ -147,7 +172,12 @@ export class AuthResolver {
return user;
}
@Throttle(5, 60)
@Throttle({
default: {
limit: 5,
ttl: 60,
},
})
@Mutation(() => Boolean)
@Auth()
async sendChangePasswordEmail(
@@ -165,7 +195,12 @@ export class AuthResolver {
return !res.rejected.length;
}
@Throttle(5, 60)
@Throttle({
default: {
limit: 5,
ttl: 60,
},
})
@Mutation(() => Boolean)
@Auth()
async sendSetPasswordEmail(
@@ -190,7 +225,12 @@ export class AuthResolver {
// 4. user open confirm email page from new email
// 5. user click confirm button
// 6. send notification email
@Throttle(5, 60)
@Throttle({
default: {
limit: 5,
ttl: 60,
},
})
@Mutation(() => Boolean)
@Auth()
async sendChangeEmail(
@@ -208,7 +248,12 @@ export class AuthResolver {
return !res.rejected.length;
}
@Throttle(5, 60)
@Throttle({
default: {
limit: 5,
ttl: 60,
},
})
@Mutation(() => Boolean)
@Auth()
async sendVerifyChangeEmail(
+36 -6
View File
@@ -91,7 +91,12 @@ export class UserResolver {
private readonly users: UsersService
) {}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Query(() => UserType, {
name: 'currentUser',
description: 'Get current user',
@@ -112,7 +117,12 @@ export class UserResolver {
};
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Query(() => UserType, {
name: 'user',
description: 'Get user by email',
@@ -140,7 +150,12 @@ export class UserResolver {
return user;
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Mutation(() => UserType, {
name: 'uploadAvatar',
description: 'Upload user avatar',
@@ -160,7 +175,12 @@ export class UserResolver {
});
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Mutation(() => RemoveAvatar, {
name: 'removeAvatar',
description: 'Remove user avatar',
@@ -176,14 +196,24 @@ export class UserResolver {
return { success: true };
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Mutation(() => DeleteAccount)
async deleteAccount(@CurrentUser() user: UserType): Promise<DeleteAccount> {
await this.users.deleteUser(user.id);
return { success: true };
}
@Throttle(10, 60)
@Throttle({
default: {
limit: 10,
ttl: 60,
},
})
@Mutation(() => AddToNewFeaturesWaitingList)
async addToNewFeaturesWaitingList(
@CurrentUser() user: UserType,
+12 -2
View File
@@ -282,7 +282,12 @@ export class WorkspaceResolver {
});
}
@Throttle(10, 30)
@Throttle({
default: {
limit: 10,
ttl: 30,
},
})
@Public()
@Query(() => WorkspaceType, {
description: 'Get public workspace by id',
@@ -515,7 +520,12 @@ export class WorkspaceResolver {
}
}
@Throttle(10, 30)
@Throttle({
default: {
limit: 10,
ttl: 30,
},
})
@Public()
@Query(() => InvitationType, {
description: 'Update workspace',
+18 -6
View File
@@ -20,8 +20,12 @@ import { getRequestResponseFromContext } from './utils/nestjs';
inject: [Config],
useFactory: (config: Config): ThrottlerModuleOptions => {
const options: ThrottlerModuleOptions = {
ttl: config.rateLimiter.ttl,
limit: config.rateLimiter.limit,
throttlers: [
{
ttl: config.rateLimiter.ttl,
limit: config.rateLimiter.limit,
},
],
skipIf: () => {
return !config.node.prod || config.affine.canary;
},
@@ -49,8 +53,10 @@ export class CloudThrottlerGuard extends ThrottlerGuard {
return getRequestResponseFromContext(context) as any;
}
protected override getTracker(req: Record<string, any>): string {
return req?.get('CF-Connecting-IP') ?? req?.get('CF-ray') ?? req?.ip;
protected override getTracker(req: Record<string, any>): Promise<string> {
return Promise.resolve(
req?.get('CF-Connecting-IP') ?? req?.get('CF-ray') ?? req?.ip
);
}
}
@@ -65,10 +71,16 @@ export class AuthThrottlerGuard extends CloudThrottlerGuard {
if (req?.url === '/api/auth/session') {
// relax throttle for session auto renew
return super.handleRequest(context, limit * 20, ttl);
return super.handleRequest(context, limit * 20, ttl, {
ttl: ttl * 20,
limit: limit * 20,
});
}
return super.handleRequest(context, limit, ttl);
return super.handleRequest(context, limit, ttl, {
ttl,
limit,
});
}
}