Compare commits

..

2 Commits
2.7.2 ... 2.8.0

Author SHA1 Message Date
diced
6ab39fb94d 2.8.0 2021-02-11 20:48:12 -08:00
diced
e520f1e589 Vulnerability Fix 2021-02-11 20:47:57 -08:00
3 changed files with 19 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "zipline-next",
"version": "2.7.2",
"version": "2.8.0",
"private": true,
"dependencies": {
"@dicedtomato/colors": "^1.0.3",

View File

@@ -9,6 +9,7 @@ import { Configuration } from './lib/Config';
import { join } from 'path';
import { checkVersion } from './lib/Util';
import { PluginLoader } from './lib/plugin';
import { readdirSync, statSync } from 'fs';
const dev = process.env.NODE_ENV !== 'production';
const server = fastify({});
@@ -45,14 +46,15 @@ if (!config) {
const path = dir.charAt(0) == '/' ? dir : join(process.cwd(), dir);
const handle = app.getRequestHandler();
if (dev) server.get('/_next/*', async (req, reply) => {
await handle(req.raw, reply.raw);
return (reply.sent = true);
});
server.all('/*', async (req, reply) => {
await handle(req.raw, reply.raw);
return (reply.sent = true);
server.get('/*', async (req, reply) => {
const routeRegex = /\/_next\/static|\/((dash|user)(\/)?(.+)?)?/gi;
if (routeRegex.test(req.url)) {
await handle(req.raw, reply.raw);
return (reply.sent = true);
} else {
await app.render404(req.raw, reply.raw);
return (reply.sent = true);
}
});
server.setNotFoundHandler(async (req, reply) => {
@@ -74,10 +76,10 @@ if (!config) {
plugin.onLoad(server, server.orm, app, config);
Console.logger(PluginLoader).info(`loaded plugin: ${plugin.name}`);
} catch (e) {
Console.logger(PluginLoader).error(`failed to load plugin: ${plugin.name}, ${e.message}`)
Console.logger(PluginLoader).error(`failed to load plugin: ${plugin.name}, ${e.message}`);
}
}
})
});
server.listen(
{

View File

@@ -1,7 +1,7 @@
import { FastifyInstance } from "fastify";
import { readdirSync, statSync } from "fs";
import { join } from "path";
import { Plugin } from "./Plugin";
import { FastifyInstance } from 'fastify';
import { readdirSync, statSync } from 'fs';
import { join } from 'path';
import { Plugin } from './Plugin';
export class PluginLoader {
public directory: string;
@@ -15,7 +15,7 @@ export class PluginLoader {
this.fastify = fastify;
}
public getAllFiles(builtIn: boolean = false): string[] {
public getAllFiles(builtIn = false): string[] {
const result = [];
const r = (dir: string) => {
@@ -32,7 +32,7 @@ export class PluginLoader {
return result;
}
public async loadPlugins(builtIn: boolean = false): Promise<Plugin[]> {
public async loadPlugins(builtIn = false): Promise<Plugin[]> {
const files = this.getAllFiles(builtIn);
for (const pluginFile of files) {