-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
cmake_minimum_required(VERSION 3.28) | ||
project(NodeLite) | ||
|
||
set(CMAKE_CXX_STANDARD 26) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
# Include directories for NodeLite core and external libraries | ||
include_directories(${PROJECT_SOURCE_DIR}/include) | ||
link_directories(${PROJECT_SOURCE_DIR}/lib) | ||
|
||
# Source files for the main NodeLite executable | ||
set(SOURCE_FILES | ||
main.cpp | ||
# Add other source files here | ||
) | ||
|
||
# Define the NodeLite executable | ||
add_executable(NodeLite ${SOURCE_FILES}) | ||
|
||
# Link with external libraries, if any (e.g., V8, libuv) | ||
# target_link_libraries(NodeLite libv8.a libuv.a) | ||
|
||
enable_testing() | ||
|
||
function(add_nodelite_test test_file) | ||
get_filename_component(test_name ${test_file} NAME_WE) | ||
add_test(NAME ${test_name} | ||
COMMAND NodeLite ${PROJECT_SOURCE_DIR}/tests/${test_file}) | ||
|
||
endfunction(add_nodelite_test) | ||
|
||
add_nodelite_test(http_tests.js) | ||
add_nodelite_test(module_loading_tests.js) | ||
add_nodelite_tests(async_io_tests.js) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# NodeLite | ||
|
||
NodeLite is an ultra-lightweight, highly modular Node.js-like runtime environment designed for building scalable server-side applications using JavaScript. It is intended for environments where memory and processing power are at a premium, or for educational purposes to understand the internals of server-side JavaScript execution. NodeLite aims to provide the core functionalities of Node.js with a focus on simplicity, modularity, and extensibility. | ||
|
||
## Getting Started | ||
|
||
To start using NodeLite, ensure you have the following prerequisites installed: | ||
|
||
- Git | ||
- C++ compiler (GCC or Clang) | ||
- Python 3.x (for build scripts) | ||
- CMake | ||
|
||
Clone the repository: | ||
|
||
```bash | ||
git clone https://yourrepository.com/NodeLite.git | ||
cd NodeLite | ||
``` | ||
|
||
Compile and build the project: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
To run a simple JavaScript file: | ||
|
||
```bash | ||
./nodelite yourscript.js | ||
``` | ||
|
||
## Development | ||
|
||
NodeLite is in early development stages and contributors are welcome. The project structure is designed to be modular, allowing for components to be easily added, modified, or replaced. The core components of NodeLite include: | ||
|
||
- **libuv-lite**: A minimalistic version of libuv, focusing on the essential event loop and asynchronous I/O operations. | ||
- **v8-lite**: A stripped-down version of the V8 engine for executing JavaScript. This will prioritize memory efficiency and modularity. | ||
- **http-lite**: A lightweight implementation of the HTTP/HTTPS protocols, supporting basic server functionality. | ||
|
||
### Building a Simple HTTP Server | ||
|
||
```javascript | ||
const http = require('http-lite'); | ||
|
||
const server = http.createServer((req, res) => { | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('Hello World\n'); | ||
}); | ||
|
||
server.listen(8080, () => { | ||
console.log('Server running at http://127.0.0.1:8080/'); | ||
}); | ||
``` | ||
|
||
### Extending NodeLite | ||
|
||
To add a new module to NodeLite, follow these steps: | ||
|
||
1. Create a new directory under `src/modules`. | ||
2. Implement your module in C++ or JavaScript, adhering to the NodeLite module interface. | ||
3. Add your module to the build system and documentation. | ||
|
||
### Contribution Guidelines | ||
|
||
Contributions to NodeLite are highly encouraged. Please follow these guidelines: | ||
|
||
- Write clear, maintainable code. | ||
- Provide comprehensive documentation for new features or modules. | ||
- Submit pull requests with detailed descriptions of changes. | ||
- Ensure your code passes all tests before submitting. | ||
|
||
## Further Reading | ||
|
||
- "Design Patterns: Elements of Reusable Object-Oriented Software" by Erich Gamma et al. – For understanding architectural patterns used. | ||
- "Understanding ECMAScript 6" by Nicholas C. Zakas – For insights into the core JavaScript concepts used in NodeLite. | ||
- "Node.js Design Patterns" by Mario Casciaro – For comparative analysis with Node.js and understanding of design choices. | ||
|
||
NodeLite is a platform for exploration, learning, and innovation. It is an ongoing project where the boundaries of what's possible with server-side JavaScript are continuously being tested and expanded. |