fulmine.js 5.0.0-rc.1
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/EXPRESS_LICENSE +26 -0
- package/LICENSE +202 -0
- package/NOTICE +38 -0
- package/README.md +469 -0
- package/package.json +165 -0
- package/src/application.js +561 -0
- package/src/cli.js +369 -0
- package/src/declarative.js +768 -0
- package/src/index.js +71 -0
- package/src/middlewares.js +636 -0
- package/src/node-shim.js +400 -0
- package/src/request.js +807 -0
- package/src/response.js +1360 -0
- package/src/router.js +1240 -0
- package/src/types.d.ts +62 -0
- package/src/utils.js +993 -0
- package/src/view.js +172 -0
- package/src/worker.js +38 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 dimden.dev
|
|
3
|
+
Copyright 2026 Nigro Simone
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// H3App, DeclarativeResponse and _cfg all exist at runtime but are missing from the
|
|
19
|
+
// declaration file the package ships, so the module is read through a loose alias
|
|
20
|
+
const uWS = require("uWebSockets.js");
|
|
21
|
+
const uWSAny = /** @type {any} */ (uWS);
|
|
22
|
+
const Application = require("./application.js");
|
|
23
|
+
const Router = require("./router.js");
|
|
24
|
+
const middlewares = require("./middlewares.js");
|
|
25
|
+
const Request = require("./request.js");
|
|
26
|
+
const Response = require("./response.js");
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// disable Uwebsockets header
|
|
30
|
+
uWSAny._cfg("999999990007");
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// older uWS builds do not expose _cfg; there is nothing to fall back to
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The factory doubles as a namespace, as in Express: Router, static and the body parsers hang off
|
|
36
|
+
// the function that creates an app.
|
|
37
|
+
//
|
|
38
|
+
// Written as `module.exports.name = ...` and never through an alias: cjs-module-lexer reads this
|
|
39
|
+
// file as text to decide which named exports an ESM importer gets, and it cannot see through one.
|
|
40
|
+
// Nothing here is executed to find that out.
|
|
41
|
+
/**
|
|
42
|
+
* @type {typeof Application & {
|
|
43
|
+
* Router: Function,
|
|
44
|
+
* request: object,
|
|
45
|
+
* response: object,
|
|
46
|
+
* application: object,
|
|
47
|
+
* static: Function,
|
|
48
|
+
* json: Function,
|
|
49
|
+
* urlencoded: Function,
|
|
50
|
+
* text: Function,
|
|
51
|
+
* raw: Function
|
|
52
|
+
* }}
|
|
53
|
+
*/
|
|
54
|
+
module.exports = /** @type {any} */ (Application);
|
|
55
|
+
|
|
56
|
+
// a router is a function too, for the same reason an app is: it has to be callable to be usable as
|
|
57
|
+
// middleware
|
|
58
|
+
module.exports.Router = function (options) {
|
|
59
|
+
return new Router(options)._asCallable();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports.request = Request.prototype;
|
|
63
|
+
module.exports.response = Response.prototype;
|
|
64
|
+
// the third of the trio: adding a method here adds it to every app, the same as express.application
|
|
65
|
+
module.exports.application = Application.Application.prototype;
|
|
66
|
+
|
|
67
|
+
module.exports.static = middlewares.static;
|
|
68
|
+
module.exports.json = middlewares.json;
|
|
69
|
+
module.exports.urlencoded = middlewares.urlencoded;
|
|
70
|
+
module.exports.text = middlewares.text;
|
|
71
|
+
module.exports.raw = middlewares.raw;
|