turbo-express-js 1.0.8 → 1.0.9
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/README.md +65 -15
- package/changelog.md +6 -1
- package/index.d.ts +124 -0
- package/index.js +1 -0
- package/index.test.js +4 -6
- package/lib/TurboServer.js +28 -18
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Turbo Express JS 🚀
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
**Minimalistic, Fast and Powerful Node.js Framework**
|
|
4
|
+
**(Express + JSON Parser + CORS + Cookie Parser + Upload + Validation + Authentication)**
|
|
5
|
+
|
|
6
|
+
> 🔄 Express compatible structure, but OOP driven and built-in all middlewares.
|
|
7
7
|
|
|
8
8
|
> Made with ❤️ by Mike Karypidis
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## ✨ Features
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
- Zero external dependency setup (JSON, CORS, Cookie, Upload built-in)
|
|
13
|
+
- Extendable `Request` and `Response` (OOP interfaces)
|
|
14
|
+
- Authentication system out of the box
|
|
15
|
+
- Validation middleware out of the box
|
|
16
|
+
- Clustering support (spawn multiple workers)
|
|
17
|
+
- Post-controller middleware execution
|
|
18
|
+
- Locales (i18n) ready
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
---
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
|
|
23
|
+
## 🔧 Installation
|
|
20
24
|
|
|
21
25
|
To install TurboServer, simply run the following command:
|
|
22
26
|
|
|
@@ -24,7 +28,7 @@ To install TurboServer, simply run the following command:
|
|
|
24
28
|
npm install turbo-express-js
|
|
25
29
|
```
|
|
26
30
|
|
|
27
|
-
## Getting Started
|
|
31
|
+
## 👌 Getting Started
|
|
28
32
|
|
|
29
33
|
Here's a simple example of how to create a basic server using TurboServer:
|
|
30
34
|
|
|
@@ -32,7 +36,7 @@ Here's a simple example of how to create a basic server using TurboServer:
|
|
|
32
36
|
|
|
33
37
|
const TurboServer = require('turboserver');
|
|
34
38
|
|
|
35
|
-
const app = new TurboServer(
|
|
39
|
+
const app = new TurboServer();
|
|
36
40
|
|
|
37
41
|
app.get('/', (req, res) => {
|
|
38
42
|
res.send('Hello, World!');
|
|
@@ -43,15 +47,61 @@ Here's a simple example of how to create a basic server using TurboServer:
|
|
|
43
47
|
});
|
|
44
48
|
```
|
|
45
49
|
|
|
50
|
+
# 🔬 Comparison: Express.js vs Turbo Express JS
|
|
51
|
+
|
|
52
|
+
| Feature | Express.js | Turbo Express JS |
|
|
53
|
+
|:---|:---|:---|
|
|
54
|
+
| Built-in JSON Body Parsing | ❌ | ✅ |
|
|
55
|
+
| Built-in CORS Middleware | ❌ | ✅ |
|
|
56
|
+
| Built-in File Upload Support | ❌ | ✅ |
|
|
57
|
+
| Authentication System | ❌ | ✅ |
|
|
58
|
+
| OOP Request/Response Extendable | ❌ | ✅ |
|
|
59
|
+
| Cluster Support | ❌ (manual) | ✅ (out of the box) |
|
|
60
|
+
| Validation Middleware | ❌ | ✅ |
|
|
61
|
+
| Post-Controller Middlewares | ❌ | ✅ |
|
|
62
|
+
| Locales (i18n) | ❌ | ✅ |
|
|
63
|
+
| Performance Focus | ✅ | ✅ |
|
|
64
|
+
|
|
65
|
+
## 📦 TypeScript Support
|
|
66
|
+
|
|
67
|
+
Turbo Express JS works perfectly with TypeScript.
|
|
68
|
+
It includes a ready-to-use `index.d.ts` file with support for:
|
|
69
|
+
|
|
70
|
+
- Request/Response interfaces
|
|
71
|
+
- Class-based routing
|
|
72
|
+
- Autocomplete & type checking
|
|
73
|
+
- Full OOP method overriding
|
|
74
|
+
|
|
75
|
+
### ✅ Basic Example in TypeScript
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// main.ts
|
|
79
|
+
import TurboServer = require("turbo-express-js");
|
|
80
|
+
|
|
81
|
+
const app = new TurboServer();
|
|
82
|
+
|
|
83
|
+
app.get("/", (req, res) => {
|
|
84
|
+
res.send("Hello from TypeScript + Turbo Express JS!");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
app.listen(3000, () => {
|
|
88
|
+
console.log("TurboExpress running on http://localhost:3000");
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
46
92
|
# Clustering
|
|
47
93
|
|
|
48
94
|
TurboServer is built to support clustering out of the box. By passing a number to the TurboServer constructor, you can specify how many worker processes to spawn for your application.
|
|
49
95
|
|
|
96
|
+
``` javascript
|
|
97
|
+
const app = new TurboServer(2);
|
|
98
|
+
```
|
|
99
|
+
|
|
50
100
|
In the example above, const app = new TurboServer(2) tells TurboServer to start two worker processes for the server. This allows the server to handle multiple requests simultaneously, improving the performance and scalability of your application.
|
|
51
101
|
|
|
52
102
|
To take full advantage of the clustering feature, it's important to make sure your application is stateless and doesn't rely on local variables or in-memory storage. With proper configuration, clustering can help your application handle a large number of requests with ease.
|
|
53
103
|
|
|
54
|
-
# Middlewares
|
|
104
|
+
# 🔍 Middlewares
|
|
55
105
|
TurboServer includes a number of built-in middlewares that you can use to add functionality to your application. Here are some of out of the box middlewares:
|
|
56
106
|
|
|
57
107
|
1. Cors middleware
|
package/changelog.md
CHANGED
|
@@ -11,4 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
# 1.0.7 stable
|
|
13
13
|
1. [18/8/2023] update TurboExpress.Cors() fix bug that throw an error if it not recieve props
|
|
14
|
-
2. [18/8/2023] update documentations
|
|
14
|
+
2. [18/8/2023] update documentations
|
|
15
|
+
|
|
16
|
+
# 1.0.8 docs changes
|
|
17
|
+
|
|
18
|
+
# 1.0.9
|
|
19
|
+
1. [25/4/2025] update clusters, 0 argument mean no clusters.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// index.d.ts
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
|
|
4
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
5
|
+
|
|
6
|
+
export = TurboServer;
|
|
7
|
+
|
|
8
|
+
declare class TurboServer {
|
|
9
|
+
constructor(clusterslength?: number);
|
|
10
|
+
|
|
11
|
+
static Router: typeof Router;
|
|
12
|
+
static AuthenticationService: any;
|
|
13
|
+
static ValidationTypes: any;
|
|
14
|
+
static ExpressServices: any;
|
|
15
|
+
static TurboExpressDefault: any;
|
|
16
|
+
static Log: any;
|
|
17
|
+
static Util: any;
|
|
18
|
+
|
|
19
|
+
static Static(options?: { folder?: string; cache?: boolean }): Function;
|
|
20
|
+
static Cors(options?: { origins?: string[]; credentials?: boolean; methods?: string[]; headers?: string[] }): Function;
|
|
21
|
+
static Upload(options?: { folder?: string; memory?: boolean }): Function;
|
|
22
|
+
static Validation(options?: any): Function;
|
|
23
|
+
static RunMethod(options?: { exe: any[] }): Function;
|
|
24
|
+
static Authentication(options?: { authentication_service: any }): Function;
|
|
25
|
+
static BuildForm(options?: any): Function;
|
|
26
|
+
static exeMaster(callback: () => Promise<void>): Promise<void>;
|
|
27
|
+
static exeWorker(callback: () => Promise<void>): Promise<void>;
|
|
28
|
+
|
|
29
|
+
Request: typeof RequestInterface;
|
|
30
|
+
Response: typeof ResponseInterface;
|
|
31
|
+
|
|
32
|
+
use(path: string, ...callbacks: Function[]): void;
|
|
33
|
+
useEndMiddleware(path: string, ...callbacks: Function[]): void;
|
|
34
|
+
|
|
35
|
+
get(path: string, ...callbacks: Function[]): void;
|
|
36
|
+
post(path: string, ...callbacks: Function[]): void;
|
|
37
|
+
put(path: string, ...callbacks: Function[]): void;
|
|
38
|
+
delete(path: string, ...callbacks: Function[]): void;
|
|
39
|
+
head(path: string, ...callbacks: Function[]): void;
|
|
40
|
+
patch(path: string, ...callbacks: Function[]): void;
|
|
41
|
+
options(path: string, ...callbacks: Function[]): void;
|
|
42
|
+
link(path: string, ...callbacks: Function[]): void;
|
|
43
|
+
unlink(path: string, ...callbacks: Function[]): void;
|
|
44
|
+
view(path: string, ...callbacks: Function[]): void;
|
|
45
|
+
lock(path: string, ...callbacks: Function[]): void;
|
|
46
|
+
unlock(path: string, ...callbacks: Function[]): void;
|
|
47
|
+
copy(path: string, ...callbacks: Function[]): void;
|
|
48
|
+
purge(path: string, ...callbacks: Function[]): void;
|
|
49
|
+
propfind(path: string, ...callbacks: Function[]): void;
|
|
50
|
+
all(path: string, ...callbacks: Function[]): void;
|
|
51
|
+
|
|
52
|
+
getServer(): import("http").Server;
|
|
53
|
+
setLocales(localeDirectory: string): void;
|
|
54
|
+
listen(port: number, callback?: () => void): void;
|
|
55
|
+
logRoutes(): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class Router {
|
|
59
|
+
constructor(path?: string);
|
|
60
|
+
|
|
61
|
+
get(path: string, ...callbacks: Function[]): void;
|
|
62
|
+
post(path: string, ...callbacks: Function[]): void;
|
|
63
|
+
put(path: string, ...callbacks: Function[]): void;
|
|
64
|
+
delete(path: string, ...callbacks: Function[]): void;
|
|
65
|
+
head(path: string, ...callbacks: Function[]): void;
|
|
66
|
+
patch(path: string, ...callbacks: Function[]): void;
|
|
67
|
+
options(path: string, ...callbacks: Function[]): void;
|
|
68
|
+
link(path: string, ...callbacks: Function[]): void;
|
|
69
|
+
unlink(path: string, ...callbacks: Function[]): void;
|
|
70
|
+
view(path: string, ...callbacks: Function[]): void;
|
|
71
|
+
lock(path: string, ...callbacks: Function[]): void;
|
|
72
|
+
unlock(path: string, ...callbacks: Function[]): void;
|
|
73
|
+
copy(path: string, ...callbacks: Function[]): void;
|
|
74
|
+
purge(path: string, ...callbacks: Function[]): void;
|
|
75
|
+
propfind(path: string, ...callbacks: Function[]): void;
|
|
76
|
+
|
|
77
|
+
use(path: string, ...callbacks: Function[]): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare class RequestInterface {
|
|
81
|
+
IncomingMessage: IncomingMessage;
|
|
82
|
+
models: Map<string, any>;
|
|
83
|
+
content_type: string;
|
|
84
|
+
current_locale: string;
|
|
85
|
+
ValidationError: any;
|
|
86
|
+
_body: Buffer;
|
|
87
|
+
_files: any[];
|
|
88
|
+
_validations: any[];
|
|
89
|
+
_validation_errors: any[];
|
|
90
|
+
_body_hash: any;
|
|
91
|
+
|
|
92
|
+
params(): Map<string, any>;
|
|
93
|
+
paramsObj(): Record<string, any>;
|
|
94
|
+
queries(): URLSearchParams;
|
|
95
|
+
queriesObj(): Record<string, any>;
|
|
96
|
+
headers(): IncomingMessage["headers"];
|
|
97
|
+
method(): string;
|
|
98
|
+
url(): string;
|
|
99
|
+
httpVersion(): string;
|
|
100
|
+
remoteAddress(): string;
|
|
101
|
+
remotePort(): number;
|
|
102
|
+
localAddress(): string;
|
|
103
|
+
localPort(): number;
|
|
104
|
+
|
|
105
|
+
body(): Promise<any>;
|
|
106
|
+
body_hash(): any;
|
|
107
|
+
files(): any[];
|
|
108
|
+
|
|
109
|
+
setState(key: string, value: any): void;
|
|
110
|
+
useState(key: string): any;
|
|
111
|
+
getStateObj(): Record<string, any>;
|
|
112
|
+
|
|
113
|
+
getText(key: string): string | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare class ResponseInterface {
|
|
117
|
+
OutgoingMessage: ServerResponse;
|
|
118
|
+
models: Map<string, any>;
|
|
119
|
+
|
|
120
|
+
status(code: number): this;
|
|
121
|
+
send(body: string, contentType?: string): void;
|
|
122
|
+
json(data: object): void;
|
|
123
|
+
header(key: string, value: string): void;
|
|
124
|
+
}
|
package/index.js
CHANGED
package/index.test.js
CHANGED
|
@@ -2,12 +2,10 @@ const TurboExpress = require("./lib/TurboServer");
|
|
|
2
2
|
const RequestInterface = require("./lib/types/RequestInterface");
|
|
3
3
|
const ResponseInterface = require("./lib/types/ResponseInterface");
|
|
4
4
|
|
|
5
|
-
const app = new TurboExpress(
|
|
5
|
+
const app = new TurboExpress();
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// console.log("testing development...")
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
app.get("asd", ()=>{ })
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
app.listen(3001, () => console.log("Server is running on port 3000"));
|
|
11
|
+
app.listen(3001, () => console.log("Service is running"));
|
package/lib/TurboServer.js
CHANGED
|
@@ -221,6 +221,7 @@ module.exports = class TurboServer
|
|
|
221
221
|
/** @type {Map<String, import("mongoose").Model} */ models = new Map();
|
|
222
222
|
/** @type {Map<String, import("mongoose").Model} */ sqlModels = new Map(); // TODO later
|
|
223
223
|
/** @type {import("./services/LocaleService")} */ localeService = new ExpressServices.LocaleService();
|
|
224
|
+
/** @type {Boolean} */ useClusters = true;
|
|
224
225
|
|
|
225
226
|
/**
|
|
226
227
|
* @param {Number} CLUSTERSLENGTH
|
|
@@ -230,6 +231,15 @@ module.exports = class TurboServer
|
|
|
230
231
|
*/
|
|
231
232
|
constructor (CLUSTERSLENGTH)
|
|
232
233
|
{
|
|
234
|
+
if(!CLUSTERSLENGTH)
|
|
235
|
+
{
|
|
236
|
+
global["TurboExpress"] = new Object();
|
|
237
|
+
global["TurboExpressCaching"] = new Object();
|
|
238
|
+
this.#server = http.createServer(ServerCallback.bind(this));
|
|
239
|
+
this.Request = RequestInterface;
|
|
240
|
+
this.Response = ResponseInterface;
|
|
241
|
+
this.useClusters = false;
|
|
242
|
+
}
|
|
233
243
|
if (cluster.isMaster) {
|
|
234
244
|
for (let i = 0; i < CLUSTERSLENGTH; i++) { cluster.fork() }
|
|
235
245
|
} else {
|
|
@@ -249,39 +259,39 @@ module.exports = class TurboServer
|
|
|
249
259
|
*/
|
|
250
260
|
|
|
251
261
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
252
|
-
get(path, ...callbacks){if(!cluster.isMaster) {this.__get_routes.push(new Route(path, RequestMethods.GET, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
262
|
+
get(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__get_routes.push(new Route(path, RequestMethods.GET, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
253
263
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
254
|
-
post(path, ...callbacks){if(!cluster.isMaster) {this.__post_routes.push(new Route(path, RequestMethods.POST, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
264
|
+
post(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__post_routes.push(new Route(path, RequestMethods.POST, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
255
265
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
256
|
-
put(path, ...callbacks){if(!cluster.isMaster) {this.__put_routes.push(new Route(path, RequestMethods.PUT, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
266
|
+
put(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__put_routes.push(new Route(path, RequestMethods.PUT, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
257
267
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
258
|
-
delete(path, ...callbacks){if(!cluster.isMaster) {this.__delete_routes.push(new Route(path, RequestMethods.DELETE, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
268
|
+
delete(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__delete_routes.push(new Route(path, RequestMethods.DELETE, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
259
269
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
260
|
-
head(path, ...callbacks){if(!cluster.isMaster) {this.__head_routes.push(new Route(path, RequestMethods.HEAD, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
270
|
+
head(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__head_routes.push(new Route(path, RequestMethods.HEAD, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
261
271
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
262
|
-
patch(path, ...callbacks){if(!cluster.isMaster) {this.__patch_routes.push(new Route(path, RequestMethods.PATCH, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
272
|
+
patch(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__patch_routes.push(new Route(path, RequestMethods.PATCH, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
263
273
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
264
|
-
options(path, ...callbacks){if(!cluster.isMaster) {this.__options_routes.push(new Route(path, RequestMethods.OPTIONS, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
274
|
+
options(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__options_routes.push(new Route(path, RequestMethods.OPTIONS, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
265
275
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
266
|
-
link(path, ...callbacks){if(!cluster.isMaster) {this.__link_routes.push(new Route(path, RequestMethods.LINK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
276
|
+
link(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__link_routes.push(new Route(path, RequestMethods.LINK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
267
277
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
268
|
-
unlink(path, ...callbacks){if(!cluster.isMaster) {this.__unlink_routes.push(new Route(path, RequestMethods.UNLINK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
278
|
+
unlink(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__unlink_routes.push(new Route(path, RequestMethods.UNLINK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
269
279
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
270
|
-
view(path, ...callbacks){if(!cluster.isMaster) {this.__view_routes.push(new Route(path, RequestMethods.VIEW, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
280
|
+
view(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__view_routes.push(new Route(path, RequestMethods.VIEW, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
271
281
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
272
|
-
lock(path, ...callbacks){if(!cluster.isMaster) {this.__lock_routes.push(new Route(path, RequestMethods.LOCK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
282
|
+
lock(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__lock_routes.push(new Route(path, RequestMethods.LOCK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
273
283
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
274
|
-
unlock(path, ...callbacks){if(!cluster.isMaster) {this.__unlock_routes.push(new Route(path, RequestMethods.UNLOCK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
284
|
+
unlock(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__unlock_routes.push(new Route(path, RequestMethods.UNLOCK, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
275
285
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
276
|
-
copy(path, ...callbacks){if(!cluster.isMaster) {this.__copy_routes.push(new Route(path, RequestMethods.COPY, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
286
|
+
copy(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__copy_routes.push(new Route(path, RequestMethods.COPY, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
277
287
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
278
|
-
purge(path, ...callbacks){if(!cluster.isMaster) {this.__purge_routes.push(new Route(path, RequestMethods.PURGE, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
288
|
+
purge(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__purge_routes.push(new Route(path, RequestMethods.PURGE, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
279
289
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
280
|
-
propfind(path, ...callbacks){if(!cluster.isMaster) {this.__propfind_routes.push(new Route(path, RequestMethods.PROPFIND, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
290
|
+
propfind(path, ...callbacks){if(!cluster.isMaster || this.useClusters === false) {this.__propfind_routes.push(new Route(path, RequestMethods.PROPFIND, callbacks, this.__middlewares_begin, this.__middlewares_end));}}
|
|
281
291
|
|
|
282
292
|
/** @param {String} path; @param {TurboExpressCallback[]} callbacks */
|
|
283
293
|
all(path, ...callbacks){
|
|
284
|
-
if(!cluster.isMaster) {
|
|
294
|
+
if(!cluster.isMaster || this.useClusters === false) {
|
|
285
295
|
const rMethods = new RequestMethods();
|
|
286
296
|
rMethods.forEach((m) => this[`__${m}_routes`].push(new Route(path, m, callbacks, this.__middlewares_begin, this.__middlewares_end)));
|
|
287
297
|
}
|
|
@@ -353,8 +363,8 @@ module.exports = class TurboServer
|
|
|
353
363
|
listen (port, cb)
|
|
354
364
|
{
|
|
355
365
|
/** will listen not on master cluster ... */
|
|
356
|
-
if(!cluster.isMaster) {
|
|
357
|
-
this.#server.listen(port, cb
|
|
366
|
+
if(!cluster.isMaster || this.useClusters === false) {
|
|
367
|
+
this.#server.listen(port, cb || (() => console.log("server is running " + port)))
|
|
358
368
|
}
|
|
359
369
|
}
|
|
360
370
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turbo-express-js",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "Turbo Express JS - Performance, Security, Easy-to-use Web Server Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"lib": "lib"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"cors": "nodemon samples/cors.test.js",
|
|
21
21
|
"validation_override": "nodemon samples/validation_override.test.js"
|
|
22
22
|
},
|
|
23
|
+
"types": "index.d.ts",
|
|
23
24
|
"repository": {
|
|
24
25
|
"type": "git",
|
|
25
26
|
"url": "git+https://github.com/breathfunwithmindte/turbo-express.git"
|
|
@@ -27,16 +28,20 @@
|
|
|
27
28
|
"keywords": [
|
|
28
29
|
"web",
|
|
29
30
|
"server",
|
|
30
|
-
"
|
|
31
|
+
"framework",
|
|
31
32
|
"lightweight",
|
|
32
33
|
"minimalistic",
|
|
33
34
|
"superfast",
|
|
34
|
-
"fast"
|
|
35
|
+
"fast",
|
|
36
|
+
"nodejs",
|
|
37
|
+
"express",
|
|
38
|
+
"turbo",
|
|
39
|
+
"turbo-express"
|
|
35
40
|
],
|
|
36
41
|
"author": "Mike Karypidis",
|
|
37
42
|
"license": "MIT",
|
|
38
43
|
"bugs": {
|
|
39
44
|
"url": "https://github.com/breathfunwithmindte/turbo-express/issues"
|
|
40
45
|
},
|
|
41
|
-
"homepage": "https://github.com/
|
|
46
|
+
"homepage": "https://github.com/mikekarypidis/turbo-express-js"
|
|
42
47
|
}
|