Socket
Socket
Sign inDemoInstall

server

Package Overview
Dependencies
191
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.37 to 1.0.38

.prettierignore

8

coverage/lcov-report/block-navigation.js

@@ -66,2 +66,10 @@ /* eslint-disable */

return function jump(event) {
if (
document.getElementById('fileSearch') === document.activeElement &&
document.activeElement != null
) {
// if we're currently focused on the search input, we don't want to navigate
return;
}
switch (event.which) {

@@ -68,0 +76,0 @@ case 78: // n

@@ -27,2 +27,27 @@ /* eslint-disable */

function onFilterInput() {
const searchValue = document.getElementById('fileSearch').value;
const rows = document.getElementsByTagName('tbody')[0].children;
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
if (
row.textContent
.toLowerCase()
.includes(searchValue.toLowerCase())
) {
row.style.display = '';
} else {
row.style.display = 'none';
}
}
}
// loads the search box
function addSearchBox() {
var template = document.getElementById('filterTemplate');
var templateClone = template.content.cloneNode(true);
templateClone.getElementById('fileSearch').oninput = onFilterInput;
template.parentElement.appendChild(templateClone);
}
// loads all columns

@@ -166,2 +191,3 @@ function loadColumns() {

loadData();
addSearchBox();
addSortIndicators();

@@ -168,0 +194,0 @@ enableUI();

73

package.json
{
"name": "server",
"version": "1.0.37",
"version": "1.0.38",
"description": "A modern and powerful server for Node.js",

@@ -8,5 +8,3 @@ "homepage": "https://serverjs.io/",

"bugs": "https://github.com/franciscop/server/issues",
"funding": {
"url": "https://www.paypal.me/franciscopresencia/19"
},
"funding": "https://www.paypal.me/franciscopresencia/19",
"author": "Francisco Presencia <public@francisco.io> (https://francisco.io/)",

@@ -43,41 +41,43 @@ "license": "MIT",

"dependencies": {
"body-parser": "^1.15.2",
"compression": "^1.6.2",
"connect-redis": "^3.3.0",
"cookie-parser": "^1.4.3",
"csurf": "^1.9.0",
"dotenv": "^8.2.0",
"express": "^4.14.0",
"express-data-parser": "^1.2.0",
"express-session": "^1.14.2",
"extend": "^3.0.0",
"hbs": "^4.1.0",
"helmet": "^3.9.0",
"body-parser": "^1.20.1",
"compression": "^1.7.4",
"connect-redis": "^6.1.3",
"cookie-parser": "^1.4.6",
"csurf": "^1.11.0",
"dotenv": "^16.0.3",
"express": "^4.18.1",
"express-session": "^1.17.3",
"extend": "^3.0.2",
"hbs": "^4.2.0",
"helmet": "^6.0.0",
"ioredis": "^5.2.3",
"loadware": "^2.0.0",
"log": "^1.4.0",
"method-override": "^3.0.0",
"mz": "^2.6.0",
"path-to-regexp": "^6.1.0",
"pug": "^3.0.0",
"mz": "^2.7.0",
"npmlog": "^6.0.2",
"path-to-regexp": "^6.2.1",
"pug": "^3.0.2",
"response-time": "^2.3.2",
"serve-favicon": "^2.3.2",
"serve-index": "^1.8.0",
"socket.io": "^2.0.3"
"serve-favicon": "^2.5.0",
"serve-index": "^1.9.1",
"socket.io": "^4.5.2",
"upload-files-express": "^0.4.0"
},
"devDependencies": {
"eslint": "^4.7.2",
"eslint-plugin-jasmine": "^2.2.0",
"grunt": "^1.0.1",
"eslint": "^8.25.0",
"eslint-plugin-jasmine": "^4.1.3",
"grunt": "^1.5.3",
"grunt-bytesize": "^0.2.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-jshint": "^1.1.0",
"grunt-contrib-connect": "^3.0.0",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-pug": "^3.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-sass": "^3.1.0",
"jest": "^25.0.0",
"jstransformer-marked": "^1.0.2",
"picnic": "^6.4.0",
"request-promises": "^1.0.1",
"sass": "^1.37.5",
"supertest": "^3.4.2"
"jest": "^29.1.2",
"jest-jasmine2": "^29.1.2",
"jstransformer-marked": "^1.2.0",
"picnic": "^7.1.0",
"request-promises": "^1.1.0",
"sass": "^1.55.0",
"supertest": "^6.3.0"
},

@@ -87,4 +87,5 @@ "jest": {

"/node_modules/"
]
],
"testRunner": "jest-jasmine2"
}
}

