Skip to content

alexdisdier/short-url-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Synopsis

This is an APi for my shorten url open source web app. I built it using NodeJS.

You will find three branches:

  • master using Typescript, REST API and GraphQL, unit test with Jest
  • javascript first version of this project using only REST API, witout unit test
  • GraphQL converting REST API into GraphQL

✅ Functionalities

  • Route to shorten url

    • Checking if it's a valid URL
    • Checking if it's missing http - https
    • Creating in MongoDB new URL object
  • Route to redirect the short url

    • Find the short url
    • redirect to original url
  • Route to update the number of visits to a url

    • Find by id the url
    • Increment + 1 the number of visits

Directory Structure

shorten-url-api
├── dist
├── src
│   ├── constant
│   ├── app.ts
│   ├── server.ts
│   └── url.ts
├── test
├── .gitignore
├── README.md
├── jest.config.js
├── package.json
└── tsconfig.json

Running the project

Clone this repository :

git clone https://github.com/alexdisdier/short-url-api.git

cd shorten-url-api

Test different branches:

git checkout javascript
git checkout GraphQL

Start the server:

npm run dev

Test the api:

npm run test:unit

Build the app:

npm run build

Open Postman to test it out. Your data will be saved to MongoDB.

If you're on the graphQl branch, you can use graphiql.

Built With

Testing With

Dependencies