GithubHelp home page GithubHelp logo

short-url-using-node's Introduction

URL Shortener

URL Shortener is a web application that allows users to shorten long URLs for easier sharing and management. This project is built using Node.js and demonstrates server-side scripting, database management, and RESTful API development.

Features

  • Shorten URLs: Convert long URLs into short, manageable links.
  • Redirect: Redirect users to the original URL when they access the shortened link.
  • API Endpoints: Provide RESTful API endpoints for URL shortening and redirection.

Technologies Used

  • Node.js: JavaScript runtime for building server-side applications.
  • Express.js: Web framework for Node.js to handle routing and middleware.
  • MongoDB: NoSQL database for storing URL mappings.

Installation

  1. Clone the repository:
    git clone https://github.com/KARANSINGH34951/short-url-using-Node
  2. Navigate to the project directory:
    cd url-shortener
  3. Install dependencies:
    npm install
  4. Set up environment variables: Create a .env file in the root directory and add your MongoDB connection string:
    MONGODB_URI=your_mongodb_connection_string
    
  5. Start the server:
    npm start

Usage

  1. Access the application: Open your browser and go to http://localhost:3000.
  2. Shorten a URL: Enter a long URL in the input field and click "Shorten".
  3. Use the shortened URL: Copy the shortened URL and share it. Accessing this URL will redirect to the original long URL.

API Endpoints

  • POST /shorten: Shortens a given long URL.

    • Request Body: { "longUrl": "http://example.com" }
    • Response: { "shortUrl": "http://short.url/abc123" }
  • GET /:shortUrl: Redirects to the original long URL.

Folder Structure

url-shortener/
├── config/
│   ├── db.js
├── controllers/
│   ├── urlController.js
├── models/
│   ├── Url.js
├── routes/
│   ├── urlRoutes.js
├── views/
│   ├── index.html
├── .env
├── .gitignore
├── package.json
├── server.js
└── ...

Contributing

Contributions are welcome! Please fork the repository and use a feature branch. Pull requests are warmly welcomed.

  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.

License

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

Contact

If you have any questions or feedback, feel free to contact me at [[email protected]].

short-url-using-node's People

Contributors

karansingh34951 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.