mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 15:16:28 +08:00
fix(server): apply env overrides after all config merged (#5795)
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
// > Configurations merge order
|
||||
// 1. load environment variables (`.env` if provided, and from system)
|
||||
// 2. load `src/fundamentals/config/default.ts` for all default settings
|
||||
// 3. apply `./affine.env.ts` patches
|
||||
// 4. apply `./affine.ts` patches (this file)
|
||||
// 3. apply `./affine.ts` patches (this file)
|
||||
// 4. apply `./affine.env.ts` patches
|
||||
//
|
||||
//
|
||||
// ###############################################################
|
||||
|
||||
@@ -382,7 +382,7 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
|
||||
// take it ease, we don't want to overload db and or cpu
|
||||
// if we limit the taken number here,
|
||||
// user will never see the latest doc if there are too many updates pending to be merged.
|
||||
take: 100,
|
||||
take: this.config.doc.manager.maxUpdatesPullCount,
|
||||
});
|
||||
|
||||
// perf(memory): avoid sorting in db
|
||||
|
||||
@@ -56,7 +56,7 @@ export class WorkspacesController {
|
||||
this.logger.warn(`Blob ${workspaceId}/${name} has no metadata`);
|
||||
}
|
||||
|
||||
res.setHeader('cache-control', 'public, max-age=31536000, immutable');
|
||||
res.setHeader('cache-control', 'public, max-age=2592000, immutable');
|
||||
body.pipe(res);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ export class WorkspacesController {
|
||||
}
|
||||
|
||||
res.setHeader('content-type', 'application/octet-stream');
|
||||
res.setHeader('cache-control', 'no-cache');
|
||||
res.send(update);
|
||||
}
|
||||
|
||||
@@ -142,6 +143,7 @@ export class WorkspacesController {
|
||||
|
||||
if (history) {
|
||||
res.setHeader('content-type', 'application/octet-stream');
|
||||
res.setHeader('cache-control', 'public, max-age=2592000, immutable');
|
||||
res.send(history.blob);
|
||||
} else {
|
||||
throw new NotFoundException('Doc history not found');
|
||||
|
||||
@@ -315,6 +315,12 @@ export interface AFFiNEConfig {
|
||||
*/
|
||||
updatePollInterval: number;
|
||||
|
||||
/**
|
||||
* The maximum number of updates that will be pulled from the server at once.
|
||||
* Existing for avoiding the server to be overloaded when there are too many updates for one doc.
|
||||
*/
|
||||
maxUpdatesPullCount: number;
|
||||
|
||||
/**
|
||||
* Use `y-octo` to merge updates at the same time when merging using Yjs.
|
||||
*
|
||||
|
||||
@@ -184,6 +184,7 @@ export const getDefaultAFFiNEConfig: () => AFFiNEConfig = () => {
|
||||
manager: {
|
||||
enableUpdateAutoMerging: flavor !== 'sync',
|
||||
updatePollInterval: 3000,
|
||||
maxUpdatesPullCount: 500,
|
||||
experimentalMergeWithYOcto: false,
|
||||
},
|
||||
history: {
|
||||
|
||||
@@ -23,6 +23,7 @@ import { StripeWebhook } from './webhook';
|
||||
// 'plugins.payment.stripe.keys.webhookKey',
|
||||
// ],
|
||||
contributesTo: ServerFeature.Payment,
|
||||
if: config => config.flavor.graphql,
|
||||
})
|
||||
export class PaymentModule {}
|
||||
|
||||
|
||||
@@ -44,18 +44,18 @@ async function load() {
|
||||
// 3. load env => config map to `globalThis.AFFiNE.ENV_MAP
|
||||
await loadRemote(AFFiNE_CONFIG_PATH, 'affine.env.js');
|
||||
|
||||
// 4. apply `process.env` map overriding to `globalThis.AFFiNE`
|
||||
applyEnvToConfig(globalThis.AFFiNE);
|
||||
|
||||
// 5. load `config/affine` to patch custom configs
|
||||
// 4. load `config/affine` to patch custom configs
|
||||
await loadRemote(AFFiNE_CONFIG_PATH, 'affine.js');
|
||||
|
||||
// 6. load `config/affine.self` to patch custom configs
|
||||
// 5. load `config/affine.self` to patch custom configs
|
||||
// This is the file only take effect in [AFFiNE Cloud]
|
||||
if (!AFFiNE.isSelfhosted) {
|
||||
await loadRemote(AFFiNE_CONFIG_PATH, 'affine.self.js');
|
||||
}
|
||||
|
||||
// 6. apply `process.env` map overriding to `globalThis.AFFiNE`
|
||||
applyEnvToConfig(globalThis.AFFiNE);
|
||||
|
||||
if (AFFiNE.node.dev) {
|
||||
console.log(
|
||||
'AFFiNE Config:',
|
||||
|
||||
Reference in New Issue
Block a user