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

rest-easy-loki

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-easy-loki - npm Package Compare versions

Comparing version 1.0.0 to 1.2.0

19

dist/api.js

@@ -32,2 +32,3 @@ "use strict";

const koa_static_1 = __importDefault(require("koa-static"));
const koa_compress_1 = __importDefault(require("koa-compress"));
const path = __importStar(require("path"));

@@ -39,15 +40,4 @@ const authorization_1 = require("./authorization");

const upload_service_1 = require("./upload-service");
const state = {
pretty: false,
port: 3000,
cors: false,
};
const createApi = (config) => {
if (config.pretty) {
state.pretty = config.pretty;
}
logging_1.setLoggingOptions(state.pretty);
if (config.port) {
state.port = config.port;
}
logging_1.setLoggingOptions(config.pretty);
const api = new koa_1.default();

@@ -67,2 +57,7 @@ // custom 404

}
if (config.compression) {
console.log('Enabled compression with koa-compress.');
// api.use(cors({ credentials: true }));
api.use(koa_compress_1.default());
}
const ss = config.io ? socket_service_1.createSocketService(api) : undefined;

@@ -69,0 +64,0 @@ api.use(koa_body_1.default({

@@ -33,2 +33,17 @@ "use strict";

{
name: 'compression',
alias: 'z',
type: Boolean,
typeLabel: 'Boolean',
defaultValue: config_1.config.compression,
description: `Enable ZIP compression ($LOKI_COMPRESSION ${config_1.config.compression}).`,
},
{
name: 'config',
defaultValue: config_1.config.config,
type: String,
typeLabel: 'String',
description: `Name of configuration file to configure the DB ($LOKI_CONFIG).`,
},
{
name: 'io',

@@ -88,9 +103,2 @@ alias: 'i',

},
{
name: 'config',
defaultValue: config_1.config.config,
type: String,
typeLabel: 'String',
description: `Name of configuration file to configure the DB ($LOKI_CONFIG).`,
},
];

@@ -97,0 +105,0 @@ CommandLineInterface.sections = [

@@ -14,9 +14,9 @@ "use strict";

/** Pretty print logs */
pretty: process.env.LOKI_PRETTY ? process.env.LOKI_PRETTY : true,
pretty: typeof process.env.LOKI_CORS !== 'undefined' ? process.env.LOKI_PRETTY : true,
/** Define port to use */
port: process.env.LOKI_PORT || 3000,
/** Allow CORS */
cors: process.env.LOKI_CORS ? process.env.LOKI_CORS : true,
cors: typeof process.env.LOKI_CORS !== 'undefined' ? process.env.LOKI_CORS : true,
/** Enable socket.io */
io: process.env.LOKI_IO ? process.env.LOKI_IO : true,
io: typeof process.env.LOKI_IO !== 'undefined' ? process.env.LOKI_IO : true,
/** Name of the database file in the DB folder */

@@ -28,3 +28,5 @@ db: process.env.LOKI_DB || 'rest_easy_loki.db',

config: process.env.LOKI_CONFIG,
/** Use compression */
compression: typeof process.env.LOKI_COMPRESSION !== 'undefined' ? process.env.LOKI_COMPRESSION : true,
};
//# sourceMappingURL=config.js.map

@@ -5,3 +5,3 @@ "use strict";

const state = { prettyLog: false };
const setLoggingOptions = (verbose) => state.prettyLog = verbose;
const setLoggingOptions = (verbose) => (state.prettyLog = verbose);
exports.setLoggingOptions = setLoggingOptions;

@@ -27,3 +27,3 @@ function outputLog(data, thrownError) {

url: ctx.url,
query: ctx.query,
query: ctx.request.querystring,
remoteAddress: ctx.request.ip,

@@ -30,0 +30,0 @@ host: ctx.headers['host'],

@@ -22,2 +22,4 @@ export interface ICommandOptions {

config?: string;
/** If true, use zip compression for the messages */
compression?: boolean;
}
import Router from 'koa-router';
import IO from 'socket.io';
export declare const createRouter: (io?: IO.Server | undefined) => Router<any, {}>;
export declare const createRouter: (io?: IO.Server<import("socket.io/dist/typed-events").DefaultEventsMap, import("socket.io/dist/typed-events").DefaultEventsMap> | undefined) => Router<any, {}>;

@@ -30,3 +30,4 @@ "use strict";

const filter = utils_1.paginationFilter(ctx.query);
const results = database_1.all(collection, ctx.query.q);
const query = ctx.query.q instanceof Array ? ctx.query.q.join('&') : ctx.query.q;
const results = database_1.all(collection, query);
ctx.body = map && results ? (filter ? results.filter(filter).map(map) : results.map(map)) : results;

@@ -51,3 +52,4 @@ });

const pages = utils_1.paginationFilter(ctx.query);
const results = database_1.all(collection, ctx.query.q);
const query = ctx.query.q instanceof Array ? ctx.query.q.join('&') : ctx.query.q;
const results = database_1.all(collection, query);
ctx.body = pages && results ? results.filter(pages) : results;

@@ -54,0 +56,0 @@ });

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

