diff --git a/dev/client-resources/src/connection.ts b/dev/client-resources/src/connection.ts index 0d5812d1b0..bc77f23339 100644 --- a/dev/client-resources/src/connection.ts +++ b/dev/client-resources/src/connection.ts @@ -18,16 +18,19 @@ import { DOMAIN_TX } from '@anticrm/core' import { createInMemoryAdapter, createInMemoryTxAdapter } from '@anticrm/dev-storage' import { createServerStorage, FullTextAdapter, IndexedDoc } from '@anticrm/server-core' import type { DbConfiguration } from '@anticrm/server-core' +import { protoSerialize, protoDeserialize } from '@anticrm/platform' class ServerStorageWrapper implements Storage { constructor (private readonly storage: ServerStorage, private readonly handler: TxHander) {} findAll (_class: Ref>, query: DocumentQuery, options?: FindOptions): Promise> { - return this.storage.findAll(_class, query, options) + const [c, q, o] = protoDeserialize(protoSerialize([_class, query, options])) + return this.storage.findAll(c, q, o) } async tx (tx: Tx): Promise { - const derived = await this.storage.tx(tx) + const _tx = protoDeserialize(protoSerialize(tx)) + const derived = await this.storage.tx(_tx) for (const tx of derived) { this.handler(tx) } } } diff --git a/packages/platform/src/rpc.ts b/packages/platform/src/rpc.ts index 45d1266cfb..18264ae623 100644 --- a/packages/platform/src/rpc.ts +++ b/packages/platform/src/rpc.ts @@ -42,13 +42,31 @@ export interface Response { error?: Status } +/** + * @public + * @param object - + * @returns + */ +export function protoSerialize (object: object): string { + return JSON.stringify(object, (key, value) => { return value ?? null }) +} + +/** + * @public + * @param data - + * @returns + */ +export function protoDeserialize (data: string): any { + return JSON.parse(data) +} + /** * @public * @param object - * @returns */ export function serialize (object: Request | Response): string { - return JSON.stringify(object) + return protoSerialize(object) } /** @@ -57,7 +75,7 @@ export function serialize (object: Request | Response): string { * @returns */ export function readResponse (response: string): Response { - return JSON.parse(response) + return protoDeserialize(response) } /** @@ -66,7 +84,7 @@ export function readResponse (response: string): Response { * @returns */ export function readRequest

(request: string): Request

{ - const result: Request

= JSON.parse(request) + const result: Request

= protoDeserialize(request) if (typeof result.method !== 'string') { throw new PlatformError( new Status(Severity.ERROR, platform.status.BadRequest, {}) diff --git a/server/front/src/index.ts b/server/front/src/index.ts index 8d7a5f6b3a..ac38ca932c 100644 --- a/server/front/src/index.ts +++ b/server/front/src/index.ts @@ -24,7 +24,7 @@ const dist = resolve(__dirname, 'dist') console.log('serving static files from', dist) -app.use(express.static(dist, { maxAge: '10m' })) +app.use(express.static(dist, { /* maxAge: '10m' */ })) app.get('*', function (request, response) { response.sendFile(join(dist, 'index.html'))