MCPcopy
hub / github.com/soketi/soketi / newServer

Method newServer

tests/utils.ts:39–84  ·  view source on GitHub ↗
(options = {}, callback)

Source from the content-addressed store, hash-verified

37 }
38
39 static newServer(options = {}, callback): any {
40 options = {
41 'cluster.prefix': uuidv4(),
42 'adapter.redis.prefix': uuidv4(),
43 'adapter.nats.prefix': uuidv4(),
44 'appManager.array.apps.0.maxBackendEventsPerSecond': 200,
45 'appManager.array.apps.0.maxClientEventsPerSecond': 200,
46 'appManager.array.apps.0.maxReadRequestsPerSecond': 200,
47 'metrics.enabled': true,
48 'appManager.mysql.useMysql2': true,
49 'cluster.port': parseInt((Math.random() * (20000 - 10000) + 10000).toString()), // random: 10000-20000
50 'appManager.dynamodb.endpoint': 'http://127.0.0.1:8000',
51 'cluster.ignoreProcess': false,
52 'webhooks.batching.enabled': false, // TODO: Find out why batching works but fails tests
53 'webhooks.batching.duration': 1,
54 'appManager.cache.enabled': true,
55 'appManager.cache.ttl': -1,
56 ...options,
57 'adapter.driver': process.env.TEST_ADAPTER || 'local',
58 'cache.driver': process.env.TEST_CACHE_DRIVER || 'memory',
59 'appManager.driver': process.env.TEST_APP_MANAGER || 'array',
60 'queue.driver': process.env.TEST_QUEUE_DRIVER || 'sync',
61 'rateLimiter.driver': process.env.TEST_RATE_LIMITER || 'local',
62 'database.mysql.user': process.env.TEST_MYSQL_USER || 'testing',
63 'database.mysql.password': process.env.TEST_MYSQL_PASSWORD || 'testing',
64 'database.mysql.database': process.env.TEST_MYSQL_DATABASE || 'testing',
65 'database.postgres.user': process.env.TEST_POSTGRES_USER || 'testing',
66 'database.postgres.password': process.env.TEST_POSTGRES_PASSWORD || 'testing',
67 'database.postgres.database': process.env.TEST_POSTGRES_DATABASE || 'testing',
68 'queue.sqs.queueUrl': process.env.TEST_SQS_URL || 'http://localhost:4566/000000000000/test.fifo',
69 'debug': process.env.TEST_DEBUG || false,
70 'shutdownGracePeriod': 1_000,
71 };
72
73 return (new Server(options)).start((server: Server) => {
74 this.wsServers.push(server);
75
76 if (server.options.cache.driver === 'redis') {
77 server.cacheManager.driver.redisConnection.flushdb().then(() => {
78 callback(server);
79 });
80 } else {
81 callback(server);
82 }
83 });
84 }
85
86 static newClonedServer(server: Server, options = {}, callback): any {
87 return this.newServer({

Calls 1

startMethod · 0.45

Tested by

no test coverage detected