const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const config_1 = require("./config");
const index_1 = require("./index");
const startService = (configuration = config_1.config) => {
const folderPath = path_1.default.dirname(path_1.default.resolve(process.cwd(), configuration.db || ''));
if (!fs_1.default.existsSync(folderPath))
fs_1.default.mkdirSync(folderPath, { recursive: true });
const dbOptions = configuration.config && fs_1.default.existsSync(configuration.config)

@@ -13,0 +17,0 @@ ? JSON.parse(fs_1.default.readFileSync(configuration.config).toString())

@@ -6,4 +6,4 @@ /// <reference types="node" />

export declare const createSocketService: (api: Koa) => {
io: Server;
io: Server<import("socket.io/dist/typed-events").DefaultEventsMap, import("socket.io/dist/typed-events").DefaultEventsMap>;
server: http.Server;
};
{
"name": "rest-easy-loki",
"version": "1.0.0",
"version": "1.2.0",
"description": "A REST interface for lokijs supporting CRUD operations and automatic creation of new collections.",

@@ -27,2 +27,4 @@ "main": "./dist/index.js",

"REST",
"API",
"Koa",
"lokijs",

@@ -38,26 +40,28 @@ "database"

"dependencies": {
"@koa/cors": "^3.1.0",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.1",
"dotenv": "^8.2.0",
"koa": "^2.13.0",
"koa": "^2.13.1",
"koa-body": "^4.2.0",
"koa-compress": "^5.0.1",
"koa-router": "^10.0.0",
"koa-static": "^5.0.0",
"@koa/cors": "^3.1.0",
"lokijs": "^1.5.11",
"rfc6902": "^4.0.1",
"socket.io": "^3.0.3"
"rfc6902": "^4.0.2",
"socket.io": "^4.0.0"
},
"devDependencies": {
"@types/command-line-args": "^5.0.0",
"@types/koa": "^2.11.6",
"@types/koa": "^2.13.1",
"@types/koa-compose": "^3.2.5",
"@types/koa-compress": "^4.0.1",
"@types/koa-router": "^7.4.1",
"@types/koa-static": "^4.0.1",
"@types/lokijs": "^1.5.3",
"@types/node": "^14.14.10",
"@types/node": "^14.14.35",
"rimraf": "^3.0.2",
"tsc-watch": "^4.2.9",
"typescript": "^4.1.2"
"typescript": "^4.2.3"
}
}

@@ -8,4 +8,6 @@ # REST-EASY-LOKI

- Statically sharing the public folder
- Uploading files using the upload folder
- Retrieving environment variables starting with `LOKI_` via REST
- Configuring the database collections using a config file
- Add support for CORS and compression

@@ -12,0 +14,0 @@ This version has moved from the default `LokiFsAdapter` to the more performing `LokiFsStructuredAdapter`. Besides a [performance gain](https://github.com/techfort/LokiJS/wiki/LokiJS-persistence-and-adapters#an-example-using-fastest-and-most-scalable-lokifsstructuredadapter-for-nodejs-might-look-like-), it also means that we don't end up with a single database file anymore, but one overall database file and one per collection.

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