corecdtl 0.1.3 → 0.1.5
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 +10 -2
- package/dist/hypernode.js +2 -2
- package/native/http/core/http_core.cpp +1 -0
- package/native/http/core/http_scanner.cpp +4 -2
- package/native/http/routes/route_matching.cpp +0 -1
- package/package.json +12 -11
- 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
|
+
}
|
|
@@ -71,6 +71,7 @@ class WebContext extends HttpContext_1.default {
|
|
|
71
71
|
this.contentTypeParsers = parser_1.contentParserTable;
|
|
72
72
|
this.parseInitial = (socket, chunk, p) => {
|
|
73
73
|
const routeId = this.httpCore.scannerRouteFirst(chunk, p, this.state.maxHeaderNameSize, this.state.maxHeaderValueSize, this.state.maxContentSize, this.state.requestQuerySize);
|
|
74
|
+
console.log(chunk.toString());
|
|
74
75
|
if (p.retFlag !== http_1.Http.RetFlagBits.FLAG_OK) {
|
|
75
76
|
switch (p.retFlag) {
|
|
76
77
|
// --- CORS 204 ---
|
|
@@ -152,7 +153,7 @@ class WebContext extends HttpContext_1.default {
|
|
|
152
153
|
this.spaRouteDefinationFn = (socket, p, routeId, _) => {
|
|
153
154
|
p.free();
|
|
154
155
|
socket.write(this.spaRespBuffer);
|
|
155
|
-
socket.end();
|
|
156
|
+
// socket.end();
|
|
156
157
|
};
|
|
157
158
|
this.dynamicRouteDefinationFn = (socket, p, routeId, chunk) => {
|
|
158
159
|
p.rawBuf = chunk;
|
|
@@ -192,7 +193,14 @@ class WebContext extends HttpContext_1.default {
|
|
|
192
193
|
this.assetParser = new hypernode_1.hypernode.PublicAssetParser();
|
|
193
194
|
this.assetParser.setAssetRoute(this.publicStaticRoute);
|
|
194
195
|
this.spaRootPath = ctxOpts?.spaRootPath == undefined ? "dist/index.html" : ctxOpts.spaRootPath;
|
|
195
|
-
|
|
196
|
+
let _data;
|
|
197
|
+
try {
|
|
198
|
+
_data = fs_1.default.readFileSync(this.spaRootPath);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
console.error(error);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
196
204
|
const __resp = Buffer.from("HTTP/1.1 200 OK\r\n" +
|
|
197
205
|
"Content-Type: text/html; charset=utf-8\r\n" +
|
|
198
206
|
"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"));
|
|
@@ -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,7 @@ FlagBits scanHeaders(
|
|
|
224
224
|
while (true) {
|
|
225
225
|
if (__offset >= total && state != ST_HV_CONCAT)
|
|
226
226
|
break;
|
|
227
|
-
|
|
227
|
+
std::cout << state << "\n";
|
|
228
228
|
switch (state) {
|
|
229
229
|
|
|
230
230
|
// ================= STARTUP =================
|
|
@@ -269,11 +269,13 @@ FlagBits scanHeaders(
|
|
|
269
269
|
__offset++;
|
|
270
270
|
state = ST_HN_P;
|
|
271
271
|
continue;
|
|
272
|
+
/*
|
|
272
273
|
case 'r': case 'R':
|
|
273
274
|
vStart = __offset;
|
|
274
275
|
__offset++;
|
|
275
276
|
state = ST_HN_R;
|
|
276
277
|
continue;
|
|
278
|
+
*/
|
|
277
279
|
case 's': case 'S':
|
|
278
280
|
vStart = __offset;
|
|
279
281
|
__offset++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corecdtl",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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",
|
|
@@ -34,17 +36,16 @@
|
|
|
34
36
|
"node-addon-api": "^8.5.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@
|
|
39
|
+
"@fastify/express": "^4.0.4",
|
|
38
40
|
"@types/bindings": "^1.5.5",
|
|
39
|
-
"
|
|
40
|
-
"ts-node": "^10.9.2",
|
|
41
|
-
"vitest": "^3.2.4",
|
|
42
|
-
"cmake-js": "^7.3.1",
|
|
41
|
+
"@types/node": "^24.8.1",
|
|
43
42
|
"autocannon": "^8.0.0",
|
|
44
|
-
"
|
|
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)
|