Skip to content

ShoroukAziz/tinyapp

Repository files navigation

🔗TinyApp

The ultimate solution for creating short and snappy URLs!

made-with-node made-with-express

Table of Content

🌟 Features

  • Generate concise, memorable short URLs from long ones.

  • Create multiple users.

  • Analytics

    • See When was a URL created.
    • keep track of how many times a given short URL is visited.
    • keep track of how many unique visitors visit each url.
    • keep track of every visit (see a timestamp, and a generated visitor_id).
  • Security:

    • URLs can be edited or deleted only by their creator.
    • All passwords are hashed and cookies are encrypted.

🚀 Getting Started

  • Fork the repo
  • clone it
    git clone <repo> tinyapp
  • Navigate to the repo
    cd tinyapp
  • Install all the depndencies
    npm install
  • Run the server:
    npm start
    or node express_server.js
  • Visit the app in your browser: http://127.0.0.1:8080/
    or in your terminal:
    curl http://127.0.0.1:8080/
  • Create a user and start generating tiny urls 🎉🎇

⚫ Endpoints

Http method path Description
GET / - if user is logged in and redirect to /urls
- if user is not logged in redirect to /login
GET /urls - if user is logged in returns HTML with a tabular view of all the users urls.
- if user is not logged in returns HTML with error message and status code 403
GET /urls/new - if user is logged in returns HTML with a form which which makes a POST request to /urls to create a new short URL
- if user is not logged in redirect to /login
GET /urls/:id - if user is logged in returns HTML with The Long URL, the shhort URL , a form to update the url and analytics about the URL number of visits and unique visitors.
-if user is not logged in returns HTML with error message and status code 403
- if user is logged in but id doesn't exist returns HTML with error message and status code 404
- if user is logged in but does not own the URL returns HTML with error message and status code 403
GET u/:id - if URL for the given ID exists redirects to the corresponding long URL
- if URL for the given ID does not exist returns HTML with error message and status code 404
POST /urls - if user is logged in, generates a short URL, saves it, and associates it with the user & redirects to /urls/:id, where :id matches the ID of the newly saved URL
- if user is not logged in returns HTML with error message and status code 403
PUT /urls/:id - if user is logged in and owns the URL for the given ID, updates the URL and redirects to /urls.
- if the user is not logged in or logged in but does not own the URL returns HTML with error message and status code 403
- if the user is logged in but the id does not exist returns HTML with error message and status code 404
DELETE /url/:id - if user is logged in and owns the URL for the given ID, deletes the URL
- if user is not logged in or logged i but does not own the URL returns HTML with error message and status code 403
- if the id does not exists returns HTML with error message and status code 404 returns HTML with error message and status code 404
GET /login - if user is logged in redirects to /urls
- if user is not logged in return HTML with a form that POSTs to /login.
GET /register - if user is logged in redirects to /urls
- if user is not logged in return HTML with a form that POSTs to /register to create a new user.
POST /login - if email and password params match an existing user, set a cookie and redirects to /urls
- if email and password params don't match an existing user returns HTML with error message and status code 401
- if email or password params are empty returns HTML with error message and status code 400
POST /register - if email or password are empty returns HTML with error message and status code 400
- if email already exists returns HTML with error message and status code 409
- Otherwise: creats a new user & redirects to /urls
POST /logout deletes cookie & redirects to /login

🧱 Main Structure

├── docs                  # screenshots for readme
├── views                 # ejs templates & partials
│  ├── partials
├─── test                 # Includes testing code for helpers.js` 
├─── public               # static images
├─── databases.js         # database objects
├─── express_server.js    # The server: the main driver of the app includes all the routs and server configs
├─── helpers.js           #Includes Helper functions
├─── package-lock.json
├─── package.json
└─── README.md

Product Overview

overview.mp4

Register screen

Login Screen

URLs Screen

URL Screen

404 Screen

403 Screen


📦 Tech Stack (Dependencies)

🔙 Backend

🧰 Development Dependencies

👁‍🗨 Frontend Dependencies


🧪 Testing

  • To run the tests. make sure you are in the project directory cd tinyapp
  • Run npm test

🙈 Known issues

  • The url provided by the user has to start with http ot https otherwise it'll fail

⚠️ Disclaimer

⬆ Go to beginning

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published