Initial standalone server implementation (#15)

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov
2021-08-08 23:04:39 +02:00
committed by GitHub
parent 67940e0d35
commit a8693be822
41 changed files with 349 additions and 174 deletions
+5
View File
@@ -16,5 +16,10 @@
import { start } from '.'
import { encode } from 'jwt-simple'
const token = encode({ email: 'rosamund@hc.engineering', workspace: 'ws1' }, 'secret')
console.log(token)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
start(3333)
+5
View File
@@ -18,10 +18,15 @@ import { start as startJsonRpc } from '@anticrm/server-ws'
import { createStorage } from '@anticrm/dev-storage'
import { DevSession } from './session'
import { addLocation } from '@anticrm/platform'
import { serverChunterId } from '@anticrm/server-chunter'
/**
* @public
*/
export async function start (port: number, host?: string): Promise<void> {
addLocation(serverChunterId, () => import('@anticrm/dev-server-chunter-resources'))
const storage = await createStorage()
startJsonRpc(server => new DevSession(server, storage), port, host)
}
+1
View File
@@ -30,6 +30,7 @@ export class DevSession implements Storage {
async tx (tx: Tx): Promise<void> {
const derived = await this.storage.tx(tx)
this.server.broadcast(this, { result: tx })
for (const tx of derived) {
this.server.broadcast(this, { result: tx })
}