Snapped URL API

Welcome to the Snapped URL API documentation. This API allows you to manage and shorten URLs for easy sharing.

Project Overview

The Snapped URL API is a powerful tool for managing and shortening URLs. It provides a set of endpoints that allow you to create, update, and delete shortened links, as well as retrieve a list of links generated by a user. With our click tracking feature, you can easily monitor the number of clicks on each shortened link to gauge its reach and performance.

Project Structure

The project is organized into the following directories and files:

.
├── README.md
├── config
│   ├── database.js
│   └── swagger_config.js
├── controller
│   └── error.js
├── features
│   ├── app_version
│   │   ├── controller.js
│   │   ├── middleware.js
│   │   ├── version_model.js
│   │   └── version_routes.js
│   ├── link_shortner
│   │   ├── link_shortner_controller.js
│   │   ├── link_shortner_model.js
│   │   ├── link_shortner_routes.js
│   │   └── schema
│   ├── login
│   │   ├── login_controller.js
│   │   ├── login_routes.js
│   │   └── schema
│   └── registration
│       ├── registration_controller.js
│       ├── registration_routes.js
│       ├── schema
│       └── user_counter_model.js
├── index.js
├── middleware
│   ├── basic_auth_middleware.js
│   └── bearer_atuh_middleware.js
├── model
│   └── user_model.js
├── package-lock.json
├── package.json
├── services
│   └── otp_controller.js
.

API Endpoint Summary

  • Check Version: /api/check-version (GET)
  • Registration: /api/sign-up (POST)
  • Log In: /api/log-in (POST)
  • Shorten URL: /api/short-link (POST)
  • Update URL: /api/short-link (PUT)
  • Delete URL: /api/short-link (DELETE)
  • Get Shortened Links: /api/short-link-generated (GET)
  • Visit Shortened Link: /sl/:shortLinkId (GET)

Swagger Documentation

Explore and test the API endpoints using Swagger documentation by accessing the Swagger UI at [Your API Base URL]/api-docs in your web browser.

CRUD Operations

This API supports Create, Read, Update, and Delete (CRUD) operations for managing shortened links:

  • Create: Use the /api/short-link POST endpoint to create a new shortened link.
  • Read: Use the /api/short-link-generated GET endpoint to retrieve a list of your shortened links. Use /sl/:shortLinkId to visit a shortened link.
  • Update: Use the /api/short-link PUT endpoint to update an existing shortened link.
  • Delete: Use the /api/short-link DELETE endpoint to delete a shortened link.

Environment Variables (example)

  • JWT_SECRET: Secret key for JWT token generation.
  • EMAIL_API_KEY: API key for email service.
  • BCRYPT_COST_FACTOR: Cost factor for bcrypt password hashing.
  • BASIC_AUTH_USERNAME: Username for Basic Authentication.
  • BASIC_AUTH_PASSWORD: Password for Basic Authentication.
  • PORT: Port number for the API server.
  • DBURL: MongoDB connection URL.
  • LOCAL_URL: Local development URL.
  • ENV: Environment mode (e.g., 'development', 'production').

Getting Started

  1. Clone this repository.
  2. Install dependencies using npm install.
  3. Set up your environment variables by creating a .env file.
  4. Start the server using node index.js.

Thank you for using the Snapped URL API!