@obinexusltd/aerossr
v0.1.0
Published
A high-performance, TypeScript-first server-side rendering (SSR) framework
Readme
@obinexusltd/aerossr
A high-performance, TypeScript-first server-side rendering (SSR) framework built on Node.js.
Installation
npm install @obinexusltd/aerossrQuick Start
import { Server } from '@obinexusltd/aerossr';
const server = new Server({ port: 3000, host: 'localhost' });
// Add middleware
server.use(async (req, res, next) => {
console.log(`${req.getMethod()} ${req.getPath()}`);
await next();
});
// Add routes
server.addRoute('GET', '/api/health', async (req, res) => {
res.json({ status: 'ok' });
});
server.addRoute('GET', '/api/hello/:name', async (req, res) => {
res.json({ message: `Hello, ${req.getParams().name}` });
});
// Error handling
server.onError(async (error, req, res) => {
console.error(error);
res.status(500).json({ error: error.message });
});
// Start
const addr = await server.start();
console.log(`Server running at http://${addr.address}:${addr.port}`);Using the Router
import { Router } from '@obinexusltd/aerossr';
const router = new Router();
router.use(async (req, res, next) => {
// Global middleware
await next();
});
router.route('GET', '/users', async (req, res) => {
res.json([{ id: 1, name: 'Alice' }]);
});
router.route('POST', '/users', async (req, res) => {
const body = req.getBody();
res.status(201).json(body);
});CLI
AeroSSR includes a command-line interface for development:
# Run directly via npx
npx @obinexusltd/aerossr --help
# Start a development server
npx @obinexusltd/aerossr serve --port 3000 --host localhost
# Initialize a new project
npx @obinexusltd/aerossr initOr install globally:
npm i -g @obinexusltd/aerossr
aerossr serve --port 3000Local Development (npm link)
Windows
cd aerossr
npm install --ignore-scripts
npm run build
npm i -g .
npx @obinexusltd/aerossr --helpWSL / Linux / macOS
If you previously ran npm install on Windows, WSL needs its own platform-specific native dependencies (rollup uses platform-specific binaries). Run npm install from within WSL first:
cd /mnt/c/Users/<you>/Projects/aerossr/aerossr
npm install --ignore-scripts
npm run build
npm i -g .
npx @obinexusltd/aerossr --helpThen in your consuming project:
npm link @obinexusltd/aerossrDocumentation
License
ISC - OBINexus Computing
