URL shortern application, build with React (Frontend) and NestJS (Backend) MYSQL (Database). If you are trying to setup on your local machine, please make sure you clone both server
and client
and setup correclty since we are not combine them.
[email protected]:naysw/url_shortener_server.git
cd your project folder
yarn install
or
npm install
Copy .env.example
to .env
cp .env.example .env
open .env
file and replace with your database crenditials on DATABASE_URL
and ACCESS_TOKEN_SECRET
DATABASE_URL="mysql:https://<user>:<password>@localhost:3306/<database>"
ACCESS_TOKEN_SECRET=
once everything setup correctly, you can start application by running
yarn dev
or
npm run dev
To be able to use demo users, roles, and any others, you will nee to run migration and seed database.
Firt push existing migration to db
yarn prisma db push
or
npm run prisma db push
and seed database
yarn prisma db seed
or
npm run prisma db seed
if you want to go with docker
container
// build docker image
docker build -t url_shortener_server .
// start docker container
docker run -d -p 4000:4000 --env-file ./evn url_shortener_server
Clone react repo
[email protected]:naysw/url_shortener_client.git
cd your project folder
yarn install
or
npm install
start application with localhost
yarn start
or
npm run start
By default, Client will up and running on localhost:3000
and server will be localhost:4000
Once your application is up and running, you can start play around. First, you may need to login to perform certain tasks. you could use below demo credentials
Admin,
username: "admin"
password: "password"
User
username: "user"
password: "password"
Note:: Please login with admin
user to be able to see admin dashboard localhost:3000/admin
that can checking link statistics, deleting link and so on.
- If you follow and seed dummy data as above step, and when you try to make short this
https://google.com
, you will get error response
Sorry! URL with "https://google.com" is not allowed, please try another one
- When you try to access link that already expired, you will got
Gone Exception
{
"statusCode": 410,
"message": "Link is expired",
"error": "Gone"
}