A Node.js/Express backend API for the SkillSwap platform - a community-driven skill exchange application where users can offer and request skills from one another.
- 🔄 Create Swaps - Users can post skill offers and requests
- 📋 List Swaps - Browse all available skill exchanges
- ✏️ Edit Swaps - Update existing skill swap postings
- 🗑️ Delete Swaps - Remove swaps
- 💾 MongoDB Integration - Persistent data storage
- 🔒 CORS Enabled - Secure cross-origin requests
- 📝 Environment Configuration - Secure environment variable management
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB
- Environment: dotenv
- Middleware: CORS, Express JSON parser
- Node.js (v14 or higher)
- npm or yarn
- MongoDB Atlas account (or local MongoDB instance)
- Clone the repository
git clone https://github.com/JstMeJosh/skillswap-backend.git
cd skillswap-backend- Install dependencies
npm install- Create
.envfile Create a.envfile in the root directory:
MONGO_URI=your_mongodb_connection_string
PORT=5000- Start the server
npm run devThe server will start on http://localhost:5000
GET /api/swaps
Returns a list of all skill swaps.
Response:
[
{
"_id": "507f1f77bcf86cd799439011",
"title": "Learn React",
"skillOffered": "JavaScript",
"skillWanted": "Python",
"description": "I can teach JavaScript basics..."
}
]POST /api/swaps
Content-Type: application/json
{
"title": "Learn Web Design",
"skillOffered": "Web Development",
"skillWanted": "Graphic Design",
"description": "I can teach HTML, CSS, and JavaScript"
}
PUT /api/swaps/:id
Content-Type: application/json
{
"title": "Learn React",
"skillOffered": "JavaScript",
"skillWanted": "Python",
"description": "Updated description"
}
DELETE /api/swaps/:id
{
title: String (required),
skillOffered: String (required),
skillWanted: String (required),
description: String (optional),
createdAt: Date (auto-generated),
updatedAt: Date (auto-generated)
}| Variable | Description | Example |
|---|---|---|
MONGO_URI |
MongoDB connection string | mongodb+srv://user:password@cluster.mongodb.net/skillswap |
PORT |
Server port (optional, defaults to 5000) | 5000 |
npm run dev- Start the server with nodemon (auto-reload on file changes)npm start- Start the production server
backend/
├── models/
│ └── Swap.js # MongoDB Swap model
├── server.js # Main Express application
├── package.json # Dependencies and scripts
├── .env # Environment variables (not tracked)
├── .gitignore # Git ignore rules
└── README.md # This file
The backend uses nodemon for automatic server reloading during development. Changes to any file will automatically restart the server.
All endpoints return appropriate HTTP status codes:
200- Success201- Created400- Bad Request / Server Error404- Not Found
The API is configured to accept requests from any origin. In production, update the CORS configuration in server.js to restrict to your frontend domain:
app.use(cors({
origin: 'https://yourdomain.com'
}));- User authentication and authorization
- User profiles with ratings and reviews
- Skill categories and tags
- Search and filter functionality
- Messaging system between users
- Transaction history
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
For questions or support, please reach out to the project maintainer.
Happy Skill Swapping! 🚀