Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rpcapi

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rpcapi - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

src/API.itest.d.ts

11

package.json
{
"name": "rpcapi",
"version": "1.0.6",
"version": "1.1.0",
"description": "Provides a struture for hosting RPC style APIs, supports both http and websocket access out of the box",

@@ -25,13 +25,16 @@ "repository": {

"devDependencies": {
"@types/socket.io-client": "^1.4.32",
"@types/ws": "^3.2.1",
"ava": "^0.24.0",
"express": "^4.16.2",
"node-fetch": "^1.7.3",
"nyc": "^11.3.0",
"socket.io-client": "^2.0.4",
"typescript": "^2.6.2"
},
"dependencies": {
"socket.io": "^2.0.4",
"@types/express": "^4.0.39",
"@types/node-fetch": "^1.6.7",
"@types/socket.io": "^1.4.31"
"@types/socket.io": "^1.4.31",
"express": "^4.16.2",
"socket.io": "^2.0.4"
},

@@ -38,0 +41,0 @@ "author": "Jye Lewis",

import { APIEndpoint } from "./APIEndpoint";
import { IWebAPIAccessMethodConfig } from "./accessMethods/WebAPIAccessMethod/index";
export interface IAPIListenConfig {
webApi?: IWebAPIAccessMethodConfig;
webSocket?: {};
}
export declare class API {

@@ -6,2 +11,3 @@ private endpoints;

getEndpoint(endpointName: string): APIEndpoint;
listen(port: number, options?: IAPIListenConfig): Promise<void>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//For built in server
var express = require("express");
var socketio = require("socket.io");
var http = require("http");
var index_1 = require("./accessMethods/WebAPIAccessMethod/index");
var index_2 = require("./accessMethods/WebSocketAccessMethod/index");
var API = /** @class */ (function () {

@@ -17,2 +23,20 @@ function API() {

};
//Magic function to setup express and socket.io server
//Convenient for any apps that have no need to manage express and socket.io themselves
API.prototype.listen = function (port, options) {
var _this = this;
if (options === void 0) { options = {}; }
return new Promise(function (resolve) {
var app = express();
var server = new http.Server(app);
var io = socketio(server);
//Setup access methods
var webApi = new index_1.WebAPIAccessMethod(_this, options.webApi);
var socketApi = new index_2.WebSocketAccessMethod(_this);
webApi.bind(app);
socketApi.bind(io);
//server listen
server.listen(port, function () { return resolve(); });
});
};
return API;

@@ -19,0 +43,0 @@ }());

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc