DeveloperBreeze

Simple RESTful API in Node.js using Express

javascript
// Import 'express' module
const express = require('express');
const app = express();

// Define a route for accessing a resource
app.get('/api/resource', (req, res) => {
  res.json({ message: 'Resource data' });
});

// Start the server and listen on port 3000
app.listen(3000, () => {
  console.log('RESTful API is running on port 3000');
});

Related Posts

More content you might like

Tutorial

Build a Custom Rate Limiter in Node.js with Redis

mkdir node-rate-limiter
cd node-rate-limiter
npm init -y
npm install express redis dotenv

Create a .env file:

Apr 04, 2025
Read More
Tutorial
go

Building a RESTful API with Go and Gorilla Mux

   curl -X GET http://localhost:8000/books/b1
   curl -X PUT http://localhost:8000/books/b1 -H "Content-Type: application/json" -d '{"title":"Advanced Go","author":"Jane Smith","year":"2024"}'

Aug 12, 2024
Read More
Tutorial
javascript css +1

Building a Real-Time Chat Application with WebSockets in Node.js

npm init -y
npm install express socket.io

Aug 03, 2024
Read More
Code
php

JWT Token Creation and Verification in Node.js using 'jsonwebtoken'

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!