UltraFast Server – Lightweight Bun-powered HTTP framework with routes, middleware, plugins, request/response management, and modern logging
npm install aetherx
# or
yarn add aetherx
# or
bun add aetherxNote: Bun must be installed globally:
npm install -g bunimport { Sether } from "aetherx";
const server = new Sether({
port: 3000,
settings: {
logger: true,
development: false,
error: new Response(`<pre>500 Internal Server Error</pre>`, {
status: 500,
headers: { "Content-Type": "text/html" },
}),
},
});app.get("/", (req, res) => res.status(200).text("Welcome!"));
app.get("/html", (req, res) => res.render("./src/pages/index.html"));
app.get("/ejs", (req, res) =>
res.render("./src/pages/index.ejs", { title: "EJS Page" }) // requires npm i ejs
);import { Sether, Router } from "aetherx";
const router = new Router();
router.create({
routeName: "myUserRoute",
name: "/user",
category: "/api",
method: "get",
run: (req, res) => res.render("./src/pages/index.html"),
});
router.create({
routeName: "userProfile",
name: "/user/profile",
category: "/api",
method: "get",
run: (req, res) => res.render("./src/pages/profile.html"),
});
const server = new Sether({
port: 3000,
routes: ["myUserRoute", "userProfile"], // routeName references
settings: {
logger: true,
development: false,
error: new Response(`<pre>500 Internal Server Error</pre>`, {
status: 500,
headers: { "Content-Type": "text/html" },
}),
},
});Available plugins: AI, CORS, Helmet, RateLimit
import { Sether, AiPlugin, chat, CorsPlugin, HelmetPlugin, RateLimitPlugin } from "aetherx";
const server = new Sether({
port: 3000,
plugins: [
new AiPlugin({
apiKey: "YOUR_OPENAI_KEY",
model: "gpt-4",
chat: async (messages) => await chat("gemini", messages)
}),
new HelmetPlugin({
contentSecurityPolicy: true,
referrerPolicy: "no-referrer",
xssProtection: true
}),
new CorsPlugin({
origin: "*",
methods: ["GET", "POST"],
credentials: true
}),
new RateLimitPlugin({
windowMs: 60000,
max: 100,
identifier: (req) => req.ip || "anon"
}),
],
settings: {
logger: true,
development: false,
},
});
// Using AI chat
const reply = await chat("gemini", [
{ role: "user", content: "Hello Gemini!" }
]);
console.log(reply); // Gemini's responseserver.on("ready", () => console.log("Server started!"));
server.emit("yourCustomEvent", "args");
server.on("yourCustomEvent", (...args) => console.log("Event triggered:", args));| Method | Description |
|---|---|
on(event: string, callback) |
Listen for server events |
emit(event: string, ...args) |
Emit custom events |
routes |
Array of route names to register |
plugins |
Array of plugins to use |
| Method | Description |
|---|---|
create(params) |
Create a new route |
getRouter() |
Return all routes |
findRoute(name, method) |
Find a route by name and method |
| Method | Description |
|---|---|
json() |
Parse request body as JSON |
text() |
Get raw text body |
form() |
Parse as FormData |
getHeader(name) |
Get specific header |
getQuery(key, default) |
Get query param |
getParam(key) |
Get route param |
device() |
Detect device/browser info |
ip |
Get client IP |
| Method | Description |
|---|---|
status(code) |
Set response status |
json(data) |
Send JSON response |
text(data) |
Send plain text response |
render(path, data) |
Render HTML/EJS template |