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

radweb-server

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

radweb-server - npm Package Compare versions

Comparing version 1.0.4 to 3.0.1

context/entities-on-server.js

22

expressBridge.d.ts

@@ -1,13 +0,13 @@

import { Entity, DataApi, DataApiResponse, DataApiRequest, DataApiServer, Action } from 'radweb';
import { Entity, DataApi, DataApiResponse, DataApiRequest, DataApiServer, Action, DataProviderFactory } from 'radweb';
import * as express from 'express';
export declare class ExpressBridge<AuthInfoType> implements DataApiServer<AuthInfoType> {
export declare class ExpressBridge implements DataApiServer {
private app;
addAllowedHeader(name: string): void;
addRequestProcessor(processAndReturnTrueToAouthorise: (req: DataApiRequest<AuthInfoType>) => void): void;
preProcessRequestAndReturnTrueToAuthorize: ((req: DataApiRequest<AuthInfoType>) => void)[];
addRequestProcessor(processAndReturnTrueToAouthorise: (req: DataApiRequest) => void): void;
preProcessRequestAndReturnTrueToAuthorize: ((req: DataApiRequest) => void)[];
private allowedHeaders;
constructor(app: express.Express);
addArea(rootUrl: string, processAndReturnTrueToAouthorise?: (req: DataApiRequest<AuthInfoType>) => Promise<boolean>): SiteArea<AuthInfoType>;
constructor(app: express.Express, dataSource: DataProviderFactory, disableHttpForDevOnly?: boolean);
addArea(rootUrl: string, processAndReturnTrueToAouthorise?: (req: DataApiRequest) => Promise<boolean>): SiteArea;
}
export declare class SiteArea<AuthInfoType> {
export declare class SiteArea {
private bridge;

@@ -17,6 +17,6 @@ private app;

private processAndReturnTrueToAouthorise;
constructor(bridge: ExpressBridge<AuthInfoType>, app: express.Express, rootUrl: string, processAndReturnTrueToAouthorise: (req: DataApiRequest<AuthInfoType>) => Promise<boolean>);
add(entityOrDataApiFactory: Entity<any> | ((req: DataApiRequest<AuthInfoType>) => DataApi<any>)): void;
process(what: (myReq: DataApiRequest<AuthInfoType>, myRes: DataApiResponse, origReq: express.Request) => Promise<void>): (req: express.Request, res: express.Response) => Promise<void>;
addAction<T extends Action<any, any, AuthInfoType>>(action: T): void;
constructor(bridge: ExpressBridge, app: express.Express, rootUrl: string, processAndReturnTrueToAouthorise: (req: DataApiRequest) => Promise<boolean>);
add(entityOrDataApiFactory: Entity<any> | ((req: DataApiRequest) => DataApi<any>)): void;
process(what: (myReq: DataApiRequest, myRes: DataApiResponse, origReq: express.Request) => Promise<void>): (req: express.Request, res: express.Response) => Promise<void>;
addAction<T extends Action<any, any>>(action: T): void;
}

@@ -40,17 +40,21 @@ "use strict";

var bodyParser = require("body-parser");
var compression = require("compression");
// @ts-ignore:
var secure = require("express-force-https");
var register_actions_on_server_1 = require("./register-actions-on-server");
var register_entities_on_server_1 = require("./register-entities-on-server");
var ExpressBridge = /** @class */ (function () {
function ExpressBridge(app) {
var _this = this;
function ExpressBridge(app, dataSource, disableHttpForDevOnly) {
this.app = app;
this.preProcessRequestAndReturnTrueToAuthorize = [];
this.allowedHeaders = ["Origin", "X-Requested-With", "Content-Type", "Accept"];
app.use(compression());
if (disableHttpForDevOnly) {
app.use(secure);
}
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Credentials", "true");
res.header("Access-Control-Allow-Origin", req.header('origin'));
res.header("Access-Control-Allow-Headers", _this.allowedHeaders.join(','));
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
next();
});
var apiArea = this.addArea('/' + radweb_1.Context.apiBaseUrl);
register_actions_on_server_1.registerActionsOnServer(apiArea, dataSource);
register_entities_on_server_1.registerEntitiesOnServer(apiArea, dataSource);
}

@@ -76,23 +80,23 @@ ExpressBridge.prototype.addAllowedHeader = function (name) {

} /*
addSqlDevHelpers(server: SQLServerDataProvider) {
let r = this.rootUrl + '/sqlHelper/typescript/:tableName';
console.log(r);
this.app.route(r).get(
async (req, res) => {
let s = await server.getTypeScript(req.params.tableName);
res.type('text/plain');
res.send(s);
});
r = this.rootUrl + '/sqlHelper/tables';
console.log(r);
this.app.route(r).get(
async (req, res) => {
server.listOfTables(new ExpressResponseBridgeToDataApiResponse(res), {
get: key => {
return req.query[key]
}, clientIp: '', authInfo: undefined, getHeader: x => "",
addSqlDevHelpers(server: SQLServerDataProvider) {
let r = this.rootUrl + '/sqlHelper/typescript/:tableName';
console.log(r);
this.app.route(r).get(
async (req, res) => {
let s = await server.getTypeScript(req.params.tableName);
res.type('text/plain');
res.send(s);
});
});
}*/
r = this.rootUrl + '/sqlHelper/tables';
console.log(r);
this.app.route(r).get(
async (req, res) => {
server.listOfTables(new ExpressResponseBridgeToDataApiResponse(res), {
get: key => {
return req.query[key]
}, clientIp: '', authInfo: undefined, getHeader: x => "",
});
});
}*/
SiteArea.prototype.add = function (entityOrDataApiFactory) {

@@ -105,3 +109,3 @@ var _this = this;

api = entityOrDataApiFactory;
var myRoute = api({ clientIp: 'onServer', authInfo: undefined, get: function (r) { return ''; }, getHeader: function (x) { return ""; } }).getRoute();
var myRoute = api({ clientIp: 'onServer', user: undefined, get: function (r) { return ''; }, getHeader: function (x) { return ""; } }).getRoute();
myRoute = this.rootUrl + '/' + myRoute;

@@ -127,9 +131,9 @@ console.log(myRoute);

.get(this.process(function (req, res, orig) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/, api(req).get(res, orig.params.id)];
return [2 /*return*/, api(req).get(res, orig.query.id)];
}); }); }))
.put(this.process(function (req, res, orig) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/, api(req).put(res, orig.params.id, orig.body)];
return [2 /*return*/, api(req).put(res, orig.query.id, orig.body)];
}); }); }))
.delete(this.process(function (req, res, orig) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/, api(req).delete(res, orig.params.id)];
return [2 /*return*/, api(req).delete(res, orig.query.id)];
}); }); }));

@@ -192,3 +196,3 @@ };

this.r = r;
this.authInfo = undefined;
this.user = undefined;
this.clientIp = r.ip;

@@ -195,0 +199,0 @@ }

export * from './JsonFileDataProvider';
export * from './expressBridge';
export * from './SQLDatabaseShared';
export * from './register-entities-on-server';
export * from './jwt-cookie-authoerization-helper';
export * from './register-actions-on-server';

@@ -9,2 +9,5 @@ "use strict";

__export(require("./SQLDatabaseShared"));
__export(require("./register-entities-on-server"));
__export(require("./jwt-cookie-authoerization-helper"));
__export(require("./register-actions-on-server"));
//# sourceMappingURL=index.js.map
{
"name": "radweb-server",
"version": "1.0.4",
"version": "3.0.1",
"main":"index.js",
"Dependencies": {
"express": "^4.16.4",
"body-parser": "^1.18.3",
"compression": "^1.7.3",
"express-force-https": "^1.0.0",
"jsonwebtoken": "^8.5.1"
}
}

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