GithubHelp home page GithubHelp logo

url-shortner's Introduction

Welcome!

This is my URL Shortner API project.

Dependencies:

Main

  • Node.js (Express for server)
  • MongoDB (Using mongodb package to communicate)

Other Dependencies:

Security:

  • Morgan
  • Helmet
  • Cors
  • Express-rate-limit

Content

  • Crypto (A default node package, used to create offsets random bytes)
  • is-url (To Check the validity of URLs passed)

Usage

Once you cloned the project or dowloaded you will need to dowload the dependencies and then run the server using the following commands:

cd PROJECT_PATH
npm install
npm run start or npm run dev ( for development ) 

You will need also to update the config.json file with a valid mongodb cluster url. Used DB Name is "URLs" and Collection name is "Data"

{
    "MONGO_DB_URL": "URL"
}

The server has 3 routes handled

  • /* for getting urls based on offsets, it redirects if offset is true otherwise returns the following message:
{
	"error": "No URL Found"
}
  • /url/create to do post requests to create shortned urls. (we use json)
// Request Body
{
	"url": "VALID-URL"
}

// Response

// If valid 
{
	"message": "URL created successfully, keep the secret to delete in the future.",
	"URL": "http://SERVER_URL:1000/5f8e69d4",
	"secret": "9e8385610be8ad90"
}
// If Invalid
{
  "error": "Please provide a valid URL."
}
  • /url/delete to do post requests to delete shortned urls already made. (we use json)
// Request Body
{
	"secret": "SECRET_FROM_CREATE_REQUEST"
}

// Response

// If valid 
{
	"message": "URL deleted successfully."
}
// If Invalid
{
	"error": "No URL connected to that secret."
}

url-shortner's People

Contributors

filexgh 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.