Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 2 additions & 36 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,20 @@ on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: bun install

- name: Build
run: bun run build:release

- name: Test
run: bun run test

publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup Node.js (for npm publish)
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
scope: "@http-native"

- name: Install dependencies
run: bun install

- name: Build (release)
run: bun run build:release
run: npm install

- name: Publish to npm
run: npm publish --access public
Expand Down
Empty file removed noslop/AGENTS.md
Empty file.
Empty file removed noslop/CLAUDE.md
Empty file.
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
{
"name": "@http-native/core",
"version": "0.1.0",
"version": "0.0.3",
"type": "module",
"publishConfig": {
"access": "public"
},
"bin": {
"http-native": "./src/cli.js"
},
"files": [
"src"
],
"exports": {
".": {
"types": "./src/index.d.ts",
"default": "./src/index.js"
},
"./cors": "./src/cors.js",
"./hot": "./src/hot.js",
"./session": "./src/session.js",
"./validate": "./src/validate.js",
"./http-server.config": "./src/http-server.config.js"
},
"scripts": {
"build": "bun scripts/build-native.mjs",
"build:release": "bun scripts/build-native.mjs --release",
"dev:hot": "HTTP_NATIVE_HOT_RELOAD=1 bun test/app.ts",
"dev": "bun src/hot.js",
"test": "bun run build && bun test/test.js",
"bench": "bun run build:release && bun bench/run.js",
"bench:http-native:static": "bun run build:release && bun bench/run.js http-native static 3001",
Expand All @@ -44,5 +53,8 @@
"bench:xitca:opt": "bun bench/run.js xitca opt 3023",
"bench:monoio:opt": "bun bench/run.js monoio opt 3024",
"bench:zig:opt": "bun bench/run.js zig opt 3025"
},
"dependencies": {
"@http-native/core": "^0.0.1"
}
}
91 changes: 27 additions & 64 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,54 @@
<p align="center">
<img src="https://cf-data.pkg.lat/httpnative-banner.png" style="width: 600px; height: 450px; object-fit: cover;" />
<img src="https://cf-data.pkg.lat/httpnative-banner.png" style="width: 600px; height: 450px; object-fit: cover;" />
</p>

# @http-native/core

Http-native
A fast, Express-like HTTP framework for JavaScript powered by a Rust native module via napi-rs.

Http native is a express like server framework for Javascript that uses the Node-compatible framework with Rust native module way, where the rust binary is evoked through napi-rs or something faster.
## Install

You can also import the default server tuning config and override it before `listen()`:

```js
import httpServerConfig from "http-native/http-server.config";
```sh
npm install @http-native/core
```

Rust handler (http) <-> (javascript logic)

The rust server handles all the http, while the core javascript logic is run sperately (EXREMELY fast)

Extrat performance features:

1) Ahead of time constant data indentification. (If the data in the route's logic isn't manipulated at runtime we directly store it in rust so we don't envoke the javascript logic)

2) Faster than bun.server() aswell as fastify.

3) Default async handling (Yes rust handles the async for you.)

So start by just writing
## Usage

```js
import { createApp } from "../src/index.js";

const db = {
async getUser(id) {
return {
id,
name: "Ada wong",
role: "admin",
};
},
};
import { createApp } from "@http-native/core";

const app = createApp();

app.use(async (req, res, next) => {
res.header("x-powered-by", "http-native");
await next();
app.get("/", async (req, res) => {
res.json({ ok: true });
});

app.get("/", (req, res) => {
res.json({
ok: true,
engine: "rust",
bridge: "napi-rs",
});
app.get("/user/:id", async (req, res) => {
res.json({ id: req.params.id });
});

app.get("/users/:id", async (req, res) => {
const user = await db.getUser(req.params.id);
res.json(user);
app.error(async (error, req, res) => {
res.status(500).json({ error: error.message });
});

const server = await app.listen({
port: 3001,
serverConfig: {
...httpServerConfig,
maxHeaderBytes: 32 * 1024,
},
});
const server = await app.listen().port(8190);
console.log(`Listening on ${server.url}`);
```

Runtime optimization reporting:
## Imports

```js
console.log(server.optimizations.summary());
console.log(server.optimizations.snapshot());
import { createApp } from "@http-native/core";
import cors from "@http-native/core/cors";
import { validate } from "@http-native/core/validate";
import httpServerConfig from "@http-native/core/http-server.config";
```

Pass `opt: { notify: true }` to `listen()` if you want runtime logs when a route is already native static or looks stable enough to cache later.


This architecture is designed to outperform previous iterations and provide top-tier performance on par with or exceeding `bun.serve()`.
Run tests via `test.js` and use the benchmark suite to validate performance gains.


Since this is designed to be a core library, please ensure strict adherence to API stability and zero-allocation principles where possible.

Remeber nadhi u moron this will be a library so don't go around doing shit.
## Optimizations

```js
const server = await app.listen().port(8190).opt({ devComments: true });

bump action
console.log(server.optimizations.summary());
console.log(server.optimizations.snapshot());
```
Loading
Loading