Skip to content

Commit 5aefcee

Browse files
committed
📌 Nodepp | Bug Fixing | V1.3.2 📌
1 parent 7cbc6b4 commit 5aefcee

39 files changed

+1010
-638
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
image.jpg
12
main.exe
23
main

README.md

Lines changed: 49 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,36 @@
55
[![Platform](https://img.shields.io/badge/platform-%20Linux%20|%20Windows%20|%20Mac%20|%20Android%20|%20IOS%20-blue)](https://github.com/NodeppOfficial/nodepp)
66
[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
Nodepp is a groundbreaking open-source project that simplifies C++ application development by bridging the gap between the language's raw power and the developer-friendly abstractions of Node.js. By providing a high-level API, Nodepp empowers developers to write C++ code in a familiar, Node.js-inspired style.
8+
Nodepp is a groundbreaking C++ framework that bridges the gap between the language's raw performance and the developer-friendly abstractions of Node.js. By providing a high-level, asynchronous API, Nodepp empowers you to write C++ with a familiar syntax—enabling seamless development across cloud servers, desktop apps, and microcontrollers.
99

10-
One of the standout features of Nodepp is its 100% asynchronous architecture, powered by an internal Event Loop. This design efficiently manages Nodepp’s tasks, enabling you to develop scalable and concurrent applications with minimal code. Experience the power and flexibility of Nodepp as you streamline your development process and create robust applications effortlessly!
10+
At its core, Nodepp features a 100% asynchronous architecture powered by an internal Event Loop. This allows for massive concurrency and scalable task management with minimal code complexity, effectively bringing the "Write Once, Run Everywhere" philosophy to the world of high-performance C++.
1111

1212
🔗: [Nodepp The MOST Powerful Framework for Asynchronous Programming in C++](https://medium.com/p/c01b84eee67a)
1313

14+
## 💡 Featured Project: Asynchronous Enigma Machine
15+
16+
To showcase [Nodepp for Arduino](https://github.com/NodeppOfficial/nodepp-arduino) efficiency on "bare metal" hardware, we implemented a fully functional Enigma Machine on an Arduino Nano.
17+
18+
- **Responsive I/O:** handle 16x2 LCD updates smoothly while encrypting enigma code in the background.
19+
- **Zero-Delay Logic:** Real-time 10x4 keypad scanning and rotor substitution without a single `delay()` call.
20+
- **Memory Mastery:** Runs sophisticated multi-tasking logic on only 2KB of RAM using Nodepp’s Zero-Copy primitives ( `ptr_t` and `queue_t` ).
21+
22+
https://github.com/user-attachments/assets/9b870671-3854-444f-893d-40fdce31a629
23+
24+
Try it now: [Enigma Machine Simulation](https://wokwi.com/projects/449104127751150593)
25+
26+
## 💡 Featured Project: Duck Hunt VR (WASM Edition)
27+
28+
To showcase [Nodepp for Web](https://github.com/NodeppOfficial/nodepp-wasm), we ported the classic Duck Hunt to Virtual Reality, running natively in the browser via WebAssembly. This project pushes the limits of web-based VR by combining low-level C++ performance with modern Web APIs.
29+
30+
- **Hand Tracking:** Integrated ARToolKitJS to detect physical DIY cardboard markers as a virtual zapper.
31+
- **Web Gyroscope:** Asynchronous event loop provides smooth 360° head tracking via the Web Gyroscope API.
32+
- **High Performance:** Native C++ performance compiled to WASM.
33+
34+
https://github.com/user-attachments/assets/ab26287e-bd73-4ee8-941b-d97382e203c9
35+
36+
Play it now: [Duck Hunt VR on Itch.io](https://edbcrepo.itch.io/duck-hunt-vr)
37+
1438
## Dependencies & Cmake Integration
1539
```bash
1640
# Openssl
@@ -40,8 +64,9 @@ target_link_libraries( #[...]
4064

4165
## Features
4266

43-
- 📌: **Node.js-like API:** Write C++ code in a syntax and structure similar to Node.js, making it easier to learn and use.
44-
- 📌: **High-performance:** Leverage the speed and efficiency of C++ for demanding applications.
67+
- 📌: **Lightweight:** Minimal dependencies, making it ideal for IoT and embedded systems.
68+
- 📌: **Cross-Platform:** Write once, run on Linux, Windows, Mac, Android, WASM and Arduino/ESP32.
69+
- 📌: **Memory Efficient:** Custom `ptr_t`, `queue_t`, `array_t` and `string_t` primitives provide SSO (Small Stack Optimization) and zero-copy slicing.
4570
- 📌: **Scalability:** Build applications that can handle large workloads and grow with your needs.
4671
- 📌: **Open-source:** Contribute to the project's development and customize it to your specific requirements.
4772

@@ -60,98 +85,28 @@ Check out some articles on [Medium](https://medium.com/@EDBCBlog)
6085

6186
## Batteries Included
6287

63-
- 📌: Include a **build-in JSON** parser / stringify system.
64-
- 📌: Include a **build-in RegExp** engine for processing text strings.
65-
- 📌: Include support for **UTF** manipulation | **UTF8 - UTF16 - UTF32**
66-
- 📌: Include a **build-in System** that make every object **Async Task** safety.
67-
- 📌: Include a **Smart Pointer** base **Garbage Collector** to avoid **Memory Leaks**.
68-
- 📌: Include support for **Reactive Programming** based on **Events** and **Observers**.
69-
- 📌: Include an **Event Loop** that can handle multiple events and tasks on a single thread.
70-
- 📌: Include support for **TCP | TLS | UDP | HTTP | WS** making it easy to create networked applications.
71-
- 📌: Include support for **Poll | Epoll | Kqueue | WSAPoll** making it easy to handle multiple file descriptors.
72-
- 📌: Include support for **Worker isolated event-loop** making it easy to create distributed self-contained event-loops.
73-
74-
## Build & Run
75-
```bash
76-
🐧: g++ -o main main.cpp -O3 -I ./include ; ./main
77-
🪟: g++ -o main main.cpp -O3 -I ./include -lws2_32 ; ./main
78-
```
79-
80-
## Test Unit
81-
```bash
82-
🐧: ( cd ./test; g++ -o main main.cpp -I../include -lssl -lcrypto -lpthread ; ./main )
83-
🪟: ( cd ./test; g++ -o main main.cpp -I../include -lssl -lcrypto -lws2_32 ; ./main )
84-
```
85-
86-
## Examples
87-
88-
### Reading JSON
89-
```cpp
90-
#include <nodepp/nodepp.h>
91-
#include <nodepp/json.h>
92-
93-
using namespace nodepp;
94-
95-
void onMain() {
96-
97-
auto data = json::parse( R"({
98-
"var1": 10,
99-
"var2": false,
100-
"var3": "hello world",
101-
"var4": { "var5": "nested object" },
102-
"var5": [ 10, 20, 30, 40, 50, 60, 70 ]
103-
})" );
88+
- 📌: UTF Support: Comprehensive manipulation for UTF8, UTF16, and UTF32.
89+
- 📌: Networking: Native support for TCP, TLS, UDP, HTTP, and WebSockets.
90+
- 📌: Built-in JSON & RegExp: Full parsing and text processing engines.
91+
- 📌: I/O Multiplexing: Support for Poll, Epoll, Kqueue, and WSAPoll.
92+
- 📌: Reactive Programming: Built-in Events and Observers system.
10493

105-
console::log( "var1:", data["var1"].as<uint>() );
106-
console::log( "var2:", data["var2"].as<bool>() );
107-
console::log( "var3:", data["var3"].as<string_t>() );
108-
console::log( "var4:", data["var4"]["var5"].as<string_t>() );
94+
## Quick Start
10995

110-
console::log( "\n --- \n" );
111-
112-
for( auto x: data["var5"].as<array_t<object_t>>() ){
113-
console::log( "var5", x.as<uint>() );
114-
}
115-
116-
}
96+
### Clone The Repository
97+
```bash
98+
#!/usr/bin/env bash
99+
git clone https://github.com/NodeppOfficial/nodepp ; cd nodepp
117100
```
118101

119-
### HTTP Client
120-
```cpp
121-
//#pragma comment(lib, "Ws2_32.lib") msvc compiler
122-
123-
#include <nodepp/nodepp.h>
124-
#include <nodepp/http.h>
125-
126-
using namespace nodepp;
127-
128-
void onMain(){
129-
130-
fetch_t args;
131-
args.method = "GET";
132-
args.url = "http://www.google.com/";
133-
args.headers = header_t({
134-
{ "Host", url::host(args.url) }
135-
});
136-
137-
http::fetch( args )
138-
139-
.then([]( http_t cli ){
140-
console::log( stream::await( cli ) );
141-
})
142-
143-
.fail([]( except_t err ){
144-
console::error( err );
145-
});
146-
147-
}
102+
### Create a main.cpp File
103+
```bash
104+
#!/usr/bin/env bash
105+
touch main.cpp
148106
```
149-
150-
### HTTP Server
151107
```cpp
152-
//#pragma comment(lib, "Ws2_32.lib") msvc compiler
153-
154108
#include <nodepp/nodepp.h>
109+
#include <nodepp/regex.h>
155110
#include <nodepp/http.h>
156111
#include <nodepp/date.h>
157112

@@ -161,14 +116,14 @@ void onMain(){
161116

162117
auto server = http::server([=]( http_t cli ){
163118

164-
console::log( cli.path, cli.get_fd() );
165-
166119
cli.write_header( 200, header_t({
167120
{ "content-type", "text/html" }
168121
}));
169122

170-
cli.write( date::fulltime() );
171-
cli.close(); // optional
123+
cli.write( regex::format( R"(
124+
<h1> Hello World </h1>
125+
<h2> ${0} </h2>
126+
)", date::fulltime() ));
172127

173128
});
174129

@@ -179,72 +134,6 @@ void onMain(){
179134
}
180135
```
181136

182-
### Worker Isolated Event-Loop
183-
```cpp
184-
#include <nodepp/nodepp.h>
185-
#include <nodepp/worker.h>
186-
#include <nodepp/os.h>
187-
188-
using namespace nodepp;
189-
190-
atomic_t<int> shared_variable = 100;
191-
192-
void worker_main( int cpu_id ){
193-
194-
// this event-loop runs in it's own isolated worker-thread
195-
196-
process::add( coroutine::add( COROUTINE(){
197-
thread_local static int variable;
198-
// this will create a static variable per thread
199-
static atomic_t<int> shared_variable;
200-
// this will create a shared global variable
201-
int local_variable;
202-
// this is a normal variable only exists here
203-
coBegin
204-
205-
while( shared_variable-->0 ){
206-
console::log( cpu_id, "->", shared_variable.get() );
207-
coDelay(1000); }
208-
209-
coFinish
210-
}));
211-
212-
}
213-
214-
void onMain(){
215-
216-
for( auto x=os::cpus(); x-->0; ){ worker::add([=](){
217-
worker_main( x ); process::wait();
218-
return -1; }); }
219-
220-
}
221-
```
222-
223-
### More Examples [here](https://nodeppofficial.github.io/nodepp-doc/guide.html)
224-
225-
## Installing Nodepp
226-
227-
### Clone The Repository
228-
```bash
229-
#!/usr/bin/env bash
230-
git clone https://github.com/NodeppOfficial/nodepp ; cd nodepp
231-
```
232-
233-
### Create a main.cpp File
234-
```bash
235-
#!/usr/bin/env bash
236-
touch main.cpp
237-
```
238-
```cpp
239-
#include <nodepp/nodepp.h>
240-
241-
using namespace nodepp;
242-
243-
void onMain() {
244-
console::log("Hello World!");
245-
}
246-
```
247-
248137
### Build Your Code
249138
```bash
250139
#!/usr/bin/env bash
@@ -257,7 +146,7 @@ void onMain() {
257146
- 🔗: [NodePP for Arduino](https://github.com/NodeppOfficial/nodepp-arduino)
258147
- 🔗: [Nodepp for WASM](https://github.com/NodeppOfficial/nodepp-wasm)
259148

260-
## Official Libraries for Nodepp
149+
## Ecosystem
261150
- 🔗: [ExpressPP](https://github.com/NodeppOfficial/nodepp-express) -> Express equivalent for Nodepp
262151
- 🔗: [ApifyPP](https://github.com/NodeppOfficial/nodepp-apify) -> Socket.io equivalent for Nodepp
263152
- 🔗: [Bluetooth](https://github.com/NodeppOfficial/nodepp-bluetooth) -> Bluetooth Port for Nodepp

examples/0-Terminal_Color.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
using namespace nodepp;
44

5-
void onMain() {
5+
void onMain(){
66

7-
conio::background( conio::color::cyan | conio::color::bold );
8-
console::log( "hello world!" );
9-
conio::reset();
10-
11-
conio::foreground( conio::color::red | conio::color::bold );
12-
console::log( "hello world!" );
13-
conio::reset();
14-
15-
conio::background( conio::color::magenta | conio::color::bold );
16-
console::log( "hello world!" );
17-
conio::reset();
18-
19-
conio::foreground( conio::color::blue | conio::color::bold );
20-
console::log( "hello world!" );
21-
conio::reset();
22-
23-
conio::background( conio::color::yellow | conio::color::bold );
24-
console::log( "hello world!" );
25-
conio::reset();
26-
277
conio::foreground( conio::color::green | conio::color::bold );
28-
console::log( "hello world!" );
29-
conio::reset();
8+
conio::log(" Hello World! \n");
9+
10+
conio::foreground( conio::color::red | conio::color::bold );
11+
conio::log(" Hello World! \n");
12+
13+
conio::foreground( conio::color::yellow | conio::color::bold );
14+
conio::log(" Hello World! \n");
15+
16+
conio::foreground( conio::color::cyan | conio::color::bold );
17+
conio::log(" Hello World! \n");
18+
19+
conio::foreground( conio::color::magenta | conio::color::bold );
20+
conio::log(" Hello World! \n");
21+
22+
conio::foreground( conio::color::white | conio::color::bold );
23+
conio::log(" Hello World! \n");
24+
25+
conio::foreground( conio::color::black | conio::color::bold );
26+
conio::background( conio::color::white );
27+
conio::log(" Hello World! \n");
28+
29+
conio::log(" Hello World! \n");
3030

3131
}

examples/14-Event.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ void onMain(){
1212
ev.on([](){ console::done(" World 1 "); });
1313

1414
// create an event that can be emitted once
15-
ev.on([](){ console::done(" hello "); });
15+
ev.once([](){ console::done(" hello "); });
1616

1717
// Emit Events
1818
ev.emit();
1919
console::log( "->", ev.size() );
2020

21-
// Clear Even Queue
21+
// Clear Event Queue
2222
ev.clear();
2323

24-
// turn of an specific event
24+
// turn off an specific event
2525
auto item = ev.on([](){
26-
console::log("me cago en la puta");
26+
console::log("hello world!");
2727
});
2828
console::log( "->", ev.size() );
2929

examples/17-Date.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ void onMain() {
77

88
auto time1 = date_t( 2025, 7, 9, false );
99
auto time2 = date_t( 2025, 7, 19, false );
10-
auto time3 = date2 - date1;
10+
auto time3 = time2 - time1;
1111

1212
console::log( "days left:", time3.get_day() );
1313

14-
}
14+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <nodepp/nodepp.h>
2+
#include <nodepp/https.h>
3+
4+
using namespace nodepp;
5+
6+
void onMain(){
7+
8+
ssl_t ssl; // ( "./ssl/cert.key", "./ssl/cert.crt" );
9+
10+
fetch_t args;
11+
args.method = "GET";
12+
args.url = "https://www.wearegecko.co.uk/media/50316/mountain-3.jpg";
13+
args.headers = header_t({
14+
{ "Host", url::host(args.url) }
15+
});
16+
17+
// args.file = file_t("PATH","r");
18+
// args.body = "MYBODY";
19+
20+
https::fetch( args, &ssl )
21+
22+
.then([]( https_t cli ){
23+
cli.onDrain([](){ console::log( "done" ); });
24+
file_t file ( "image.jpg", "w" );
25+
stream::pipe( cli, file );
26+
})
27+
28+
.fail([]( except_t err ){
29+
console::error( err );
30+
});
31+
32+
}

0 commit comments

Comments
 (0)