URL Shortener using LevelDB
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
LICENSE.txt
package-lock.json
package.json
readme.md
server.js

readme.md

urlLeveler

A simple example of using LevelDB to make a URL shortener, with Node.js, Express.js, and LevelDB

Setup

npm install

Running

npm run start

Usage

REST Endpoints

curl http://localhost:8000/<key> - Will redirect to the URL for the give Key.

curl -X POST http://localhost:8000/api -d "url=https://128bit.io" - Will add the URL to the database and return JSON data with the Key and URL.

curl http://localhost:8000/api/<key> - Will return JSON data with Key and URL from the database.

curl -X DELETE http://localhost:8000/api/<key> - Will return JSON data with Key and URL from the database and remove the data from the database.

GraphQL Endpoint

GraphQL Endpoint can be found at http://localhost:8000/graphql.

To create a new URL, use the addURL Mutation

mutation {
  addURL(url: "https://128bit.io") {
    key
    url
  }
}

To get a URL with a key, use the url Query

{
  url(key: "<key>") {
    key
    url
  }
}