GithubHelp home page GithubHelp logo

url-shortener's Introduction

URL Shortener

A simple URL shortener

Requirements

  • Node.js v10.x & NPM v6.2
  • Mongo 2.2.3

Run

  • Clone this repo
  • Run npm install to install dependencies
  • Run npm run dep to run dependencies like mongo and don't forget to enter root password after running command for mongo.
  • Open new terminal leaving previous one running
  • Copy file .env.example to .env and change env details if needed
  • Run command npm run dev
  • Then visit http://localhost:{port} to access app

List of any security issues in your solution, and how you would fix them.

A malicous user can enter same url to fill database with same url so to prevent this i have worked on both frontend and backend.

Dependencies

  • cors Helps us protect from any cors related issue
  • helmet Sends security related headers
  • winston Simple logger transport layer for logging
  • next For server side rendering, static pages and routing
  • react UI library
  • yup Object schema validator used for request/form validation
  • axios Simple isomorphic http client

Backend

  • We have rate limited our API so a malicous user can't request multiple times in certain window
  • We have added some security related headers which will prevent us from common problems
  • If a requested url for shortening is already available then we provide available short url to provide duplication as currently we don't have user account we won't have any problem.

Frontend

  • Once a user submits url and new short url is created it is stored in memory and whenever on next request if the requested url is found in cache then we return back previously created short url. This will prevent unnecessary request.

List of any scalability issues in your solution, and with how you would fix them.

Currently our app can handle some amount of users but if in future if usage grows then we can do following things.

  • Clustering application
  • Load Balance and distrbute equally on nodes
  • Instead of direct insert to database we can introduce some queuing technology (redis).
  • We can maintain session to track url and avoid duplication of urls.

url-shortener's People

Contributors

samundrak avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  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.