From 43e6988a242ad0b4b4bb13a553eaf96243df3fde Mon Sep 17 00:00:00 2001 From: Karl-Aksel Puulmann Date: Fri, 19 Mar 2021 12:10:31 +0200 Subject: [PATCH] Move createServer under src/shared --- benchmarks/postgres/ingestion.benchmark.ts | 2 +- benchmarks/vm/memory.benchmark.ts | 2 +- src/main/pluginsServer.ts | 2 +- src/{ => shared}/server.ts | 16 ++++++++-------- src/worker/worker.ts | 2 +- tests/plugins.test.ts | 2 +- tests/postgres/queue.test.ts | 2 +- tests/postgres/vm.test.ts | 2 +- tests/postgres/vm.timeout.test.ts | 2 +- tests/schedule.test.ts | 2 +- tests/shared/process-event.ts | 2 +- tests/sql.test.ts | 2 +- tests/transforms.test.ts | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) rename src/{ => shared}/server.ts (94%) diff --git a/benchmarks/postgres/ingestion.benchmark.ts b/benchmarks/postgres/ingestion.benchmark.ts index 96a6bcebb..1fcf4330b 100644 --- a/benchmarks/postgres/ingestion.benchmark.ts +++ b/benchmarks/postgres/ingestion.benchmark.ts @@ -4,8 +4,8 @@ import os from 'os' import { performance } from 'perf_hooks' import { IEvent } from '../../src/idl/protos' -import { createServer } from '../../src/server' import { EventsProcessor } from '../../src/shared/ingestion/process-event' +import { createServer } from '../../src/shared/server' import { UUIDT } from '../../src/shared/utils' import { LogLevel, PluginsServer, SessionRecordingEvent, Team } from '../../src/types' import { getFirstTeam, resetTestDatabase } from '../../tests/helpers/sql' diff --git a/benchmarks/vm/memory.benchmark.ts b/benchmarks/vm/memory.benchmark.ts index 660349864..f2d1a4220 100644 --- a/benchmarks/vm/memory.benchmark.ts +++ b/benchmarks/vm/memory.benchmark.ts @@ -1,6 +1,6 @@ import { PluginEvent } from '@posthog/plugin-scaffold/src/types' -import { createServer } from '../../src/server' +import { createServer } from '../../src/shared/server' import { Plugin, PluginConfig, PluginConfigVMReponse } from '../../src/types' import { createPluginConfigVM } from '../../src/worker/vm/vm' import { commonOrganizationId } from '../../tests/helpers/plugins' diff --git a/src/main/pluginsServer.ts b/src/main/pluginsServer.ts index 94bbfb23f..a1e8b8518 100644 --- a/src/main/pluginsServer.ts +++ b/src/main/pluginsServer.ts @@ -4,8 +4,8 @@ import { FastifyInstance } from 'fastify' import Redis from 'ioredis' import * as schedule from 'node-schedule' -import { createServer } from '../server' import { defaultConfig } from '../shared/config' +import { createServer } from '../shared/server' import { status } from '../shared/status' import { createRedis, delay } from '../shared/utils' import { PluginsServer, PluginsServerConfig, Queue, ScheduleControl } from '../types' diff --git a/src/server.ts b/src/shared/server.ts similarity index 94% rename from src/server.ts rename to src/shared/server.ts index ebd633550..5409de555 100644 --- a/src/server.ts +++ b/src/shared/server.ts @@ -9,14 +9,14 @@ import * as path from 'path' import { types as pgTypes } from 'pg' import { ConnectionOptions } from 'tls' -import { defaultConfig } from './shared/config' -import { DB } from './shared/db' -import { status } from './shared/status' -import { createPostgresPool, createRedis, UUIDT } from './shared/utils' -import { PluginsServer, PluginsServerConfig } from './types' -import { EventsProcessor } from './worker/ingestion/process-event' - -const { version } = require('../package.json') +import { PluginsServer, PluginsServerConfig } from '../types' +import { EventsProcessor } from '../worker/ingestion/process-event' +import { defaultConfig } from './config' +import { DB } from './db' +import { status } from './status' +import { createPostgresPool, createRedis, UUIDT } from './utils' + +const { version } = require('../../package.json') export async function createServer( config: Partial = {}, diff --git a/src/worker/worker.ts b/src/worker/worker.ts index 1e0101e0f..38944d7b2 100644 --- a/src/worker/worker.ts +++ b/src/worker/worker.ts @@ -1,5 +1,5 @@ import { initApp } from '../init' -import { createServer } from '../server' +import { createServer } from '../shared/server' import { status } from '../shared/status' import { cloneObject } from '../shared/utils' import { PluginsServer, PluginsServerConfig } from '../types' diff --git a/tests/plugins.test.ts b/tests/plugins.test.ts index 187fcdce0..11a4fb17b 100644 --- a/tests/plugins.test.ts +++ b/tests/plugins.test.ts @@ -1,8 +1,8 @@ import { PluginEvent } from '@posthog/plugin-scaffold/src/types' import { mocked } from 'ts-jest/utils' -import { createServer } from '../src/server' import { clearError, processError } from '../src/shared/error' +import { createServer } from '../src/shared/server' import { LogLevel, PluginsServer } from '../src/types' import { loadPlugin } from '../src/worker/plugins/loadPlugin' import { runPlugins } from '../src/worker/plugins/run' diff --git a/tests/postgres/queue.test.ts b/tests/postgres/queue.test.ts index f804d5c75..a28b43c35 100644 --- a/tests/postgres/queue.test.ts +++ b/tests/postgres/queue.test.ts @@ -1,6 +1,6 @@ import { startQueue } from '../../src/main/queue' -import { createServer } from '../../src/server' import Client from '../../src/shared/celery/client' +import { createServer } from '../../src/shared/server' import { delay } from '../../src/shared/utils' import { LogLevel, PluginsServer } from '../../src/types' import { runPlugins } from '../../src/worker/plugins/run' diff --git a/tests/postgres/vm.test.ts b/tests/postgres/vm.test.ts index d6862e37c..d5ca1e70a 100644 --- a/tests/postgres/vm.test.ts +++ b/tests/postgres/vm.test.ts @@ -1,8 +1,8 @@ import { PluginEvent } from '@posthog/plugin-scaffold' import * as fetch from 'node-fetch' -import { createServer } from '../../src/server' import Client from '../../src/shared/celery/client' +import { createServer } from '../../src/shared/server' import { delay } from '../../src/shared/utils' import { PluginsServer } from '../../src/types' import { createPluginConfigVM } from '../../src/worker/vm/vm' diff --git a/tests/postgres/vm.timeout.test.ts b/tests/postgres/vm.timeout.test.ts index f3d8cd61d..1530333cb 100644 --- a/tests/postgres/vm.timeout.test.ts +++ b/tests/postgres/vm.timeout.test.ts @@ -1,4 +1,4 @@ -import { createServer } from '../../src/server' +import { createServer } from '../../src/shared/server' import { PluginsServer } from '../../src/types' import { createPluginConfigVM } from '../../src/worker/vm/vm' import { pluginConfig39 } from '../helpers/plugins' diff --git a/tests/schedule.test.ts b/tests/schedule.test.ts index 287edd3b0..e6fabb72d 100644 --- a/tests/schedule.test.ts +++ b/tests/schedule.test.ts @@ -7,7 +7,7 @@ import { startSchedule, waitForTasksToFinish, } from '../src/main/services/schedule' -import { createServer } from '../src/server' +import { createServer } from '../src/shared/server' import { delay } from '../src/shared/utils' import { LogLevel, ScheduleControl } from '../src/types' import { createPromise } from './helpers/promises' diff --git a/tests/shared/process-event.ts b/tests/shared/process-event.ts index 7d1aa69b8..0dcd12d1d 100644 --- a/tests/shared/process-event.ts +++ b/tests/shared/process-event.ts @@ -4,8 +4,8 @@ import { DateTime } from 'luxon' import { performance } from 'perf_hooks' import { IEvent } from '../../src/idl/protos' -import { createServer } from '../../src/server' import { hashElements } from '../../src/shared/ingestion/utils' +import { createServer } from '../../src/shared/server' import { delay, UUIDT } from '../../src/shared/utils' import { Database, diff --git a/tests/sql.test.ts b/tests/sql.test.ts index a0a82d4ad..571fbc2fb 100644 --- a/tests/sql.test.ts +++ b/tests/sql.test.ts @@ -1,4 +1,4 @@ -import { createServer } from '../src/server' +import { createServer } from '../src/shared/server' import { getPluginAttachmentRows, getPluginConfigRows, getPluginRows, setError } from '../src/shared/sql' import { PluginConfig, PluginError, PluginsServer } from '../src/types' import { commonOrganizationId } from './helpers/plugins' diff --git a/tests/transforms.test.ts b/tests/transforms.test.ts index 763a4d1a0..726fe7fbe 100644 --- a/tests/transforms.test.ts +++ b/tests/transforms.test.ts @@ -1,4 +1,4 @@ -import { createServer } from '../src/server' +import { createServer } from '../src/shared/server' import { code } from '../src/shared/utils' import { PluginsServer } from '../src/types' import { transformCode } from '../src/worker/vm/transforms'