UNPKG

1.47 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ServerFactory = void 0;
4const transport_enum_1 = require("../enums/transport.enum");
5const server_grpc_1 = require("./server-grpc");
6const server_kafka_1 = require("./server-kafka");
7const server_mqtt_1 = require("./server-mqtt");
8const server_nats_1 = require("./server-nats");
9const server_redis_1 = require("./server-redis");
10const server_tcp_1 = require("./server-tcp");
11const server_rmq_1 = require("./server-rmq");
12class ServerFactory {
13 static create(microserviceOptions) {
14 const { transport, options } = microserviceOptions;
15 switch (transport) {
16 case transport_enum_1.Transport.REDIS:
17 return new server_redis_1.ServerRedis(options);
18 case transport_enum_1.Transport.NATS:
19 return new server_nats_1.ServerNats(options);
20 case transport_enum_1.Transport.MQTT:
21 return new server_mqtt_1.ServerMqtt(options);
22 case transport_enum_1.Transport.GRPC:
23 return new server_grpc_1.ServerGrpc(options);
24 case transport_enum_1.Transport.KAFKA:
25 return new server_kafka_1.ServerKafka(options);
26 case transport_enum_1.Transport.RMQ:
27 return new server_rmq_1.ServerRMQ(options);
28 default:
29 return new server_tcp_1.ServerTCP(options);
30 }
31 }
32}
33exports.ServerFactory = ServerFactory;