Getting Started
Learn how to set up and build your first Eiseniiiia application with clear, step-by-step instructions.
1. Installation
// Via npm
npm install eiseniiiia
// Via CDN
<script src="https://cdn.eiseniiiia.dev/1.0.0/index.js"></script>
Use npm for local development or add the CDN link to your HTML file for quick prototyping.
2. Your First App
import { Router } from 'eiseniiiia';
const app = Router();
app.get('/', (req, res) => {
res.send('Hello, Eiseniiiia!');
});
app.listen(3000, () => {
console.log('Server running at http://localhost:3000');
});
Basic server setup with a single route
How It Works
This example creates a Router instance, defines a basic '/' route, and starts the server on port 3000.
The res.send()
method sends a simple HTML response.
GET /
PORT 3000
3. Advanced Routing
Build complex routing with parameterized paths and middleware.
app.get('/user/:id', (req, res) => {
res.json({
id: req.params.id,
message: 'User details'
});
});
Route with parameterized path
Request Flow
URL: /user/123
Route Handler
4. Error Handling
Implement global error handling with custom middleware.
app.use((err, req, res, next) => {
res.status(500).json({
error: "Server Error",
details: err.message
});
});
Global error middleware
Demo Response
HTTP/1.1 500 Internal Server Error
192 B
{"error":"Server Error","details":"Internal error message"}