@hyperultima/nest-tcp-server
v0.2.0
Published
NestJS Simple TCP Server
Downloads
1
Readme
Nest TCP Server
A simple TCP server for NestJS. This package is a wrapper around NodeJS net module.
Installation
$ npm i --save @hyperultima/nest-tcp-server
Usage
/*
* AppModule
*/
import { Module } from '@nestjs/common';
import { TCPServerModule } from 'lib';
@Module({
imports: [
TCPServerModule.register({
port: 3001,
host: "127.0.0.1",
timeout: 1000,
keepAlive: {
enable: true,
initialDelay: 2000
},
}),
],
})
export class AppModule {}
/*
* Service
*/
import { Injectable } from '@nestjs/common';
import { TCPServerService } from '@hyperultima/nest-tcp-server';
@Injectable()
export class AppService {
constructor(private tcp: TCPServerService) {}
}
Configuration
{
port: 3001, // server port
host: "127.0.0.1", // server host
timeout: 1000, // socket timeout (in ms)
keepAlive: {
enable: true, // enable keep-alive
initialDelay: 2000 // keep-alive initial delay (in ms)
},
}