@@ -5,7 +5,13 @@ const run = require('server/test/run');

const storeLog = out => ({ report: { write: log => { out.log = log; } } });
const storeLog = out => ({
report: log => {
out.log = log.toString();
}
});
describe('final', () => {
it('gets called with an unhandled error', async () => {
const simple = () => { throw new Error('Hello Error'); };
const simple = () => {
throw new Error('Hello Error');
};
const out = {};

@@ -20,5 +26,11 @@ const res = await run({ raw: true, log: storeLog(out) }, simple).get('/');

let called = false;
const simple = () => { called = true; };
const simple = () => {
called = true;
};
const out = {};
const res = await run({ raw: true, log: storeLog(out) }, () => 'Hello world', simple).get('/');
const res = await run(
{ raw: true, log: storeLog(out) },
() => 'Hello world',
simple
).get('/');
expect(res.statusCode).toBe(200);

@@ -25,0 +37,0 @@ expect(res.body).toBe('Hello world');

@@ -1,12 +0,12 @@

const Log = require('log');
const log = require('npmlog');
const valid = [
'emergency',
'debug',
'info',
'notice',
'warning',
'error',
'critical',
'alert',
'critical',
'error',
'warning',
'notice',
'info',
'debug'
'emergency'
];

@@ -29,3 +29,21 @@

init: ctx => {
ctx.log = new Log(ctx.options.log.level, ctx.options.log.report);
valid.forEach((level, n) => {
log.addLevel(level, n);
});
log.level = 'info';
if (ctx.options.log.level) {
log.level = ctx.options.log.level;
}
ctx.log = {};
valid.forEach(type => {
ctx.log[type] = content => {
if (
ctx.options.log.report &&
typeof ctx.options.log.report === 'function'
) {
ctx.options.log.report(content, type);
}
log.log(type, '', content);
};
});
}

@@ -32,0 +50,0 @@ };

@@ -40,9 +40,20 @@ const server = require('../../server');

// Now errors must be fully qualified with Jest
expect(res).rejects.toMatchObject(new ConfigError('enum', {
name: 'level',
value: 'abc',
possible: ['emergency','alert','critical','error','warning','notice','info','debug'],
status: 500
}));
expect(res).rejects.toMatchObject(
new ConfigError('enum', {
name: 'level',
value: 'abc',
possible: [
'debug',
'info',
'notice',
'warning',
'error',
'critical',
'alert',
'emergency'
],
status: 500
})
);
});
});

@@ -76,3 +76,3 @@ // Parser plugin

if (!ctx.options.parser.data) return;
const data = require('express-data-parser')(ctx.options.parser.data);
const data = require('upload-files-express')(ctx.options.parser.data);
return modern(data)(ctx);

@@ -79,0 +79,0 @@ },

@@ -7,2 +7,3 @@ const modern = require('../../src/modern');

let sessionMiddleware;
const Redis = require('ioredis');

