Coder Social home page Coder Social logo

url's Introduction

URL Shortener Application

Done as a school assignment for the Metropolia University of Applied Sciences.

by Tuomas Pöyry

Setup

The ui folder holds the React application responsible for the frontend. The api folder has the Node.js backend.

Run npm install in both.

UI

For development, simply run npm start. For production, built the UI with npm run build.

NOTE: The apiUrl for GrapthQL is normally configured for production, you can change this in the ui/src/Util.ts file.

API

Create a .env file, and look at the .env.example for guidance.

DB_URL should be a connection string to a MongoDB instance.
MATOMO_SITE_ID and MATOMO_SITE_URL can be left empty to disable Matomo tracking.
JWT_SECRET should be a long random string to encrypt the JWT session tokens with.

GraphQL API Documentation

For the endpoints that require login, append the JWT token that /loginUser gives you to the Authorization header as a bearer token, like so: Authorization: Bearer <TOKEN>.

NOTE: The hash of a shortened link is the part after the last /. So for https://v1a.pw/ABCD the hash would be ABCD.

Mutations

/shortenUrl

Shorten a URL with options.

// The URL to shorten
url: { type: new GraphQLNonNull(GraphQLString) },

// Set to "true" if the shortened URL should be hard to guess
isObscured: { type: GraphQLBoolean },

// Should this URL be linked to the logged in account
isMine: { type: GraphQLBoolean },

// Currently not used
password: { type: GraphQLString },
expiresAt: { type: GraphQLInt },

/updateUrl (Requires login)

Update an existing URL linked to your account.

// The "hash" of the URL that should be updated
hash: { type: new GraphQLNonNull(GraphQLString) },

// The new URL this link should be changed to point to
url: { type: new GraphQLNonNull(GraphQLString) },

/removeUrl (Requires login)

Remove an existing URL linked to your account.

// The "hash" of the URL that should be removed
hash: { type: new GraphQLNonNull(GraphQLString) },

/registerUser

Register a new user.

email: { type: new GraphQLNonNull(GraphQLString) },
password: { type: new GraphQLNonNull(GraphQLString) },

/loginUser

Login with a registered user.

email: { type: new GraphQLNonNull(GraphQLString) },
password: { type: new GraphQLNonNull(GraphQLString) },

Queries

/listOwnURLs (Requires login)

List all URLs linked to the currently logged in account.

/stats

List generic statistics about the site.

url's People

Contributors

munkkeli avatar dependabot[bot] 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.