@vandenberghinc/volt 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/dist/cjs/file_watcher.d.ts +0 -44
- package/backend/dist/cjs/file_watcher.js +324 -343
- package/backend/dist/cjs/server.d.ts +2 -5
- package/backend/dist/cjs/server.js +182 -179
- package/backend/dist/cjs/volt.d.ts +0 -1
- package/backend/dist/cjs/volt.js +1 -1
- package/backend/dist/esm/file_watcher.d.ts +1 -44
- package/backend/dist/esm/file_watcher.js +325 -309
- package/backend/dist/esm/server.d.ts +2 -5
- package/backend/dist/esm/server.js +182 -179
- package/backend/dist/esm/volt.d.ts +0 -1
- package/backend/dist/esm/volt.js +1 -1
- package/backend/dist/esm-dev/file_watcher.d.ts +1 -44
- package/backend/dist/esm-dev/file_watcher.js +325 -309
- package/backend/dist/esm-dev/server.d.ts +2 -5
- package/backend/dist/esm-dev/server.js +182 -179
- package/backend/dist/esm-dev/volt.d.ts +0 -1
- package/backend/dist/esm-dev/volt.js +1 -1
- package/backend/src/file_watcher.ts +324 -323
- package/backend/src/server.ts +107 -109
- package/backend/src/volt.ts +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,6 @@ import * as Mail from './plugins/mail.js';
|
|
|
7
7
|
import { Status } from "./status.js";
|
|
8
8
|
import { Endpoint, EndpointOptions } from "./endpoint.js";
|
|
9
9
|
import { Database, Collection } from "./database.js";
|
|
10
|
-
import { /*StaticFileWatcher,*/ FileWatcher } from "./file_watcher.js";
|
|
11
10
|
import { Users } from "./users.js";
|
|
12
11
|
import { Paddle } from "./payments/paddle.js";
|
|
13
12
|
import { RateLimits, RateLimitServer, RateLimitClient } from "./rate_limit.js";
|
|
@@ -121,7 +120,6 @@ export declare class Server {
|
|
|
121
120
|
additional_sitemap_endpoints: string[];
|
|
122
121
|
log_level: number;
|
|
123
122
|
tls?: TLSConfig;
|
|
124
|
-
file_watcher?: FileWatcher;
|
|
125
123
|
lightweight: boolean;
|
|
126
124
|
performance: vlib.Performance;
|
|
127
125
|
csp: Record<string, string>;
|
|
@@ -141,7 +139,6 @@ export declare class Server {
|
|
|
141
139
|
keys: Record<string, string>;
|
|
142
140
|
private _on_start;
|
|
143
141
|
private _on_stop;
|
|
144
|
-
is_file_watcher: boolean;
|
|
145
142
|
daemon?: vlib.Daemon;
|
|
146
143
|
private _stop_tscompiler_watcher?;
|
|
147
144
|
users: Users;
|
|
@@ -149,7 +146,8 @@ export declare class Server {
|
|
|
149
146
|
status: typeof Status;
|
|
150
147
|
rate_limits: typeof RateLimits;
|
|
151
148
|
logger: typeof logger;
|
|
152
|
-
constructor({ ip,
|
|
149
|
+
constructor({ ip, // leave undefined for blank detection.
|
|
150
|
+
port, domain, is_primary, source, database, statics, favicon, company, meta, tls, smtp, mail_style, rate_limit, keys, payments, default_headers, google_tag, token_expiration, enable_2fa, enable_account_activation, production, localhost, multiprocessing, processes, offline, additional_sitemap_endpoints, log_level, daemon, lightweight, }: {
|
|
153
151
|
ip?: string;
|
|
154
152
|
port?: number;
|
|
155
153
|
domain: string;
|
|
@@ -178,7 +176,6 @@ export declare class Server {
|
|
|
178
176
|
localhost?: boolean;
|
|
179
177
|
multiprocessing?: boolean;
|
|
180
178
|
processes?: number | null;
|
|
181
|
-
file_watcher?: FileWatcher | Record<string, any> | boolean;
|
|
182
179
|
offline?: boolean;
|
|
183
180
|
additional_sitemap_endpoints?: string[];
|
|
184
181
|
log_level?: number;
|
|
@@ -62,7 +62,7 @@ const endpoint_js_1 = require("./endpoint.js");
|
|
|
62
62
|
const image_endpoint_js_1 = require("./image_endpoint.js");
|
|
63
63
|
const stream_js_1 = require("./stream.js");
|
|
64
64
|
const database_js_1 = require("./database.js");
|
|
65
|
-
|
|
65
|
+
// import { /*StaticFileWatcher,*/ FileWatcher } from "./file_watcher.js";
|
|
66
66
|
const users_js_1 = require("./users.js");
|
|
67
67
|
const paddle_js_1 = require("./payments/paddle.js");
|
|
68
68
|
const rate_limit_js_1 = require("./rate_limit.js");
|
|
@@ -719,7 +719,7 @@ class Server {
|
|
|
719
719
|
additional_sitemap_endpoints;
|
|
720
720
|
log_level;
|
|
721
721
|
tls;
|
|
722
|
-
file_watcher;
|
|
722
|
+
// public file_watcher?: FileWatcher;
|
|
723
723
|
// public admin: AdminConfig;
|
|
724
724
|
// public ts: TypeScriptConfig;
|
|
725
725
|
lightweight;
|
|
@@ -743,7 +743,7 @@ class Server {
|
|
|
743
743
|
_on_stop;
|
|
744
744
|
// public browser_preview?: BrowserPreview;
|
|
745
745
|
// public static_file_watcher: StaticFileWatcher;
|
|
746
|
-
is_file_watcher;
|
|
746
|
+
// public is_file_watcher: boolean;
|
|
747
747
|
daemon;
|
|
748
748
|
_stop_tscompiler_watcher;
|
|
749
749
|
users;
|
|
@@ -751,7 +751,8 @@ class Server {
|
|
|
751
751
|
status;
|
|
752
752
|
rate_limits;
|
|
753
753
|
logger;
|
|
754
|
-
constructor({ ip
|
|
754
|
+
constructor({ ip, // leave undefined for blank detection.
|
|
755
|
+
port = 8000, domain, is_primary = true, source, database = "mongodb://localhost:27017/main", statics = [], favicon = undefined, company, meta = new meta_js_1.Meta(), tls = undefined, smtp = undefined, mail_style = {
|
|
755
756
|
font: '"Helvetica", sans-serif',
|
|
756
757
|
title_fg: "#121B23",
|
|
757
758
|
subtitle_fg: "#121B23",
|
|
@@ -776,7 +777,9 @@ class Server {
|
|
|
776
777
|
},
|
|
777
778
|
}, keys = [], payments = null, default_headers = null, google_tag = undefined, token_expiration = 86400, enable_2fa = false, enable_account_activation = true,
|
|
778
779
|
// honey_pot_key = null,
|
|
779
|
-
production = false, localhost = true, multiprocessing = true, processes = null,
|
|
780
|
+
production = false, localhost = true, multiprocessing = true, processes = null,
|
|
781
|
+
// file_watcher = false,
|
|
782
|
+
offline = false, additional_sitemap_endpoints = [], log_level = 0, daemon = {},
|
|
780
783
|
// admin = {
|
|
781
784
|
// password: null,
|
|
782
785
|
// ips: [],
|
|
@@ -909,7 +912,7 @@ class Server {
|
|
|
909
912
|
localhost: { type: "boolean", required: false },
|
|
910
913
|
multiprocessing: { type: "boolean", required: false, default: true },
|
|
911
914
|
processes: { type: "number", required: false, default: null },
|
|
912
|
-
file_watcher: {
|
|
915
|
+
// file_watcher: {type: ["null", "boolean", "object", FileWatcher], required: false},
|
|
913
916
|
offline: { type: "boolean", default: false },
|
|
914
917
|
additional_sitemap_endpoints: { type: "array", default: [] },
|
|
915
918
|
log_level: { type: "number", default: 0 },
|
|
@@ -934,7 +937,7 @@ class Server {
|
|
|
934
937
|
} });
|
|
935
938
|
// Assign attributes directly.
|
|
936
939
|
this.port = port;
|
|
937
|
-
this.ip = ip;
|
|
940
|
+
this.ip = ip ?? "127.0.0.1";
|
|
938
941
|
this.is_primary = is_primary && cluster_1.default.isPrimary;
|
|
939
942
|
this.source = new _vinc_1.vlib.Path(source);
|
|
940
943
|
this.favicon = favicon;
|
|
@@ -966,6 +969,10 @@ class Server {
|
|
|
966
969
|
this.ip = "127.0.0.1";
|
|
967
970
|
this.domain = this.ip + ":" + (port + (this.tls ? 1 : 0));
|
|
968
971
|
}
|
|
972
|
+
else if (!localhost && ip == null) { // use argument ip not attr since that already has a default.
|
|
973
|
+
this.ip = _vinc_1.vlib.Network.private_ip();
|
|
974
|
+
this.domain = this.ip + ":" + (port + (this.tls ? 1 : 0));
|
|
975
|
+
}
|
|
969
976
|
/* @performance */ this.performance = new _vinc_1.vlib.Performance("Server performance");
|
|
970
977
|
// Assign objects to server so it is easy to access.
|
|
971
978
|
this.status = status_js_1.Status;
|
|
@@ -1074,96 +1081,98 @@ class Server {
|
|
|
1074
1081
|
// Static file watcher.
|
|
1075
1082
|
// this.static_file_watcher = new StaticFileWatcher(this);
|
|
1076
1083
|
// Initialize file watcher.
|
|
1077
|
-
if (file_watcher !== false) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1084
|
+
// if (file_watcher !== false) {
|
|
1085
|
+
// console.warn("[Volt] Argument file_watcher is deprecated. This may be removed in future versions.");
|
|
1086
|
+
// if (file_watcher == null) {
|
|
1087
|
+
// // Null.
|
|
1088
|
+
// file_watcher = {};
|
|
1089
|
+
// }
|
|
1090
|
+
// if (!(file_watcher as Record<string, any>).source) {
|
|
1091
|
+
// // Source.
|
|
1092
|
+
// (file_watcher as Record<string, any>).source = this.source.str();
|
|
1093
|
+
// }
|
|
1094
|
+
// if (!(file_watcher instanceof FileWatcher)) {
|
|
1095
|
+
// // Initialize.
|
|
1096
|
+
// file_watcher = new FileWatcher(file_watcher as any);
|
|
1097
|
+
// }
|
|
1098
|
+
// this.file_watcher = file_watcher as FileWatcher;
|
|
1099
|
+
// }
|
|
1100
|
+
// else {
|
|
1101
|
+
// this.file_watcher = undefined;
|
|
1102
|
+
// }
|
|
1103
|
+
// File watcher.
|
|
1104
|
+
// if (
|
|
1105
|
+
// process.env.VOLT_NO_FILE_WATCHER == null &&
|
|
1106
|
+
// !process.argv.includes("--no-file-watcher") &&
|
|
1107
|
+
// this.production === false &&
|
|
1108
|
+
// // file_watcher !== false &&
|
|
1109
|
+
// process.env.VOLT_FILE_WATCHER !== '1'
|
|
1110
|
+
// ) {
|
|
1111
|
+
// // Disable primary for when users access is_primary.
|
|
1112
|
+
// this.is_primary = false;
|
|
1113
|
+
// // Enable file watcher.
|
|
1114
|
+
// this.is_file_watcher = true;
|
|
1115
|
+
// }
|
|
1116
|
+
// // No file watcher.
|
|
1117
|
+
// else {
|
|
1118
|
+
// Disable file watcher.
|
|
1119
|
+
// this.is_file_watcher = false;
|
|
1120
|
+
// Set logger.
|
|
1121
|
+
logger_js_1.default.log_level = this.log_level;
|
|
1122
|
+
this.log = logger_js_1.default.log.bind(logger_js_1.default);
|
|
1123
|
+
this.error = logger_js_1.default.error.bind(logger_js_1.default);
|
|
1124
|
+
// Initialize the service daemon.
|
|
1125
|
+
// Must be initialized before initializing the database.
|
|
1126
|
+
if (daemon !== false) {
|
|
1127
|
+
const log_source = this.source.join(".logs");
|
|
1128
|
+
if (!log_source.exists()) {
|
|
1129
|
+
log_source.mkdir_sync();
|
|
1090
1130
|
}
|
|
1091
|
-
this.
|
|
1131
|
+
this.daemon = new _vinc_1.vlib.Daemon({
|
|
1132
|
+
name: this.domain.replaceAll(".", ""),
|
|
1133
|
+
user: daemon.user || os.userInfo().username,
|
|
1134
|
+
group: daemon.group || null,
|
|
1135
|
+
command: "volt --service --start",
|
|
1136
|
+
cwd: this.source.str(),
|
|
1137
|
+
args: daemon.args || [],
|
|
1138
|
+
env: daemon.env || {},
|
|
1139
|
+
description: daemon.description || `Service daemon for website ${this.domain}.`,
|
|
1140
|
+
auto_restart: true,
|
|
1141
|
+
logs: daemon.logs || log_source.join("logs").str(),
|
|
1142
|
+
errors: daemon.errors || log_source.join("errors").str(),
|
|
1143
|
+
});
|
|
1092
1144
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1145
|
+
// Initialize the database class.
|
|
1146
|
+
if (typeof database === "string") {
|
|
1147
|
+
this.db = new database_js_1.Database({ uri: database, _server: this });
|
|
1095
1148
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
this.
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
this.is_file_watcher = false;
|
|
1111
|
-
// Set logger.
|
|
1112
|
-
logger_js_1.default.log_level = this.log_level;
|
|
1113
|
-
this.log = logger_js_1.default.log.bind(logger_js_1.default);
|
|
1114
|
-
this.error = logger_js_1.default.error.bind(logger_js_1.default);
|
|
1115
|
-
// Initialize the service daemon.
|
|
1116
|
-
// Must be initialized before initializing the database.
|
|
1117
|
-
if (daemon !== false) {
|
|
1118
|
-
const log_source = this.source.join(".logs");
|
|
1119
|
-
if (!log_source.exists()) {
|
|
1120
|
-
log_source.mkdir_sync();
|
|
1121
|
-
}
|
|
1122
|
-
this.daemon = new _vinc_1.vlib.Daemon({
|
|
1123
|
-
name: this.domain.replaceAll(".", ""),
|
|
1124
|
-
user: daemon.user || os.userInfo().username,
|
|
1125
|
-
group: daemon.group || null,
|
|
1126
|
-
command: "volt --service --start",
|
|
1127
|
-
cwd: this.source.str(),
|
|
1128
|
-
args: daemon.args || [],
|
|
1129
|
-
env: daemon.env || {},
|
|
1130
|
-
description: daemon.description || `Service daemon for website ${this.domain}.`,
|
|
1131
|
-
auto_restart: true,
|
|
1132
|
-
logs: daemon.logs || log_source.join("logs").str(),
|
|
1133
|
-
errors: daemon.errors || log_source.join("errors").str(),
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
// Initialize the database class.
|
|
1137
|
-
if (typeof database === "string") {
|
|
1138
|
-
this.db = new database_js_1.Database({ uri: database, _server: this });
|
|
1139
|
-
}
|
|
1140
|
-
else if (database !== false) {
|
|
1141
|
-
this.db = new database_js_1.Database({ ...database, _server: this });
|
|
1142
|
-
}
|
|
1143
|
-
// Initialize the users class.
|
|
1144
|
-
this.users = new users_js_1.Users(this);
|
|
1145
|
-
// The smtp instance.
|
|
1146
|
-
if (smtp) {
|
|
1147
|
-
this.smtp_sender = smtp.sender;
|
|
1148
|
-
this.smtp = nodemailer.createTransport(smtp);
|
|
1149
|
+
else if (database !== false) {
|
|
1150
|
+
this.db = new database_js_1.Database({ ...database, _server: this });
|
|
1151
|
+
}
|
|
1152
|
+
// Initialize the users class.
|
|
1153
|
+
this.users = new users_js_1.Users(this);
|
|
1154
|
+
// The smtp instance.
|
|
1155
|
+
if (smtp) {
|
|
1156
|
+
this.smtp_sender = smtp.sender;
|
|
1157
|
+
this.smtp = nodemailer.createTransport(smtp);
|
|
1158
|
+
}
|
|
1159
|
+
// The rate limit server/client.
|
|
1160
|
+
if (rate_limit) {
|
|
1161
|
+
if (this.is_primary) {
|
|
1162
|
+
this.rate_limit = new rate_limit_js_1.RateLimitServer({ ...(rate_limit.server ?? {}), _server: this });
|
|
1149
1163
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
this.rate_limit = new rate_limit_js_1.RateLimitServer({ ...(rate_limit.server ?? {}), _server: this });
|
|
1154
|
-
}
|
|
1155
|
-
else {
|
|
1156
|
-
if (rate_limit.server?.https) {
|
|
1157
|
-
rate_limit.client.https = true;
|
|
1158
|
-
}
|
|
1159
|
-
this.rate_limit = new rate_limit_js_1.RateLimitClient({ ...(rate_limit.client ?? {}), _server: this });
|
|
1164
|
+
else {
|
|
1165
|
+
if (rate_limit.server?.https) {
|
|
1166
|
+
rate_limit.client.https = true;
|
|
1160
1167
|
}
|
|
1168
|
+
this.rate_limit = new rate_limit_js_1.RateLimitClient({ ...(rate_limit.client ?? {}), _server: this });
|
|
1161
1169
|
}
|
|
1162
|
-
// Blacklist class.
|
|
1163
|
-
// if (this.honey_pot_key) {
|
|
1164
|
-
// this.blacklist = new Blacklist({api_key: this.honey_pot_key});
|
|
1165
|
-
// }
|
|
1166
1170
|
}
|
|
1171
|
+
// Blacklist class.
|
|
1172
|
+
// if (this.honey_pot_key) {
|
|
1173
|
+
// this.blacklist = new Blacklist({api_key: this.honey_pot_key});
|
|
1174
|
+
// }
|
|
1175
|
+
// }
|
|
1167
1176
|
// Other keys.
|
|
1168
1177
|
this.keys = {};
|
|
1169
1178
|
// Start callbacks.
|
|
@@ -1254,7 +1263,7 @@ class Server {
|
|
|
1254
1263
|
// Create default endpoints.
|
|
1255
1264
|
_create_default_endpoints() {
|
|
1256
1265
|
// Vars.
|
|
1257
|
-
const additional_file_watcher_paths = [];
|
|
1266
|
+
// const additional_file_watcher_paths: string[] = [];
|
|
1258
1267
|
// Add favicon.
|
|
1259
1268
|
if (this.favicon != null) {
|
|
1260
1269
|
const favicon = new _vinc_1.vlib.Path(this.favicon);
|
|
@@ -1362,7 +1371,7 @@ class Server {
|
|
|
1362
1371
|
._load_data_by_path(this));
|
|
1363
1372
|
});
|
|
1364
1373
|
// Handler.
|
|
1365
|
-
return additional_file_watcher_paths;
|
|
1374
|
+
// return additional_file_watcher_paths;
|
|
1366
1375
|
}
|
|
1367
1376
|
// Create the sitemap endpoint.
|
|
1368
1377
|
_create_sitemap() {
|
|
@@ -1732,87 +1741,81 @@ class Server {
|
|
|
1732
1741
|
logger_js_1.default.log(1, log_source, "Initializing server.");
|
|
1733
1742
|
/* @performance */ this.performance.start();
|
|
1734
1743
|
// File watcher.
|
|
1735
|
-
if (this.is_file_watcher) {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1744
|
+
// if (this.is_file_watcher) {
|
|
1745
|
+
// // Disable primary for when users access is_primary.
|
|
1746
|
+
// this.is_primary = false;
|
|
1747
|
+
// // Create default endpoints for excluded static file watch paths.
|
|
1748
|
+
// this._create_default_endpoints();
|
|
1749
|
+
// // Exclude the typescript output directory from the file watcher.
|
|
1750
|
+
// // if (this.ts.output) {
|
|
1751
|
+
// // this.file_watcher!.add_exclude(this.ts.output);
|
|
1752
|
+
// // }
|
|
1753
|
+
// // Add the volt backend source files to the additional files.
|
|
1754
|
+
// this.file_watcher!.add_path(__dirname);
|
|
1755
|
+
// this.file_watcher!.add_exclude(`${__dirname}/frontend_globals.js`);
|
|
1756
|
+
// // Exclude static files.
|
|
1757
|
+
// this.statics.forEach(item => {
|
|
1758
|
+
// if (typeof item === "string" || item instanceof vlib.Path) {
|
|
1759
|
+
// this.file_watcher!.add_exclude(item);
|
|
1760
|
+
// }
|
|
1761
|
+
// else {
|
|
1762
|
+
// this.file_watcher!.add_exclude(item.path)
|
|
1763
|
+
// }
|
|
1764
|
+
// })
|
|
1765
|
+
// if (!this.production) {
|
|
1766
|
+
// [
|
|
1767
|
+
// `${process.env.PERSISTANCE}/private/dev/vinc/vlib/js/vlib.js`,
|
|
1768
|
+
// `${process.env.PERSISTANCE}/private/dev/vinc/vhighlight/vhighlight.js`,
|
|
1769
|
+
// ].forEach(path => {
|
|
1770
|
+
// const vpath = new vlib.Path(path);
|
|
1771
|
+
// if (vpath.exists()) {
|
|
1772
|
+
// this.file_watcher!.add_exclude(vpath.str());
|
|
1773
|
+
// }
|
|
1774
|
+
// })
|
|
1775
|
+
// }
|
|
1776
|
+
// // Stop.
|
|
1777
|
+
// return;
|
|
1778
|
+
// }
|
|
1779
|
+
// // No file watcher.
|
|
1780
|
+
// else {
|
|
1781
|
+
// Create HTTPS server.
|
|
1782
|
+
if (this.tls) {
|
|
1783
|
+
this.https = http2.createSecureServer({
|
|
1784
|
+
key: new _vinc_1.vlib.Path(this.tls.key).load_sync({ encoding: 'utf8' }),
|
|
1785
|
+
cert: new _vinc_1.vlib.Path(this.tls.cert).load_sync({ encoding: 'utf8' }),
|
|
1786
|
+
ca: this.tls.ca == null ? null : new _vinc_1.vlib.Path(this.tls.ca).load_sync({ encoding: 'utf8' }),
|
|
1787
|
+
passphrase: this.tls.passphrase,
|
|
1788
|
+
allowHTTP1: true,
|
|
1789
|
+
},
|
|
1790
|
+
// Support for http1.
|
|
1791
|
+
// Does not work, requests get triggered on the stream and on this callback.
|
|
1792
|
+
(req, res) => {
|
|
1793
|
+
if (req.httpVersion.charAt(0) !== "2") {
|
|
1794
|
+
this._serve(undefined, undefined, req, res);
|
|
1758
1795
|
}
|
|
1759
1796
|
});
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1797
|
+
this.https.on('stream', (stream, headers) => {
|
|
1798
|
+
this._serve(stream, headers, undefined, undefined);
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
// Payments require HTTPS in production.
|
|
1802
|
+
else if (this.production && this.payments) {
|
|
1803
|
+
throw Error("Accepting payments in production mode requires HTTPS.");
|
|
1804
|
+
}
|
|
1805
|
+
// Redirect HTTP requests to HTTPS.
|
|
1806
|
+
if (this.tls) {
|
|
1807
|
+
this.http = http.createServer((request, response) => {
|
|
1808
|
+
response.writeHead(301, { Location: `https://${request.headers.host}${request.url}` });
|
|
1809
|
+
response.end();
|
|
1810
|
+
});
|
|
1773
1811
|
}
|
|
1774
|
-
// No file watcher.
|
|
1775
1812
|
else {
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
key: new _vinc_1.vlib.Path(this.tls.key).load_sync({ encoding: 'utf8' }),
|
|
1780
|
-
cert: new _vinc_1.vlib.Path(this.tls.cert).load_sync({ encoding: 'utf8' }),
|
|
1781
|
-
ca: this.tls.ca == null ? null : new _vinc_1.vlib.Path(this.tls.ca).load_sync({ encoding: 'utf8' }),
|
|
1782
|
-
passphrase: this.tls.passphrase,
|
|
1783
|
-
allowHTTP1: true,
|
|
1784
|
-
},
|
|
1785
|
-
// Support for http1.
|
|
1786
|
-
// Does not work, requests get triggered on the stream and on this callback.
|
|
1787
|
-
(req, res) => {
|
|
1788
|
-
if (req.httpVersion.charAt(0) !== "2") {
|
|
1789
|
-
this._serve(undefined, undefined, req, res);
|
|
1790
|
-
}
|
|
1791
|
-
});
|
|
1792
|
-
this.https.on('stream', (stream, headers) => {
|
|
1793
|
-
this._serve(stream, headers, undefined, undefined);
|
|
1794
|
-
});
|
|
1795
|
-
}
|
|
1796
|
-
// Payments require HTTPS in production.
|
|
1797
|
-
else if (this.production && this.payments) {
|
|
1798
|
-
throw Error("Accepting payments in production mode requires HTTPS.");
|
|
1799
|
-
}
|
|
1800
|
-
// Redirect HTTP requests to HTTPS.
|
|
1801
|
-
if (this.tls) {
|
|
1802
|
-
this.http = http.createServer((request, response) => {
|
|
1803
|
-
response.writeHead(301, { Location: `https://${request.headers.host}${request.url}` });
|
|
1804
|
-
response.end();
|
|
1805
|
-
});
|
|
1806
|
-
}
|
|
1807
|
-
else {
|
|
1808
|
-
this.http = http.createServer((req, res) => {
|
|
1809
|
-
this._serve(undefined, undefined, req, res);
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
/* @performance */ this.performance.end("create-http-server");
|
|
1813
|
+
this.http = http.createServer((req, res) => {
|
|
1814
|
+
this._serve(undefined, undefined, req, res);
|
|
1815
|
+
});
|
|
1813
1816
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1817
|
+
/* @performance */ this.performance.end("create-http-server");
|
|
1818
|
+
// }
|
|
1816
1819
|
// Start the database.
|
|
1817
1820
|
if (this.db) {
|
|
1818
1821
|
await this.db.initialize();
|
|
@@ -2148,11 +2151,11 @@ class Server {
|
|
|
2148
2151
|
// Always initialize, even when forking.
|
|
2149
2152
|
await this.initialize();
|
|
2150
2153
|
// Inside file watcher process.
|
|
2151
|
-
if (this.is_file_watcher) {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
}
|
|
2154
|
+
// if (this.is_file_watcher) {
|
|
2155
|
+
// this.file_watcher!.start();
|
|
2156
|
+
// await this.file_watcher!.promise;
|
|
2157
|
+
// return ;
|
|
2158
|
+
// }
|
|
2156
2159
|
// Start static file watcher.
|
|
2157
2160
|
// if (!this.production && this.file_watcher) {
|
|
2158
2161
|
// this.static_file_watcher.start();
|
|
@@ -2605,12 +2608,12 @@ class Server {
|
|
|
2605
2608
|
}
|
|
2606
2609
|
// Add endpoint.
|
|
2607
2610
|
this.endpoints.set(`${endpoint.endpoint}:${endpoint.method}`, endpoint);
|
|
2608
|
-
if (!this.production) {
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
}
|
|
2611
|
+
// if (!this.production) {
|
|
2612
|
+
// if (endpoint._path && this.file_watcher?.add_exclude) {
|
|
2613
|
+
// this.file_watcher!.add_exclude(endpoint._path);
|
|
2614
|
+
// }
|
|
2615
|
+
// // this.static_file_watcher.add(endpoint);
|
|
2616
|
+
// }
|
|
2614
2617
|
}
|
|
2615
2618
|
return this;
|
|
2616
2619
|
}
|
|
@@ -9,7 +9,6 @@ export * from "./server.js";
|
|
|
9
9
|
export * from "./database.js";
|
|
10
10
|
export * from "./rate_limit.js";
|
|
11
11
|
export * from "./logger.js";
|
|
12
|
-
export * from "./file_watcher.js";
|
|
13
12
|
export * as Mail from "./plugins/mail.js";
|
|
14
13
|
export * as TypeScript from "./plugins/ts/compiler.js";
|
|
15
14
|
export * from "./plugins/css.js";
|
package/backend/dist/cjs/volt.js
CHANGED
|
@@ -56,7 +56,7 @@ __exportStar(require("./server.js"), exports);
|
|
|
56
56
|
__exportStar(require("./database.js"), exports);
|
|
57
57
|
__exportStar(require("./rate_limit.js"), exports);
|
|
58
58
|
__exportStar(require("./logger.js"), exports);
|
|
59
|
-
|
|
59
|
+
// export * from "./file_watcher.js"
|
|
60
60
|
exports.Mail = __importStar(require("./plugins/mail.js"));
|
|
61
61
|
// export * as PDF from "./plugins/pdf.js"
|
|
62
62
|
exports.TypeScript = __importStar(require("./plugins/ts/compiler.js"));
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
|
|
2
|
-
declare class StaticFileWatcher {
|
|
3
|
-
private server;
|
|
4
|
-
private mtimes;
|
|
5
|
-
private endpoints;
|
|
6
|
-
private log_source;
|
|
7
|
-
private interval;
|
|
8
|
-
constructor(server: any);
|
|
9
|
-
start(): Promise<void>;
|
|
10
|
-
add(endpoint: any): void;
|
|
11
|
-
has(endpoint: string): boolean;
|
|
12
|
-
stop(): void;
|
|
13
|
-
}
|
|
14
|
-
declare class FileWatcher {
|
|
15
|
-
private source;
|
|
16
|
-
private config?;
|
|
17
|
-
private interval;
|
|
18
|
-
private excluded;
|
|
19
|
-
private additional_paths;
|
|
20
|
-
private start_file?;
|
|
21
|
-
private log_source;
|
|
22
|
-
private args;
|
|
23
|
-
private mtimes;
|
|
24
|
-
promise: Promise<any>;
|
|
25
|
-
private proc;
|
|
26
|
-
private has_changed;
|
|
27
|
-
private _com_file?;
|
|
28
|
-
constructor({ source, config, interval, excluded, additional_paths, start_file, }: {
|
|
29
|
-
source: vlib.Path | string;
|
|
30
|
-
config?: string;
|
|
31
|
-
interval?: number;
|
|
32
|
-
excluded?: string[];
|
|
33
|
-
additional_paths?: string[];
|
|
34
|
-
start_file?: string;
|
|
35
|
-
});
|
|
36
|
-
add_path(path: string | vlib.Path): void;
|
|
37
|
-
add_exclude(path: string | vlib.Path): void;
|
|
38
|
-
start(): Promise<void>;
|
|
39
|
-
scan(): Promise<void>;
|
|
40
|
-
scan_files(): void;
|
|
41
|
-
spawn_process(): void;
|
|
42
|
-
restart_process(): Promise<void>;
|
|
43
|
-
}
|
|
44
|
-
export { StaticFileWatcher, FileWatcher };
|
|
1
|
+
export {};
|