Basic Usage
Learn the fundamentals of using Axiom Genesis.
Creating a Simple Application
Here's a basic example to get you started:
import { AxiomGenesis, Server } from 'axiom-genesis';
const app = new AxiomGenesis();
const server = new Server(app);
// Define a route
app.get('/api/hello', (req, res) => {
res.json({ message: 'Hello, World!' });
});
// Start the server
server.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});
Handling Requests
GET Request
app.get('/api/users', (req, res) => {
res.json({ users: [] });
});
POST Request
app.post('/api/users', (req, res) => {
const user = req.body;
res.json({ id: 1, ...user });
});
Error Handling
app.get('/api/error', (req, res) => {
res.error(new Error('Something went wrong'));
});
Middleware
You can add middleware to process requests:
app.use((req, res, next) => {
console.log(`${req.method} ${req.path}`);
next();
});
Configuration
Configure your application using the configuration file created during setup. See the Configuration Guide for details.
Next Steps
- Learn about Advanced Features
- Explore the API Reference
- Check out example projects on GitHub