corecdtl 0.1.4 → 0.1.6
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/binding.gyp +12 -13
- package/dist/http/context/WebContext.js +9 -2
- package/dist/hypernode.js +2 -2
- package/native/http/core/http_core.cpp +1 -1
- package/native/http/core/http_scanner.cpp +3 -2
- package/native/http/routes/route_matching.cpp +0 -1
- package/package.json +13 -12
- package/CMakeLists.txt +0 -47
package/binding.gyp
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
"targets": [
|
|
3
3
|
{
|
|
4
4
|
"target_name": "hypernode",
|
|
5
|
-
|
|
6
5
|
"sources": [
|
|
7
6
|
"native/main.cpp",
|
|
8
|
-
"native/http/core
|
|
9
|
-
"native/http/routes
|
|
10
|
-
"native/http/parser
|
|
11
|
-
"native/http/cpool
|
|
7
|
+
"<!@(node -p \"require('fs').readdirSync('native/http/core').filter(f => f.endsWith('.cpp')).map(f => 'native/http/core/' + f).join(' ')\")",
|
|
8
|
+
"<!@(node -p \"require('fs').readdirSync('native/http/routes').filter(f => f.endsWith('.cpp')).map(f => 'native/http/routes/' + f).join(' ')\")",
|
|
9
|
+
"<!@(node -p \"require('fs').readdirSync('native/http/parser').filter(f => f.endsWith('.cpp')).map(f => 'native/http/parser/' + f).join(' ')\")",
|
|
10
|
+
"<!@(node -p \"require('fs').readdirSync('native/http/cpool').filter(f => f.endsWith('.cpp')).map(f => 'native/http/cpool/' + f).join(' ')\")"
|
|
12
11
|
],
|
|
13
|
-
|
|
14
12
|
"include_dirs": [
|
|
15
13
|
"<!@(node -p \"require('node-addon-api').include\")",
|
|
16
14
|
"native/include",
|
|
@@ -18,26 +16,27 @@
|
|
|
18
16
|
"native/http/routes",
|
|
19
17
|
"native/http/parser",
|
|
20
18
|
"native/http/cpool",
|
|
21
|
-
"native/third_party/simdjson"
|
|
22
19
|
],
|
|
23
|
-
|
|
24
20
|
"dependencies": [
|
|
25
21
|
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
26
22
|
],
|
|
27
|
-
|
|
28
23
|
"defines": [
|
|
29
24
|
"NAPI_VERSION=3",
|
|
30
25
|
"NAPI_CPP_EXCEPTIONS"
|
|
31
26
|
],
|
|
32
|
-
|
|
33
27
|
"cflags_cc": [
|
|
34
28
|
"-std=c++14",
|
|
35
29
|
"-fexceptions"
|
|
36
30
|
],
|
|
37
|
-
|
|
38
31
|
"xcode_settings": {
|
|
39
|
-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
|
|
32
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD": "c++14"
|
|
34
|
+
},
|
|
35
|
+
"msvs_settings": {
|
|
36
|
+
"VCCLCompilerTool": {
|
|
37
|
+
"ExceptionHandling": 1
|
|
38
|
+
}
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
]
|
|
43
|
-
}
|
|
42
|
+
}
|
|
@@ -152,7 +152,7 @@ class WebContext extends HttpContext_1.default {
|
|
|
152
152
|
this.spaRouteDefinationFn = (socket, p, routeId, _) => {
|
|
153
153
|
p.free();
|
|
154
154
|
socket.write(this.spaRespBuffer);
|
|
155
|
-
socket.end();
|
|
155
|
+
// socket.end();
|
|
156
156
|
};
|
|
157
157
|
this.dynamicRouteDefinationFn = (socket, p, routeId, chunk) => {
|
|
158
158
|
p.rawBuf = chunk;
|
|
@@ -192,7 +192,14 @@ class WebContext extends HttpContext_1.default {
|
|
|
192
192
|
this.assetParser = new hypernode_1.hypernode.PublicAssetParser();
|
|
193
193
|
this.assetParser.setAssetRoute(this.publicStaticRoute);
|
|
194
194
|
this.spaRootPath = ctxOpts?.spaRootPath == undefined ? "dist/index.html" : ctxOpts.spaRootPath;
|
|
195
|
-
|
|
195
|
+
let _data;
|
|
196
|
+
try {
|
|
197
|
+
_data = fs_1.default.readFileSync(this.spaRootPath);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
console.error(error);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
196
203
|
const __resp = Buffer.from("HTTP/1.1 200 OK\r\n" +
|
|
197
204
|
"Content-Type: text/html; charset=utf-8\r\n" +
|
|
198
205
|
"Content-Length: " + _data.length + "\r\n" +
|
package/dist/hypernode.js
CHANGED
|
@@ -4,5 +4,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.hypernode = void 0;
|
|
7
|
-
const
|
|
8
|
-
exports.hypernode = (
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
exports.hypernode = require(path_1.default.join(__dirname, "../build/Release/hypernode.node"));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include <route.h>
|
|
3
3
|
#include "http_scanner.h"
|
|
4
4
|
#include <cpool.h>
|
|
5
|
+
#include <iostream>
|
|
5
6
|
|
|
6
7
|
#include <string>
|
|
7
8
|
#include <napi.h>
|
|
@@ -387,7 +388,6 @@ Napi::Value HttpCore::PrintRouteTree(const Napi::CallbackInfo& info) {
|
|
|
387
388
|
default:
|
|
388
389
|
break;
|
|
389
390
|
}
|
|
390
|
-
std::cout << methodName << "\n";
|
|
391
391
|
RouteBuilder::printRouteTree(this->m_httpRouteMaps[i].route_node, deepth);
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -93,7 +93,7 @@ enum State {
|
|
|
93
93
|
ST_HN_L,
|
|
94
94
|
ST_HN_O,
|
|
95
95
|
ST_HN_P,
|
|
96
|
-
ST_HN_R,
|
|
96
|
+
// ST_HN_R,
|
|
97
97
|
ST_HN_S,
|
|
98
98
|
ST_HN_T,
|
|
99
99
|
ST_HN_U,
|
|
@@ -224,7 +224,6 @@ FlagBits scanHeaders(
|
|
|
224
224
|
while (true) {
|
|
225
225
|
if (__offset >= total && state != ST_HV_CONCAT)
|
|
226
226
|
break;
|
|
227
|
-
|
|
228
227
|
switch (state) {
|
|
229
228
|
|
|
230
229
|
// ================= STARTUP =================
|
|
@@ -269,11 +268,13 @@ FlagBits scanHeaders(
|
|
|
269
268
|
__offset++;
|
|
270
269
|
state = ST_HN_P;
|
|
271
270
|
continue;
|
|
271
|
+
/*
|
|
272
272
|
case 'r': case 'R':
|
|
273
273
|
vStart = __offset;
|
|
274
274
|
__offset++;
|
|
275
275
|
state = ST_HN_R;
|
|
276
276
|
continue;
|
|
277
|
+
*/
|
|
277
278
|
case 's': case 'S':
|
|
278
279
|
vStart = __offset;
|
|
279
280
|
__offset++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corecdtl",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "High-performance customizable HTTP engine",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,11 +16,13 @@
|
|
|
16
16
|
"low-level"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
20
|
-
"rebuild": "
|
|
19
|
+
"build": "node-gyp rebuild && rm -rf dist && tsc",
|
|
20
|
+
"rebuild": "node-gyp rebuild --clean && rm -rf dist && tsc",
|
|
21
21
|
"test": "vitest run",
|
|
22
22
|
"benchmark": "node benchmark/e2e/run.js",
|
|
23
|
-
"prepublishOnly": "npm run build"
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"example": "node example/server.js",
|
|
25
|
+
"example:web": "node example/server.web.js"
|
|
24
26
|
},
|
|
25
27
|
"files": [
|
|
26
28
|
"dist",
|
|
@@ -31,20 +33,19 @@
|
|
|
31
33
|
"LICENSE"
|
|
32
34
|
],
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"node-addon-api": "^8.5.0"
|
|
35
|
-
"bindings": "^1.5.0"
|
|
36
|
+
"node-addon-api": "^8.5.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
+
"@fastify/express": "^4.0.4",
|
|
39
40
|
"@types/bindings": "^1.5.5",
|
|
40
|
-
"
|
|
41
|
-
"ts-node": "^10.9.2",
|
|
42
|
-
"vitest": "^3.2.4",
|
|
43
|
-
"cmake-js": "^7.3.1",
|
|
41
|
+
"@types/node": "^24.8.1",
|
|
44
42
|
"autocannon": "^8.0.0",
|
|
43
|
+
"cmake-js": "^7.3.1",
|
|
45
44
|
"express": "^5.2.1",
|
|
46
45
|
"fastify": "^5.6.2",
|
|
47
|
-
"
|
|
46
|
+
"ts-node": "^10.9.2",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^3.2.4"
|
|
48
49
|
},
|
|
49
50
|
"repository": {
|
|
50
51
|
"type": "git",
|
package/CMakeLists.txt
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.9)
|
|
2
|
-
cmake_policy(SET CMP0042 NEW)
|
|
3
|
-
set (CMAKE_CXX_STANDARD 14)
|
|
4
|
-
if(NOT CMAKE_BUILD_TYPE)
|
|
5
|
-
set(CMAKE_BUILD_TYPE Release)
|
|
6
|
-
endif()
|
|
7
|
-
|
|
8
|
-
project(hypernode)
|
|
9
|
-
include_directories(${CMAKE_JS_INC})
|
|
10
|
-
include_directories(
|
|
11
|
-
${CMAKE_SOURCE_DIR}/native/include
|
|
12
|
-
${CMAKE_SOURCE_DIR}/native/http/core
|
|
13
|
-
${CMAKE_SOURCE_DIR}/native/http/routes
|
|
14
|
-
${CMAKE_SOURCE_DIR}/native/http/parser
|
|
15
|
-
${CMAKE_SOURCE_DIR}/native/http/cpool
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
file(GLOB MAIN_SOURCE "native/main.cpp")
|
|
20
|
-
file(GLOB HTTP_SOURCES "native/http/core/*.cpp")
|
|
21
|
-
file(GLOB ROUTE_BUILDER_SOURCES "native/http/routes/*.cpp")
|
|
22
|
-
file(GLOB CHUNK_PROGRESSION_POOL_SOURCES "native/http/cpool/*.cpp")
|
|
23
|
-
file(GLOB PARSER_SOURCES "native/http/parser/*.cpp")
|
|
24
|
-
|
|
25
|
-
add_library(${PROJECT_NAME} SHARED
|
|
26
|
-
${MAIN_SOURCE}
|
|
27
|
-
${ROUTE_BUILDER_SOURCES}
|
|
28
|
-
${CHUNK_PROGRESSION_POOL_SOURCES}
|
|
29
|
-
${PARSER_SOURCES}
|
|
30
|
-
${HTTP_SOURCES}
|
|
31
|
-
${CMAKE_JS_SRC}
|
|
32
|
-
)
|
|
33
|
-
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
34
|
-
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
|
|
35
|
-
|
|
36
|
-
# Include N-API wrappers
|
|
37
|
-
execute_process(
|
|
38
|
-
COMMAND node -p "require('node-addon-api').include"
|
|
39
|
-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
40
|
-
OUTPUT_VARIABLE NODE_ADDON_API_DIR
|
|
41
|
-
)
|
|
42
|
-
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
|
|
43
|
-
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
|
|
44
|
-
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
|
|
45
|
-
|
|
46
|
-
# define NAPI_VERSION
|
|
47
|
-
add_definitions(-DNAPI_VERSION=3)
|