Home

Awesome

nodenative

<b>nodenative</b> is a C++14 (aka C++1y) port for node.js.

<table> <thead> <tr> <th>Linux and OSX</th> <th>Coverage Status</th> </tr> </thead> <tbody> <tr> <td align="center"> <a href="https://travis-ci.org/nodenative/nodenative"><img src="https://travis-ci.org/nodenative/nodenative.svg?branch=master"></a> </td> <td> <a href="https://coveralls.io/github/nodenative/nodenative?branch=master)"><img src="https://coveralls.io/repos/github/nodenative/nodenative/badge.svg?branch=master"></a> </td> </tr> </tbody> </table>

Please note that nodenative project is <em>under heavy development</em>.

Feature highlights

Sample code

Simplest web-server example using nodenative.

#include <iostream>
#include <native/native.hpp>
using namespace native::http;

int main() {
    Server server;
    if(!server.listen("0.0.0.0", 8080, [](http::shared_ptr<Transaction> iTransaction) {
        ServerResponse& res = iTransaction->getResponse();
        res.set_status(200);
        res.set_header("Content-Type", "text/plain");
        res.end("C++ FTW\n");
    })) return 1; // Failed to run server.

    std::cout << "Server running at http://0.0.0.0:8080/" << std::endl;
    return native::run();
}

Getting started

<em>nodenative</em> requires libuv and http-parser lib to use.

Build

To compile included sample application(webserver.cpp) first run the following command in the project directory:

git submodule update --init

then generate the build files and compile:

./build.py
make -C out

build.py will try to download build dependencies (gyp) if missing. If you prefer to download manually you can do:

$ git clone https://chromium.googlesource.com/external/gyp.git build/gyp
OR
$ svn co http://gyp.googlecode.com/svn/trunk build/gyp

by default will generate for make file. if you want to generate for a specific build tool use -f <buildtool>. e.x:

./build.py -f ninja
ninja -C out/Debug/

alternatively you can set custom paths to http-parser and libuv if you dont want to use the submodules. If it is build with make in debug mode, then executables are saved to out/Debug dir.

Run samples

In samples dir you can see samples which use native library.

To run webserver sample compiled by make in debug mode:

out/Debug/webserver

Run tests

To run tests compiled by make in debug mode:

out/Debug/test

Tested on

Other Resources