const restify = require('restify');
const server = restify.createServer();
const port = 8080;
server.get('/', function(req, res, next) {
res.send('Hello World from Restify!');
next();
});
// Add a route with parameters
server.get('/hello/:name', function(req, res, next) {
res.send(`Hello ${req.params.name}!`);
next();
});
// Add a route that returns JSON
server.get('/api/info', function(req, res, next) {
res.json({
framework: 'Restify',
version: '8.x',
features: ['RESTful routing', 'Content negotiation', 'DTrace support', 'Middleware']
});
next();
});
server.listen(port, function() {
console.log(`Restify server running at http://localhost:${port}`);
});