mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-30 02:23:56 +03:00
feat: optional payment for server (#5055)
This commit is contained in:
parent
9dc2d55a5a
commit
13e712158c
30
packages/backend/server/src/modules/config.ts
Normal file
30
packages/backend/server/src/modules/config.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { Field, ObjectType, Query } from '@nestjs/graphql';
|
||||||
|
|
||||||
|
import { SERVER_FLAVOR } from '../modules';
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class ServerConfigType {
|
||||||
|
@Field({ description: 'server version' })
|
||||||
|
version!: string;
|
||||||
|
|
||||||
|
@Field({ description: 'server flavor' })
|
||||||
|
flavor!: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ServerConfigResolver {
|
||||||
|
@Query(() => ServerConfigType, {
|
||||||
|
description: 'server config',
|
||||||
|
})
|
||||||
|
serverConfig(): ServerConfigType {
|
||||||
|
return {
|
||||||
|
version: AFFiNE.version,
|
||||||
|
flavor: SERVER_FLAVOR || 'allinone',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [ServerConfigResolver],
|
||||||
|
})
|
||||||
|
export class ServerConfigModule {}
|
@ -3,7 +3,7 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
|
|||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
|
|
||||||
import { GqlModule } from '../graphql.module';
|
import { GqlModule } from '../graphql.module';
|
||||||
import { AuthModule } from './auth';
|
import { ServerConfigModule } from './config';
|
||||||
import { DocModule } from './doc';
|
import { DocModule } from './doc';
|
||||||
import { PaymentModule } from './payment';
|
import { PaymentModule } from './payment';
|
||||||
import { SyncModule } from './sync';
|
import { SyncModule } from './sync';
|
||||||
@ -22,13 +22,23 @@ switch (SERVER_FLAVOR) {
|
|||||||
case 'sync':
|
case 'sync':
|
||||||
BusinessModules.push(SyncModule, DocModule.forSync());
|
BusinessModules.push(SyncModule, DocModule.forSync());
|
||||||
break;
|
break;
|
||||||
case 'graphql':
|
case 'selfhosted':
|
||||||
BusinessModules.push(
|
BusinessModules.push(
|
||||||
|
ServerConfigModule,
|
||||||
|
ScheduleModule.forRoot(),
|
||||||
|
GqlModule,
|
||||||
|
WorkspaceModule,
|
||||||
|
UsersModule,
|
||||||
|
DocModule.forRoot()
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'graphql':
|
||||||
|
BusinessModules.push(
|
||||||
|
ServerConfigModule,
|
||||||
ScheduleModule.forRoot(),
|
ScheduleModule.forRoot(),
|
||||||
GqlModule,
|
GqlModule,
|
||||||
WorkspaceModule,
|
WorkspaceModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
AuthModule,
|
|
||||||
DocModule.forRoot(),
|
DocModule.forRoot(),
|
||||||
PaymentModule
|
PaymentModule
|
||||||
);
|
);
|
||||||
@ -36,11 +46,11 @@ switch (SERVER_FLAVOR) {
|
|||||||
case 'allinone':
|
case 'allinone':
|
||||||
default:
|
default:
|
||||||
BusinessModules.push(
|
BusinessModules.push(
|
||||||
|
ServerConfigModule,
|
||||||
ScheduleModule.forRoot(),
|
ScheduleModule.forRoot(),
|
||||||
GqlModule,
|
GqlModule,
|
||||||
WorkspaceModule,
|
WorkspaceModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
AuthModule,
|
|
||||||
SyncModule,
|
SyncModule,
|
||||||
DocModule.forRoot(),
|
DocModule.forRoot(),
|
||||||
PaymentModule
|
PaymentModule
|
||||||
@ -48,4 +58,4 @@ switch (SERVER_FLAVOR) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { BusinessModules };
|
export { BusinessModules, SERVER_FLAVOR };
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
|
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
|
|
||||||
|
type ServerConfigType {
|
||||||
|
"""server version"""
|
||||||
|
version: String!
|
||||||
|
|
||||||
|
"""server flavor"""
|
||||||
|
flavor: String!
|
||||||
|
}
|
||||||
|
|
||||||
type UserType {
|
type UserType {
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
@ -240,6 +248,9 @@ type DocHistoryType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
|
"""server config"""
|
||||||
|
serverConfig: ServerConfigType!
|
||||||
|
|
||||||
"""Get is owner of workspace"""
|
"""Get is owner of workspace"""
|
||||||
isOwner(workspaceId: String!): Boolean!
|
isOwner(workspaceId: String!): Boolean!
|
||||||
|
|
||||||
|
@ -545,6 +545,20 @@ mutation sendVerifyChangeEmail($token: String!, $email: String!, $callbackUrl: S
|
|||||||
}`,
|
}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const serverConfigQuery = {
|
||||||
|
id: 'serverConfigQuery' as const,
|
||||||
|
operationName: 'serverConfig',
|
||||||
|
definitionName: 'serverConfig',
|
||||||
|
containsFile: false,
|
||||||
|
query: `
|
||||||
|
query serverConfig {
|
||||||
|
serverConfig {
|
||||||
|
version
|
||||||
|
flavor
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
};
|
||||||
|
|
||||||
export const setWorkspacePublicByIdMutation = {
|
export const setWorkspacePublicByIdMutation = {
|
||||||
id: 'setWorkspacePublicByIdMutation' as const,
|
id: 'setWorkspacePublicByIdMutation' as const,
|
||||||
operationName: 'setWorkspacePublicById',
|
operationName: 'setWorkspacePublicById',
|
||||||
|
6
packages/frontend/graphql/src/graphql/server-config.gql
Normal file
6
packages/frontend/graphql/src/graphql/server-config.gql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
query serverConfig {
|
||||||
|
serverConfig {
|
||||||
|
version
|
||||||
|
flavor
|
||||||
|
}
|
||||||
|
}
|
@ -533,6 +533,17 @@ export type SendVerifyChangeEmailMutation = {
|
|||||||
sendVerifyChangeEmail: boolean;
|
sendVerifyChangeEmail: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ServerConfigQueryVariables = Exact<{ [key: string]: never }>;
|
||||||
|
|
||||||
|
export type ServerConfigQuery = {
|
||||||
|
__typename?: 'Query';
|
||||||
|
serverConfig: {
|
||||||
|
__typename?: 'ServerConfigType';
|
||||||
|
version: string;
|
||||||
|
flavor: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export type SetWorkspacePublicByIdMutationVariables = Exact<{
|
export type SetWorkspacePublicByIdMutationVariables = Exact<{
|
||||||
id: Scalars['ID']['input'];
|
id: Scalars['ID']['input'];
|
||||||
public: Scalars['Boolean']['input'];
|
public: Scalars['Boolean']['input'];
|
||||||
@ -732,6 +743,11 @@ export type Queries =
|
|||||||
variables: PricesQueryVariables;
|
variables: PricesQueryVariables;
|
||||||
response: PricesQuery;
|
response: PricesQuery;
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
name: 'serverConfigQuery';
|
||||||
|
variables: ServerConfigQueryVariables;
|
||||||
|
response: ServerConfigQuery;
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
name: 'subscriptionQuery';
|
name: 'subscriptionQuery';
|
||||||
variables: SubscriptionQueryVariables;
|
variables: SubscriptionQueryVariables;
|
||||||
|
Loading…
Reference in New Issue
Block a user