This project implements a URL-shortening service that allows users to shorten long URLs into shorter.
The url-shorten
folder contains the following files and directories:
index.js
: Entry point for the URL shortening service.models/
: Directory containing data models for the application.url.model.js
: Defines the data model for URLs.
route/
: Directory containing route definitions.url.route.js
: Defines the API routes for the URL shortening service.
config/
: Directory containing configuration files.db.js
: Configuration file for connecting to the database.
To set up and run the URL shortening service locally, follow these steps:
- Clone the repository:
git clone <url-shorten-repo-url>
- Navigate to the repository:
cd url-shorten
- Install dependencies:
npm install
- Set up environment variables:
PORT: 8000
5.Start the server
node index.js
- Endpoint:
/shorten
- Method: POST
- Request Body:
{ "originalUrl": "https://example.com" }
- Response:
{ "shortUrl": "https://shortened-url.com/abc123" }