Skip to content

TechTea Server is a Node.js and Express.js based REST API backend powering the TechTea blog platform. It supports full user authentication, post and category management, image uploads via Cloudinary, and more.

Notifications You must be signed in to change notification settings

SwapnilMk/techtea-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TechTea Blog Application

A full-stack blog application built with Node.js, Express, and MongoDB. This application provides a robust API for managing blog posts, users, categories, and authentication.

Features

  • User authentication and authorization
  • Blog post management (CRUD operations)
  • Category management
  • User profile management
  • Post likes functionality
  • Image upload support using Cloudinary
  • RESTful API architecture

Tech Stack

  • Backend: Node.js, Express.js
  • Database: MongoDB with Mongoose
  • Authentication: JWT (JSON Web Tokens)
  • File Upload: Cloudinary, Multer
  • Other Tools: bcrypt for password hashing, cors for cross-origin requests

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB
  • Cloudinary account (for image uploads)

Installation

  1. Clone the repository:
git clone https://github.com/SwapnilMk/techtea-server.git
cd techtea-server
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory with the following variables:
PORT=8080
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
  1. Start the development server:
npm run dev

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login user

Users

  • GET /api/users - Get all users
  • GET /api/users/:id - Get user by ID
  • PUT /api/users/:id - Update user
  • DELETE /api/users/:id - Delete user

Posts

  • GET /api/posts - Get all posts
  • GET /api/posts/:id - Get post by ID
  • POST /api/posts - Create new post
  • PUT /api/posts/:id - Update post
  • DELETE /api/posts/:id - Delete post

Categories

  • GET /api/categories - Get all categories
  • POST /api/categories - Create new category
  • PUT /api/categories/:id - Update category
  • DELETE /api/categories/:id - Delete category

Project Structure

techtea-server/
├── config/         # Configuration files
├── models/         # Database models
├── routes/         # API routes
├── utils/          # Utility functions
├── index.js        # Main application file
└── package.json    # Project dependencies

Scripts

  • npm run dev - Start development server with nodemon
  • npm start - Start production server

Error Handling

The application includes global error handling middleware that catches and processes errors appropriately, returning meaningful error messages to the client.

Security Features

  • Password hashing using bcrypt
  • JWT-based authentication
  • CORS enabled
  • Request size limits
  • Environment variable configuration

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

About

TechTea Server is a Node.js and Express.js based REST API backend powering the TechTea blog platform. It supports full user authentication, post and category management, image uploads via Cloudinary, and more.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published