Comparing version 1.0.6 to 1.1.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
335693
79
2783
5
7
2
+ Addedexpress@^4.16.2
+ Addedarray-flatten@1.1.1(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.7.1(transitive)
+ Addedcookie-signature@1.0.6(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.22.0.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@4.21.1(transitive)
+ Addedfinalhandler@1.3.1(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmerge-descriptors@1.0.3(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@0.1.10(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsend@0.19.0(transitive)
+ Addedserve-static@1.16.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvary@1.1.2(transitive)