Browse Source

Add websocket server to request

dev
David Ludwig 4 years ago
parent
commit
48318bc760
5 changed files with 49 additions and 1 deletions
  1. +3
    -0
      services/request/package.json
  2. +30
    -0
      services/request/src/services/WebSocketServer.ts
  3. +3
    -1
      services/request/src/services/index.ts
  4. +1
    -0
      services/request/tsconfig.json
  5. +12
    -0
      services/request/yarn.lock

+ 3
- 0
services/request/package.json View File

@ -21,6 +21,7 @@
"@autoplex/microservice": "^0.0.0",
"@autoplex/utils": "^0.0.0",
"@autoplex/webserver": "^0.0.0",
"@autoplex/websocket-server": "^0.0.0",
"bcrypt": "^5.0.1",
"discord.js": "^12.5.3",
"fastify": "^3.14.1",
@ -37,12 +38,14 @@
"typeorm": "^0.2.32",
"validate.js": "^0.13.1",
"websocket": "^1.0.33",
"ws": "^7.5.0",
"xml2js": "^0.4.23"
},
"devDependencies": {
"@types/bcrypt": "^3.0.1",
"@types/jsonwebtoken": "^8.5.1",
"@types/node-ipc": "^9.1.3",
"@types/ws": "^7.4.4",
"@types/xml2js": "^0.4.8",
"@zerollup/ts-transform-paths": "^1.7.18",
"tsconfig-paths": "^3.9.0",


+ 30
- 0
services/request/src/services/WebSocketServer.ts View File

@ -0,0 +1,30 @@
import { WebSocketServerService } from "@autoplex/websocket-server";
import Application from "../Application";
export default class WebSocketServer extends WebSocketServerService<Application>
{
/**
* The name of the service
*/
public NAME = "WebSocket Server";
/**
* The application key used for authentication
*/
protected get appKey() {
return Application.instance().APP_KEY;
}
/**
* Install the websocket methods
*/
protected override installMethods() {
this.installMethod("test", this.test.bind(this));
}
protected test() {
return new Promise<string>(resolve => {
resolve("This is the response from the server");
});
}
}

+ 3
- 1
services/request/src/services/index.ts View File

@ -5,9 +5,11 @@ export { DatabaseService } from "@autoplex/database";
import DiscordBot from "./DiscordBot";
import MovieSearch from "./MovieSearch";
import WebServer from "./WebServer/WebServer";
import WebSocketServer from "./WebSocketServer";
export {
// DiscordBot,
MovieSearch,
WebServer
WebServer,
WebSocketServer
}

+ 1
- 0
services/request/tsconfig.json View File

@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2015",
"baseUrl": "./src", /* Base directory to resolve non-absolute module names. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outDir": "./dist", /* Redirect output structure to the directory. */


+ 12
- 0
services/request/yarn.lock View File

@ -78,6 +78,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e"
integrity sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==
"@types/ws@^7.4.4":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.4.tgz#93e1e00824c1de2608c30e6de4303ab3b4c0c9bc"
integrity sha512-d/7W23JAXPodQNbOZNXvl2K+bqAQrCMwlh/nuQsPSQk6Fq0opHoPrUw43aHsvSbIiQPr8Of2hkFbnz1XBFVyZQ==
dependencies:
"@types/node" "*"
"@types/xml2js@^0.4.8":
version "0.4.8"
resolved "https://registry.yarnpkg.com/@types/xml2js/-/xml2js-0.4.8.tgz#84c120c864a5976d0b5cf2f930a75d850fc2b03a"
@ -1721,6 +1728,11 @@ ws@^7.4.1, ws@^7.4.4:
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==
ws@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.0.tgz#0033bafea031fb9df041b2026fc72a571ca44691"
integrity sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==
xml2js@^0.4.23:
version "0.4.23"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66"


Loading…
Cancel
Save