Code Monkey home page Code Monkey logo

shorturl's Introduction

ShortURL

ShortURL is a URL shortener web app built from scratch for a technical interview.

Demo

The app is hosted on Heroku which automatically deploy the branch main: https://shorturl-demo.herokuapp.com/

Usage

Install the dependencies:

npm install

For local testing, you need to have postgresql installed. Then please create a database shorturl, an super admin with name shorturl and password shorturl too:

backend git:(main) ✗ sudo -u postgres -i
postgres@antoine-aero:~$ createuser --interactive --pwprompt
Enter name of role to add: shorturl
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y
postgres@antoine-aero:~$ createdb shorturl

You also need to init the database:

psql postgresql://shorturl:shorturl@localhost:5432/shorturl -f packages/backend/prisma/init.sql

Build the packages:

npm run build

Start the backend which also serve the frontend:

npm run start

App: http://localhost:4000

GraphQL playground: http://localhost:4000/graphql

Contributing

If you want to edit the frontend you should run webpack instead:

cd packages/frontend
npm run start

App: http://localhost:3000

If you change the GraphQL schema in the backend or the queries/mutations in the frontend, you will have to regenerate the types for the frontend package:

cd packages/frontend
npm run codegen

Tests

Both the frontend and the backend packages are configured to use Jest.

You can run the tests by running npm run test in the package folder.

Note: There are no frontend tests implemented yet.

Stack

  • Backend:
    • NodeJS
    • Typescript
    • GraphQL
    • graphql-code-generator
    • Apollo
    • Koa
    • Prisma2
    • TypeGraphQL
    • postgresql
    • Jest
  • Frontend:
    • Typescript
    • React
    • create-react-app
    • GraphQL
    • Apollo
    • Material UI
    • Jest

Things missing

  • More unit tests
  • Handle errors & loading states
  • Use subscriptions instead of pooling to refresh the lists
  • Update the cache when deleting/adding ShortURLs instead of refetching everything

shorturl's People

Watchers

Baptiste Marchand avatar Sébastien LE MOIGNE avatar Nicolas Barray avatar CHaBou 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.