mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
refactor(infra): directory structure (#4615)
This commit is contained in:
42
packages/backend/server/src/modules/users/gates.ts
Normal file
42
packages/backend/server/src/modules/users/gates.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
type FeatureEarlyAccessPreview = {
|
||||
whitelist: RegExp[];
|
||||
};
|
||||
|
||||
type FeatureStorageLimit = {
|
||||
storageQuota: number;
|
||||
};
|
||||
|
||||
type UserFeatureGate = {
|
||||
earlyAccessPreview: FeatureEarlyAccessPreview;
|
||||
freeUser: FeatureStorageLimit;
|
||||
proUser: FeatureStorageLimit;
|
||||
};
|
||||
|
||||
const UserLevel = {
|
||||
freeUser: {
|
||||
storageQuota: 10 * 1024 * 1024 * 1024,
|
||||
},
|
||||
proUser: {
|
||||
storageQuota: 100 * 1024 * 1024 * 1024,
|
||||
},
|
||||
} satisfies Pick<UserFeatureGate, 'freeUser' | 'proUser'>;
|
||||
|
||||
export function getStorageQuota(features: string[]) {
|
||||
for (const feature of features) {
|
||||
if (feature in UserLevel) {
|
||||
return UserLevel[feature as keyof typeof UserLevel].storageQuota;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const UserType = {
|
||||
earlyAccessPreview: {
|
||||
whitelist: [/@toeverything\.info$/],
|
||||
},
|
||||
} satisfies Pick<UserFeatureGate, 'earlyAccessPreview'>;
|
||||
|
||||
export const FeatureGates = {
|
||||
...UserType,
|
||||
...UserLevel,
|
||||
} satisfies UserFeatureGate;
|
||||
Reference in New Issue
Block a user