mirror of
https://github.com/diced/zipline.git
synced 2025-12-22 23:26:36 -08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ab39fb94d | ||
|
|
e520f1e589 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "zipline-next",
|
||||
"version": "2.7.2",
|
||||
"version": "2.8.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@dicedtomato/colors": "^1.0.3",
|
||||
|
||||
22
src/index.ts
22
src/index.ts
@@ -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(
|
||||
{
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user