Skip to content

amz2694/TinyURL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinyURL

Table of Contents

General Info

TinyURL is a simple MEVN stack URL shortener.

Technologies

  • HTML/CSS3
  • nodeJs
  • express
  • vue 3
  • vue router
  • mongoDB

How To Use

Installation

You can install TinyURL locally using npm.

Front-End project setup

Install dependencies using:

cd front
npm install

Compile and hot-reload for development using:

npm run serve

Compile and minifile for production by running:

npm run build

Back-End project setup

Install dependencies using:

cd back
npm install

Compiles for development using:

npm run dev

or start the server by using the following command:

npm start

database setup

replace your database url in back/.env file

API Reference

You can get the original URL using:

GET   /short
Parameter Type Description
URL string Required. short url

200 status code return {realURL : string}


get the details about your short url using:

GET   /details
Parameter Type
URL string

200 status code return

{
  realURL : String,
  os      : Object,
  machine : Object,
  time    : Object,
  country : Object,
}

shorten the URL:

POST  /short

Login is required to request this API. The request should be a JSON in the form of {URL : string}. Make sure to put Bearer accessToken in headed.Authorization.

201 status code return {shortURL : string}


Sign up :

POST  /register

The request should be a JSON in the form of

{
  user  : string,
  email : string,
  pwd   : string
}

201 status code return { "success": 'new user ${user} created!' }

other status code :

Status Code Description
201 CREATED
400 BAD REQUEST
409 Conflict
500 INTERNAL SERVER ERROR

Login to an existing account :

POST  /auth

The request should be a JSON in the form of

{
  user  : string,
  pwd   : string
}

200 status code return {accessToken : string} which expires after 30 seconds. The refreshToken is set as a cookie which expires after 1 day.

other status code :

Status Code Description
200 OK
400 BAD REQUEST
401 UNAUTHORIZED
500 INTERNAL SERVER ERROR

To get new accessToken :

GET   /refresh

200 status code return {accessToken : string}

other status code :

Status Code Description
200 OK
401 UNAUTHORIZED
403 FORBIDDEN
500 INTERNAL SERVER ERROR

License

licensed under the MIT License.

Back To The Top