Initial commit

This commit is contained in:
abrendan
2023-11-30 14:15:19 +00:00
commit e4599df811
5457 changed files with 500139 additions and 0 deletions

19
node_modules/server/plugins/static/index.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
const modern = require('../../src/modern');
module.exports = {
name: 'static',
options: {
__root: 'public',
public: {
type: String,
inherit: 'public',
env: false
}
},
init: ctx => {
if (!ctx.options.static.public) return;
module.exports.before = [
modern(ctx.express.static(ctx.options.static.public))
];
}
};

45
node_modules/server/plugins/static/unit.test.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
const run = require('server/test/run');
const stat = require('./');
const storeLog = out => ({ report: { write: log => { out.log = log; } } });
describe('static plugin', () => {
it('exists', () => {
expect(stat).toBeDefined();
expect(stat.name).toBe('static');
expect(stat.options).toBeDefined();
});
it('static', async () => {
const res = await run({ public: 'test' }).get('/logo.png');
expect(res.statusCode).toBe(200);
expect(res.headers['content-type']).toBe('image/png');
});
it('non-existing static', async () => {
let out = {};
const log = storeLog(out);
const res = await run({ public: 'xxxx', log }).get('/non-existing.png');
expect(res.statusCode).toBe(404);
expect(out.log).toMatch(/did not return anything/);
});
it('does not serve if set to false', async () => {
let out = {};
const log = storeLog(out);
const res = await run({ public: false, log }).get('/logo.png');
expect(res.statusCode).toBe(404);
expect(out.log).toMatch(/did not return anything/);
});
it('does not serve if set to empty string', async () => {
let out = {};
const log = storeLog(out);
const res = await run({ public: '', log }).get('/logo.png');
expect(res.statusCode).toBe(404);
expect(out.log).toMatch(/did not return anything/);
});
});