-
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.
- 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
ornode 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 🎉🎇
- Base URL : http://127.0.0.1:5000
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 |
├── 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
overview.mp4
- 🚄 Express
- 📰 EJS
- 🍪 Cookie-Session
- 🔐 Bcryptjs
- 📝 Method override
- 💬 Morgan
- 🎨 Bootstrap
- 🔠 FontAwesome
- To run the tests. make sure you are in the project directory
cd tinyapp
- Run
npm test
- The url provided by the user has to start with http ot https otherwise it'll fail
- This is a project for LHL web development bootcamp and is not meant for production use