Xcess is a lightweight, express-like and easy-to-use web framework for Node.js, inspired by Express.js. It provides a simple API for creating web applications and handling HTTP requests and responses. With Xcess, you can define routes, use middleware functions, handle static file serving, and enable Cross-Origin Resource Sharing (CORS).
- Easy routing using HTTP methods (GET, POST, PUT, DELETE)
- Middleware support for request processing
- Cross-Origin Resource Sharing (CORS) handling
- Static file serving
To install Xcess, you can use npm:
npm install xcess
Here's an example of how you can use Xcess:
const xcess = require('xcess');
const app = new xcess();
app.get('/', (req, res) => {
res.send('Hello World!');
})
Xcess provides several route methods that allow you to define handlers for different HTTP methods. Here are the available route methods:
The get()
method is used to define a route handler for GET requests.
Usage Example:
app.get('/', (req, res) => {
// Handler logic for GET '/'
});
The post()
method is used to define a route handler for POST requests.
Usage Example:
app.post('/users', (req, res) => {
// Handler logic for POST '/'
});
The put()
method is used to define a route handler for PUT requests.
Usage Example:
app.put('/users/:id', (req, res) => {
// Handler logic for PUT '/users/:id'
});
The delete()
method is used to define a route handler for DELETE requests.
Usage Example:
app.delete('/users/:id', (req, res) => {
// Handler logic for DELETE '/users/:id'
});
The all()
method is used to define a route handler for all HTTP methods.
Usage Example:
app.all('/users', (req, res) => {
// Handler logic for all methods '/users'
});