@@ -38,5 +39,4 @@ module.exports = {

if (!ctx.options.session.store && ctx.options.session.redis) {
ctx.options.session.store = new RedisStore({
url: ctx.options.session.redis
});
const redisClient = new Redis(ctx.options.session.redis);
ctx.options.session.store = new RedisStore({ client: redisClient });
}

@@ -49,3 +49,3 @@ sessionMiddleware = session(ctx.options.session);

if (!ctx.io || !ctx.io.use) return;
ctx.io.use(function(socket, next) {
ctx.io.use(function (socket, next) {
sessionMiddleware(socket.request, socket.request.res || {}, next);

@@ -52,0 +52,0 @@ });

const run = require('server/test/run');
const stat = require('./');
const storeLog = out => ({ report: { write: log => { out.log = log; } } });
const storeLog = out => ({
report: log => {
out.log = log.toString();
}
});

@@ -6,0 +10,0 @@ describe('static plugin', () => {

@@ -144,4 +144,2 @@ # **server.js** for Node.js

I love using my work and I'm available for contractor work. Freelancing helps maintain `server` and [my other open source projects](https://github.com/franciscop/) up to date! I am also on [Codementor](https://www.codementor.io/franciscop) so if you want to learn more Javascript/Node.js/etc contact me there.
You can also [sponsor the project](https://serverjs.io/sponsor), get your logo in here and some other perks with tons of ♥

@@ -1,51 +0,48 @@

const reply = require('.');
const reply = require(".");
describe('reply', () => {
it('loads the main reply', () => {
expect(reply).toEqual(require('server').reply);
expect(reply).toEqual(require('server/reply'));
describe("reply", () => {
it("loads the main reply", () => {
expect(JSON.stringify(reply)).toEqual(
JSON.stringify(require("server").reply)
);
expect(JSON.stringify(reply)).toEqual(
JSON.stringify(require("server/reply"))
);
});
it('has the right methods defined', () => {
expect(reply.cookie ).toEqual(jasmine.any(Function));
it("has the right methods defined", () => {
expect(reply.cookie).toEqual(jasmine.any(Function));
expect(reply.download).toEqual(jasmine.any(Function));
expect(reply.end ).toEqual(jasmine.any(Function));
expect(reply.file ).toEqual(jasmine.any(Function));
expect(reply.header ).toEqual(jasmine.any(Function));
expect(reply.json ).toEqual(jasmine.any(Function));
expect(reply.jsonp ).toEqual(jasmine.any(Function));
expect(reply.end).toEqual(jasmine.any(Function));
expect(reply.file).toEqual(jasmine.any(Function));
expect(reply.header).toEqual(jasmine.any(Function));
expect(reply.json).toEqual(jasmine.any(Function));
expect(reply.jsonp).toEqual(jasmine.any(Function));
expect(reply.redirect).toEqual(jasmine.any(Function));
expect(reply.render ).toEqual(jasmine.any(Function));
expect(reply.send ).toEqual(jasmine.any(Function));
expect(reply.status ).toEqual(jasmine.any(Function));
expect(reply.type ).toEqual(jasmine.any(Function));
expect(reply.render).toEqual(jasmine.any(Function));
expect(reply.send).toEqual(jasmine.any(Function));
expect(reply.status).toEqual(jasmine.any(Function));
expect(reply.type).toEqual(jasmine.any(Function));
});
it('can load all the methods manually', () => {
expect(require('server/reply/cookie' )).toEqual(reply.cookie);
expect(require('server/reply/download')).toEqual(reply.download);
expect(require('server/reply/end' )).toEqual(reply.end);
expect(require('server/reply/file' )).toEqual(reply.file);
expect(require('server/reply/header' )).toEqual(reply.header);
expect(require('server/reply/json' )).toEqual(reply.json);
expect(require('server/reply/jsonp' )).toEqual(reply.jsonp);
expect(require('server/reply/redirect')).toEqual(reply.redirect);
expect(require('server/reply/render' )).toEqual(reply.render);
expect(require('server/reply/send' )).toEqual(reply.send);
expect(require('server/reply/status' )).toEqual(reply.status);
expect(require('server/reply/type' )).toEqual(reply.type);
it("can load all the methods manually", () => {
expect(typeof require("server/reply/cookie")).toBe("function");
expect(typeof require("server/reply/download")).toBe("function");
expect(typeof require("server/reply/end")).toBe("function");
expect(typeof require("server/reply/file")).toBe("function");
expect(typeof require("server/reply/header")).toBe("function");
expect(typeof require("server/reply/json")).toBe("function");
expect(typeof require("server/reply/jsonp")).toBe("function");
expect(typeof require("server/reply/redirect")).toBe("function");
expect(typeof require("server/reply/render")).toBe("function");
expect(typeof require("server/reply/send")).toBe("function");
expect(typeof require("server/reply/status")).toBe("function");
expect(typeof require("server/reply/type")).toBe("function");
});
describe('reply: instances instead of global', () => {
it('adds a method to the stack', () => {
const mock = reply.file('./index.js');
describe("reply: instances instead of global", () => {
it("adds a method to the stack", () => {
const mock = reply.file("./index.js");
expect(mock.stack.length).toEqual(1);
const inst = reply.file('./index.js');
const inst = reply.file("./index.js");
expect(inst.stack.length).toEqual(1);

@@ -57,6 +54,6 @@

it('adds several methods correctly', () => {
const mock = reply.file('./index.js');
it("adds several methods correctly", () => {
const mock = reply.file("./index.js");
expect(mock.stack.length).toEqual(1);
const inst = reply.file('./index.js').file('./whatever.js');
const inst = reply.file("./index.js").file("./whatever.js");
expect(inst.stack.length).toEqual(2);

@@ -63,0 +60,0 @@

// Unit - test the router on its own
const loadware = require('loadware');
const join = require('server/src/join');
const { get, error } = require('server/router');
const RouterError = require('./errors');
const loadware = require("loadware");
const join = require("server/src/join");
const { get, error } = require("server/router");
const RouterError = require("./errors");
const run = require('server/test/run');
const run = require("server/test/run");
const createCtx = ({ url = '/', path = '/', method = 'GET' } = {}) => ({
const createCtx = ({ url = "/", path = "/", method = "GET" } = {}) => ({
req: { url, path, method },
res: { send: () => {}, end: () => {} },
options: {}
options: {},
});
const router = require('.');
const router = require(".");
describe('server/router definition', () => {
it('loads the main router', () => {
expect(router).toEqual(require('server').router);
expect(router).toBe(require('server/router'));
describe("server/router definition", () => {
it("loads the main router", () => {
expect(JSON.stringify(router)).toEqual(
JSON.stringify(require("server").router)
);
expect(JSON.stringify(router)).toBe(
JSON.stringify(require("server/router"))
);
});
it('has the right methods defined', () => {
it("has the right methods defined", () => {
expect(router.get).toEqual(jasmine.any(Function));

@@ -33,27 +37,27 @@ expect(router.head).toEqual(jasmine.any(Function));

it('can load all the methods manually', () => {
expect(require('server/router/get')).toEqual(jasmine.any(Function));
expect(require('server/router/head')).toEqual(jasmine.any(Function));
expect(require('server/router/post')).toEqual(jasmine.any(Function));
expect(require('server/router/put')).toEqual(jasmine.any(Function));
expect(require('server/router/del')).toEqual(jasmine.any(Function));
expect(require('server/router/sub')).toEqual(jasmine.any(Function));
expect(require('server/router/error')).toEqual(jasmine.any(Function));
it("can load all the methods manually", () => {
expect(require("server/router/get")).toEqual(jasmine.any(Function));
expect(require("server/router/head")).toEqual(jasmine.any(Function));
expect(require("server/router/post")).toEqual(jasmine.any(Function));
expect(require("server/router/put")).toEqual(jasmine.any(Function));
expect(require("server/router/del")).toEqual(jasmine.any(Function));
expect(require("server/router/sub")).toEqual(jasmine.any(Function));
expect(require("server/router/error")).toEqual(jasmine.any(Function));
});
});
describe('server/router works', () => {
it('works', async () => {
describe("server/router works", () => {
it("works", async () => {
const mid = [
() => new Promise(resolve => resolve()),
get('/aaa', () => {
() => new Promise((resolve) => resolve()),
get("/aaa", () => {
throw new Error();
}),
get('/', () => 'Hello 世界'),
get('/sth', () => {
get("/", () => "Hello 世界"),
get("/sth", () => {
throw new Error();
}),
get('/', () => {
get("/", () => {
throw new Error();
})
}),
];

@@ -66,15 +70,15 @@

it('works even when wrapped with join() and loadware()', async () => {
it("works even when wrapped with join() and loadware()", async () => {
const middles = [
() => new Promise(resolve => resolve()),
get('/aaa', () => {
() => new Promise((resolve) => resolve()),
get("/aaa", () => {
throw new Error();
}),
join(loadware(get('/', () => 'Hello 世界'))),
get('/sth', () => {
join(loadware(get("/", () => "Hello 世界"))),
get("/sth", () => {
throw new Error();
}),
get('/', () => {
get("/", () => {
throw new Error();
})
}),
];

@@ -88,74 +92,74 @@

it('works with parameters', async () => {
const ctx = createCtx({ path: '/test/francisco/presencia/bla' });
await get('/test/:name/:lastname/bla')(ctx);
it("works with parameters", async () => {
const ctx = createCtx({ path: "/test/francisco/presencia/bla" });
await get("/test/:name/:lastname/bla")(ctx);
expect(ctx.req.solved).toBe(true);
expect(ctx.req.params.name).toBe('francisco');
expect(ctx.req.params.lastname).toBe('presencia');
expect(ctx.req.params.name).toBe("francisco");
expect(ctx.req.params.lastname).toBe("presencia");
});
});
describe('Error routes', () => {
it('can catch errors', async () => {
describe("Error routes", () => {
it("can catch errors", async () => {
const generate = () => {
throw new Error('Should be caught');
throw new Error("Should be caught");
};
const handle = error(() => 'Error 世界');
const handle = error(() => "Error 世界");
const res = await run([generate, handle]).get('/');
expect(res.body).toBe('Error 世界');
const res = await run([generate, handle]).get("/");
expect(res.body).toBe("Error 世界");
});
it('can catch errors with full path', async () => {
const generate = ctx => {
throw new RouterError('router');
it("can catch errors with full path", async () => {
const generate = (ctx) => {
throw new RouterError("router");
};
const handle = error('/server/test/router', ctx => {
const handle = error("/server/test/router", (ctx) => {
return ctx.error.code;
});
const res = await run([generate, handle]).get('/');
expect(res.body).toBe('/server/test/router');
const res = await run([generate, handle]).get("/");
expect(res.body).toBe("/server/test/router");
});
it('can catch errors with partial path', async () => {
const generate = ctx => {
throw new RouterError('router');
it("can catch errors with partial path", async () => {
const generate = (ctx) => {
throw new RouterError("router");
};
const handle = error('/server/test', ctx => {
const handle = error("/server/test", (ctx) => {
return ctx.error.code;
});
const res = await run([generate, handle]).get('/');
expect(res.body).toBe('/server/test/router');
const res = await run([generate, handle]).get("/");
expect(res.body).toBe("/server/test/router");
});
const errors = {
'test:pre:1': new Error('Hi there 1'),
'test:pre:a': new Error('Hi there a'),
'test:pre:b': new Error('Hi there b'),
'test:pre:build': opts => new Error(`Hi there ${opts.name}`)
"test:pre:1": new Error("Hi there 1"),
"test:pre:a": new Error("Hi there a"),
"test:pre:b": new Error("Hi there b"),
"test:pre:build": (opts) => new Error(`Hi there ${opts.name}`),
};
it('can generate errors', async () => {
const generate = ctx => {
throw new RouterError('router');
it("can generate errors", async () => {
const generate = (ctx) => {
throw new RouterError("router");
};
const handle = error('/server/test/router', ctx => {
const handle = error("/server/test/router", (ctx) => {
return ctx.error.code;
});
const res = await run({ errors }, [generate, handle]).get('/');
expect(res.body).toBe('/server/test/router');
const res = await run({ errors }, [generate, handle]).get("/");
expect(res.body).toBe("/server/test/router");
});
it('can generate errors with options', async () => {
const generate = ctx => {
throw new RouterError('simplerouter', { text: 'ABC' });
it("can generate errors with options", async () => {
const generate = (ctx) => {
throw new RouterError("simplerouter", { text: "ABC" });
};
const handle = error('/server/test/simplerouter', ctx => {
const handle = error("/server/test/simplerouter", (ctx) => {
return ctx.error.message;
});
const res = await run({ errors }, [generate, handle]).get('/');
expect(res.body).toBe('Simple message: ABC');
const res = await run({ errors }, [generate, handle]).get("/");
expect(res.body).toBe("Simple message: ABC");
});
});

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc