Skip to content

Commit 1c0556d

Browse files
committed
📌 Nodepp | Stable Release | V1.3.0 📌
1 parent fe9c8e4 commit 1c0556d

File tree

152 files changed

+3660
-1826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+3660
-1826
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Nodepp C++ Cross-Platform CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build_and_test:
11+
# 1. Define the runners for the matrix strategy
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
17+
# 2. Use the matrix variable to set the runner OS
18+
runs-on: ${{ matrix.os }}
19+
20+
steps:
21+
- name: ⬇️ Checkout code
22+
uses: actions/checkout@v4
23+
24+
# --- 🧪 Unit Test Compilation and Run ---
25+
26+
- name: 🧪 Unit Test (Linux/macOS)
27+
# Uses -lssl -lcrypto -lpthread flags
28+
if: runner.os != 'Windows'
29+
run: |
30+
echo "Running Unix-like Unit Test build..." ; cd ./test
31+
g++ -o main main.cpp -I../include -lpthread ; ./main
32+
33+
- name: 🧪 Unit Test (Windows)
34+
# Uses -lssl -lcrypto -lws2_32 flags
35+
if: runner.os == 'Windows'
36+
run: |
37+
echo "Running Windows Unit Test build..." ; cd ./test
38+
g++ -o main main.cpp -I../include -lws2_32; ./main.exe
39+
40+
# --- End of the workflow ---

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main.exe
2+
main

README.md

Lines changed: 83 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,36 @@ One of the standout features of Nodepp is its 100% asynchronous architecture, po
4747
```
4848

4949
## Examples
50-
### Hello world
50+
51+
### Reading JSON
5152
```cpp
5253
#include <nodepp/nodepp.h>
54+
#include <nodepp/json.h>
5355

5456
using namespace nodepp;
5557

56-
void onMain() {
57-
console::log("Hello World!");
58-
}
58+
void onMain() {
59+
60+
auto data = json::parse( R"({
61+
"var1": 10,
62+
"var2": false,
63+
"var3": "hello world",
64+
"var4": { "var5": "nested object" },
65+
"var5": [ 10, 20, 30, 40, 50, 60, 70 ]
66+
})" );
67+
68+
console::log( "var1:", data["var1"].as<uint>() );
69+
console::log( "var2:", data["var2"].as<bool>() );
70+
console::log( "var3:", data["var3"].as<string_t>() );
71+
console::log( "var4:", data["var4"]["var5"].as<string_t>() );
5972

60-
// note that we are using onMain() instead of main()
73+
console::log( "\n --- \n" );
74+
75+
for( auto x: data["var5"].as<array_t<object_t>>() ){
76+
console::log( "var5", x.as<uint>() );
77+
}
78+
79+
}
6180
```
6281

6382
### HTTP Client
@@ -103,16 +122,16 @@ using namespace nodepp;
103122

104123
void onMain(){
105124

106-
auto server = http::server([=]( http_t cli ){
125+
auto server = http::server([=]( http_t cli ){
107126

108127
console::log( cli.path, cli.get_fd() );
109-
128+
110129
cli.write_header( 200, header_t({
111130
{ "content-type", "text/html" }
112131
}));
113-
132+
114133
cli.write( date::fulltime() );
115-
cli.close(); // optional | GC automaticaly close unused sockets
134+
cli.close(); // optional
116135

117136
});
118137

@@ -123,9 +142,45 @@ void onMain(){
123142
}
124143
```
125144

126-
### More Examples [here](https://github.com/NodeppOfficial/Nodepp/tree/main/examples)
145+
### More Examples [here](https://nodeppofficial.github.io/nodepp-doc/guide.html)
146+
147+
## Installing Nodepp
148+
149+
### Clone The Repository
150+
```bash
151+
#!/usr/bin/env bash
152+
git clone https://github.com/NodeppOfficial/nodepp ; cd nodepp
153+
```
154+
155+
### Create a main.cpp File
156+
```bash
157+
#!/usr/bin/env bash
158+
touch main.cpp
159+
```
160+
```cpp
161+
#include <nodepp/nodepp.h>
162+
163+
using namespace nodepp;
164+
165+
void onMain() {
166+
console::log("Hello World!");
167+
}
168+
```
169+
170+
### Build Your Code
171+
```bash
172+
#!/usr/bin/env bash
173+
🐧: g++ -o main main.cpp -O3 -I ./include ; ./main #(Linux)
174+
🪟: g++ -o main main.cpp -O3 -I ./include -lws2_32 ; ./main #(Windows)
175+
```
176+
177+
## Nodepp Supports Other Platforms Too
178+
- 🔗: [NodePP for Window | Linux | Mac | Bsd ](https://github.com/NodeppOfficial/nodepp)
179+
- 🔗: [NodePP for Arduino](https://github.com/NodeppOfficial/nodepp-arduino)
180+
- 🔗: [Nodepp for WASM](https://github.com/NodeppOfficial/nodepp-wasm)
127181

128182
## Projects made with NodePP
183+
- 🔗: [Computer Vision VR Controllers for phones Demo](https://github.com/PocketVR/Barely_VR_AR_Controller_Test)
129184
- 🔗: [Draw on your PC using your smartphone](https://github.com/ScreenDraw/PCDraw)
130185
- 🔗: [Simple multiplayer Game With Raylib](https://medium.com/@EDBCBlog/create-your-own-online-multiplayer-small-fast-and-fun-with-raylib-nodepp-and-websockets-190f5c174094)
131186
- 🔗: [Cursed Luna - A simple Raylib Game](https://github.com/EDBCREPO/Space-Shocker)
@@ -136,26 +191,24 @@ void onMain(){
136191

137192
Check out some articles on [Medium](https://medium.com/@EDBCBlog)
138193

139-
## Compatibility
140-
- 🔗: [NodePP for Window | Linux | Mac | Bsd ](https://github.com/NodeppOfficial/nodepp)
141-
- 🔗: [NodePP for Arduino](https://github.com/NodeppOfficial/nodepp-arduino)
142-
- 🔗: [Nodepp for WASM](https://github.com/NodeppOfficial/nodepp-wasm)
143-
144194
## Official Libraries for Nodepp
145-
- 🔗: [ExpressPP](https://github.com/NodeppOfficial/nodepp-express) -> Express equivalent for Nodepp
146-
- 🔗: [ApifyPP](https://github.com/NodeppOfficial/nodepp-apify) -> Socket.io equivalent for Nodepp
147-
- 🔗: [SerialPP](https://github.com/NodeppOfficial/nodepp-serial) -> Serial Port for Nodepp
148-
- 🔗: [Argon2](https://github.com/NodeppOfficial/nodepp-argon2) -> Argon2 for Nodepp
149-
- 🔗: [Torify](https://github.com/NodeppOfficial/nodepp-torify) -> HTTP|Ws over Tor
150-
- 🔗: [NginxPP](https://github.com/NodeppOfficial/nodepp-nginx) -> Reverse Proxy
151-
- 🔗: [InputPP](https://github.com/NodeppOfficial/nodepp-input) -> Fake Inputs
152-
- 🔗: [JWT](https://github.com/NodeppOfficial/nodepp-jwt) -> JSON Web Token
153-
- 🔗: [NmapPP](https://github.com/NodeppOfficial/nodepp-nmap) -> Scan IPs and Ports
154-
- 🔗: [Redis](https://github.com/NodeppOfficial/nodepp-redis) -> Redis Client for Nodepp
155-
- 🔗: [Sqlite](https://github.com/NodeppOfficial/nodepp-sqlite) -> Sqlite Client for Nodepp
156-
- 🔗: [MariaDB](https://github.com/NodeppOfficial/nodepp-mariadb) -> MariaDB Client for Nodepp
157-
- 🔗: [Postgres](https://github.com/NodeppOfficial/nodepp-postgres) -> Postgres Client for Nodepp
158-
195+
- 🔗: [ExpressPP](https://github.com/NodeppOfficial/nodepp-express) -> Express equivalent for Nodepp
196+
- 🔗: [ApifyPP](https://github.com/NodeppOfficial/nodepp-apify) -> Socket.io equivalent for Nodepp
197+
- 🔗: [Bluetooth](https://github.com/NodeppOfficial/nodepp-bluetooth) -> Bluetooth Port for Nodepp
198+
- 🔗: [SerialPP](https://github.com/NodeppOfficial/nodepp-serial) -> Serial Port for Nodepp
199+
- 🔗: [Argon2](https://github.com/NodeppOfficial/nodepp-argon2) -> Argon2 for Nodepp
200+
- 🔗: [Torify](https://github.com/NodeppOfficial/nodepp-torify) -> HTTP|Ws over Tor
201+
- 🔗: [GPUPP](https://github.com/NodeppOfficial/nodepp-gpu) -> GPGPU for Nodepp
202+
- 🔗: [NginxPP](https://github.com/NodeppOfficial/nodepp-nginx) -> Reverse Proxy
203+
- 🔗: [InputPP](https://github.com/NodeppOfficial/nodepp-input) -> Fake Inputs
204+
- 🔗: [XML](https://github.com/NodeppOfficial/nodepp-xml) -> XML for Nodepp
205+
- 🔗: [JWT](https://github.com/NodeppOfficial/nodepp-jwt) -> JSON Web Token
206+
- 🔗: [NmapPP](https://github.com/NodeppOfficial/nodepp-nmap) -> Scan IPs and Ports
207+
- 🔗: [Redis](https://github.com/NodeppOfficial/nodepp-redis) -> Redis Client for Nodepp
208+
- 🔗: [Sqlite](https://github.com/NodeppOfficial/nodepp-sqlite) -> Sqlite Client for Nodepp
209+
- 🔗: [MariaDB](https://github.com/NodeppOfficial/nodepp-mariadb) -> MariaDB Client for Nodepp
210+
- 🔗: [Postgres](https://github.com/NodeppOfficial/nodepp-postgres) -> Postgres Client for Nodepp
211+
159212
## Contribution
160213

161214
If you want to contribute to **Nodepp**, you are welcome to do so! You can contribute in several ways:
@@ -171,4 +224,4 @@ If you want to contribute to **Nodepp**, you are welcome to do so! You can contr
171224

172225
## License
173226

174-
**Nodepp** is distributed under the MIT License. See the LICENSE file for more details.
227+
**Nodepp** is distributed under the MIT License. See the LICENSE file for more details.

examples/0-Terminal_Color.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <nodepp/nodepp.h>
2+
3+
using namespace nodepp;
4+
5+
void onMain() {
6+
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+
27+
conio::foreground( conio::color::green | conio::color::bold );
28+
console::log( "hello world!" );
29+
conio::reset();
30+
31+
}

examples/14-Event.cpp

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

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

1717
// Emit Events
1818
ev.emit();
19+
console::log( "->", ev.size() );
1920

2021
// Clear Even Queue
2122
ev.clear();
2223

2324
// turn of an specific event
24-
auto item = ev.on([](){ /* logic goes here */ });
25-
26-
ev.off( item );
25+
auto item = ev.on([](){
26+
console::log("me cago en la puta");
27+
});
28+
console::log( "->", ev.size() );
2729

30+
ev.off( item ); ev.emit();
31+
console::log( "->", ev.size() );
2832

2933
}

examples/16-Asyn_Promises.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <nodepp/nodepp.h>
2+
#include <nodepp/timer.h>
3+
#include <nodepp/promise.h>
4+
5+
using namespace nodepp;
6+
7+
void onMain(){
8+
9+
promise_t<int,except_t> prom ([=]( res_t<int> res, rej_t<except_t> rej ){
10+
timer::timeout([=](){ res(10); },1000);
11+
}); prom.emit();
12+
13+
process::add( coroutine::add( COROUTINE(){
14+
coBegin
15+
16+
coWait( prom.is_pending() );
17+
18+
if( !prom.has_value() ){ coEnd; }
19+
20+
if( prom.is_resolved() ){ console::done ( prom.get_value().value() ); }
21+
else /*--------------*/ { console::error( prom.get_value().error() ); }
22+
23+
coFinish
24+
}));
25+
26+
}

examples/16-Promises.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ using namespace nodepp;
66

77
void onMain(){
88

9-
promise_t<int,int>([=]( function_t<void,int> res, function_t<void,int> rej ){
9+
promise_t<int,except_t>([=]( res_t<int> res, rej_t<except_t> rej ){
1010
timer::timeout([=](){ res(10); },1000);
1111
})
12-
12+
1313
.then([=]( int res ){
1414
console::log("resolved:>",res);
1515
})
16-
17-
.fail([=]( int rej ){
16+
17+
.fail([=]( except_t rej ){
1818
console::log("rejected:>",rej);
19+
})
20+
21+
.finally([=](){
22+
console::log("--finally--");
1923
});
2024

21-
}
25+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <nodepp/nodepp.h>
2+
#include <nodepp/promise.h>
3+
4+
using namespace nodepp;
5+
6+
void onMain() {
7+
8+
ptr_t<uint> value = new uint(0);
9+
10+
promise::resolve( coroutine::add( COROUTINE(){
11+
coBegin
12+
13+
coDelay( 1000 );
14+
*value = 10;
15+
16+
coFinish
17+
}))
18+
19+
.then([=]( null_t ){
20+
console::log( *value );
21+
})
22+
23+
.fail([=]( except_t err ){
24+
console::error( err.what() );
25+
});
26+
27+
console::log( "Hello!" );
28+
29+
}

examples/30-HTTPS-Client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void onMain(){
1717
// args.file = file_t("PATH","r");
1818
// args.body = "MYBODY";
1919

20-
https::fetch( args, ssl )
20+
https::fetch( args, &ssl )
2121

2222
.then([]( https_t cli ){
2323
cli.onData([]( string_t chunk ){

examples/33-HTTPS-Server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void onMain(){
1818

1919
cli.write( date::fulltime() );
2020

21-
}, ssl );
21+
}, &ssl );
2222

2323
server.listen( "localhost", 8000, [=]( ssocket_t server ){
2424
console::log("server started at https://localhost:8000");

0 commit comments

Comments
 (0)