ShortURL is a URL shortener web app built from scratch for a technical interview.
The app is hosted on Heroku which automatically deploy the branch main
: https://shorturl-demo.herokuapp.com/
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
GraphQL playground: http://localhost:4000/graphql
If you want to edit the frontend you should run webpack instead:
cd packages/frontend
npm run start
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
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.
- Backend:
- NodeJS
- Typescript
- GraphQL
- graphql-code-generator
- Apollo
- Koa
- Prisma2
- TypeGraphQL
- postgresql
- Jest
- Frontend:
- Typescript
- React
- create-react-app
- GraphQL
- Apollo
- Material UI
- Jest
- 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