Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dacurse/url-shortener
A URL shortener made with React and NestJS.
https://github.com/dacurse/url-shortener
lerna material-ui monorepo nestjs react react-query typeorm typescript url-shortener
Last synced: about 7 hours ago
JSON representation
A URL shortener made with React and NestJS.
- Host: GitHub
- URL: https://github.com/dacurse/url-shortener
- Owner: DaCurse
- License: gpl-3.0
- Created: 2021-07-05T17:24:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-03T14:14:48.000Z (over 2 years ago)
- Last Synced: 2023-03-04T18:02:07.277Z (over 1 year ago)
- Topics: lerna, material-ui, monorepo, nestjs, react, react-query, typeorm, typescript, url-shortener
- Language: TypeScript
- Homepage: https://url.dacurse.xyz
- Size: 1.37 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# url-shortener
[![Build Status](https://app.travis-ci.com/DaCurse/url-shortener.svg?branch=master)](https://app.travis-ci.com/DaCurse/url-shortener)
## Motivation
This project is a URL Shortener made using [Lerna](https://lerna.js.org/), [NestJS](https://nestjs.com/), [TypeORM](https://typeorm.io/#/), [React](https://reactjs.org/), [material-ui](https://next.material-ui.com/) and [React Query](https://react-query.tanstack.com/).
I made it mostly for practice and to get familliar with some specific concepts:
- Working with a monorepo
- Testing a NestJS app
- Using React with TypeScript and material-ui
- Working with react-query
- Deploying the whole app using DockerThe app is currently deployed on my website at https://url.dacurse.xyz/, using `docker-compose`, the rest of my website's configuration can be found [here](https://github.com/dacurse/website).
## Running the app
### Migrating database
To create the database, we can run the provided migrations.
Clone and cd into the repository:
```
git clone https://github.com/DaCurse/url-shortener.git
cd url-shortener
```Install dependencies:
```
yarn
```Create an empty file for your database:
```
mkdir /tmp/data
touch /tmp/data/db.sqlite
```cd into the backend package and pass the path to your database in `DB_PATH`:
```
cd packages/backend
NODE_ENV=production DB_PATH=/tmp/data/db.sqlite yarn typeorm migration:run
```Now your database should have the required structure for the app to work.
### Docker
You can pull a pre-built image from Docker Hub:
```
docker pull dacurse0/url-shortener
```Or build one yourself:
```
docker build https://github.com/DaCurse/url-shortener.git -t dacurse0/url-shortener:latest
```#### Running the image
Make sure to mount the directory with your database which should be named `db.sqlite` (In this example `/tmp/data` is used).
```
docker run -d \
--restart unless-stopped \
--name url-shortener -p 80:80 \
--mount type=bind,source=/tmp/data,target=/data \
dacurse0/url-shortener:latest
```Or with `docker-compose`:
```yml
---
version: '2.1'
services:
url:
image: dacurse0/url-shortener:latest
container_name: url-shortener
restart: unless-stopped
volumes:
- /tmp/data:/data
ports:
- 80:80
```