@remult/core
Advanced tools
Comparing version 2.3.17 to 2.4.1
{ | ||
"name": "@remult/core", | ||
"schematics": "./schematics/collection.json", | ||
"version": "2.3.17", | ||
"version": "2.4.1", | ||
"description": "remult core lib", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
import { DataApi, DataApiResponse, DataApiRequest, UserInfo, DataProvider, DataProviderFactoryBuilder, ServerContext, queuedJobInfoResponse, IdEntity, StringColumn, BoolColumn, DateTimeColumn, NumberColumn, SpecificEntityHelper } from '../'; | ||
import * as express from 'express'; | ||
export declare function initExpress(app: express.Express, dataProvider: DataProvider | DataProviderFactoryBuilder, options?: { | ||
export declare function initExpress(app: express.Express, options?: { | ||
dataProvider?: DataProvider | DataProviderFactoryBuilder; | ||
bodySizeLimit?: string; | ||
@@ -5,0 +6,0 @@ disableAutoApi?: boolean; |
@@ -9,3 +9,5 @@ "use strict"; | ||
var __2 = require("../"); | ||
function initExpress(app, dataProvider, options) { | ||
var JsonEntityFileStorage_1 = require("./JsonEntityFileStorage"); | ||
var json_data_provider_1 = require("../src/data-providers/json-data-provider"); | ||
function initExpress(app, options) { | ||
var _this = this; | ||
@@ -24,6 +26,12 @@ if (!options) { | ||
var builder; | ||
if (typeof dataProvider === 'function') | ||
builder = dataProvider; | ||
else | ||
builder = function () { return dataProvider; }; | ||
if (options.dataProvider) { | ||
var dataProvider_1 = options.dataProvider; | ||
if (typeof dataProvider_1 === 'function') | ||
builder = dataProvider_1; | ||
else | ||
builder = function () { return dataProvider_1; }; | ||
} | ||
else { | ||
builder = function () { return new json_data_provider_1.JsonDataProvider(new JsonEntityFileStorage_1.JsonEntityFileStorage('./db')); }; | ||
} | ||
var result = new ExpressBridge(app, new inProcessQueueHandler(options.queueStorage)); | ||
@@ -30,0 +38,0 @@ var apiArea = result.addArea('/' + __1.Context.apiBaseUrl); |
@@ -10,5 +10,12 @@ "use strict"; | ||
JsonEntityFileStorage.prototype.getItem = function (entityDbName) { | ||
return fs.readFileSync(path.join(this.folderPath, entityDbName) + '.json').toString(); | ||
var fn = path.join(this.folderPath, entityDbName) + '.json'; | ||
if (fs.existsSync(fn)) { | ||
return fs.readFileSync(fn).toString(); | ||
} | ||
return undefined; | ||
}; | ||
JsonEntityFileStorage.prototype.setItem = function (entityDbName, json) { | ||
if (!fs.existsSync(this.folderPath)) { | ||
fs.mkdirSync(this.folderPath); | ||
} | ||
return fs.writeFileSync(path.join(this.folderPath, entityDbName) + '.json', json); | ||
@@ -15,0 +22,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1020909
16092