GithubHelp home page GithubHelp logo

tinyapp's Introduction

tinyApp

Intro

These files contain the code necessary to create a fully functioning URL shorterning app, that will only work for you, on your own computer, and won't remember anything you've done once you close it. But it works!

To get this app up and running, clone the repo and run 'NPM Install'. I'm under the impression this will install all the dependencies in the JSON package.

Then run 'npm start', and the express module will do the rest. This app is currently set to run on port 8080, but you can change that by altering the PORT value in the express_server.js file.

The repo consists of:

The express_server.js file.

  • This file contains all of the endpoints for the app. You can run this file from the Terminal with NPM start, and it will create a server running on Port 8080 by default.

  • In its current form this server allows users to create an account, submit URLs for their favorite websites and then store shortened versions of those URLs in a simple library. Users can then share those shortened links, and anyone with the link will be redirected to the original website.

  • Users can register accounts, sign in and out, and the server restricts users from seeing other user's links or accessing most pages without being signed in.

  • It stores hashed passwords, and creates encrypted cookies to track user Ids.

Dependencies

  • Node.js
  • Express
  • EJS
  • bcryptjs
  • cookie-session
  • It also depends on a Javascript file of helper functions called helpers.js.

helpers.js

  • This file contains 4 helper functions used in the main server file.
  • These functions are modular.
  • The simpler two are used to generate random ID values for users or URLs.
  • The more complicated two are used to return a user object from a given databse, if the email on the object matches the email passed in as an argument, OR to return a subset of a databse of URLs, if the URL matches a given userId (contained in a cookie, in this case).

Six EJS files that pertain to all the different web pages that the server can render.

  • Login.ejs displays the login page, where users can enter their email and password to sign in.
  • Registration.ejs displays a page where a new user can sign up with the same info.
  • urls_index is a page that displays stored URLs and their short codes.
  • urls_new is a page where a new full URL can be entered and generates a short code once submitted.
  • urls_show is a page that diplays the newly generated short code for a submitted URL.
  • Finally, _header.ejs is a file that displays a header or toolbar, that is displayed on all other rendered pages as well.
    • It contains a link to submit a new URL, see your stored URLs and codes, as well as displays your logged-in status on the right.
    • If you are signed in, it will display your email and a logout button. If not, it displays a link to the login and registration pages.

Finished Product

"Screenshot of URLs page"

"Screenshot of register page"

tinyapp's People

Contributors

t-smift avatar

Watchers

 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.