Skip to content

prabhatisme/subscription-tracker-api

Repository files navigation

Subscription Tracker API

A RESTful API for managing subscription services and tracking renewal dates.

Features

  • User authentication and authorization
  • CRUD operations for subscriptions
  • Subscription status tracking (active, cancelled, expired)
  • Upcoming renewal notifications
  • Multiple currency support (USD, EUR, GBP)
  • Subscription categorization
  • Automatic renewal date calculations

Tech Stack

  • Node.js
  • Express.js
  • MongoDB with Mongoose
  • JWT Authentication

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB
  • npm or yarn

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/subscription-tracker-api.git
cd subscription-tracker-api
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/subscription-tracker
JWT_SECRET=your_jwt_secret
  1. Start the server:
npm start

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

Subscriptions

  • GET /api/subscriptions - Get all subscriptions
  • GET /api/subscriptions/:id - Get subscription by ID
  • POST /api/subscriptions - Create new subscription
  • PUT /api/subscriptions/:id - Update subscription
  • DELETE /api/subscriptions/:id - Delete subscription
  • PUT /api/subscriptions/:id/cancel - Cancel subscription
  • GET /api/subscriptions/upcoming-renewals - Get upcoming renewals

Data Models

User Model

{
  name: String,
  email: String,
  password: String
}

Subscription Model

{
  name: String,
  price: Number,
  currency: String,
  frequency: String,
  category: String,
  paymentMethod: String,
  status: String,
  startDate: Date,
  renewalDate: Date,
  user: ObjectId
}

Testing

Run the test suite:

npm test

Contributing

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

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A RESTful API for managing subscription services and tracking renewal dates.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published