/yaus

Yet Another URL Shortner

Primary LanguageTypeScript

Yet Another URL Shortener

Batteries included URL Shortener that is designed for speed and scalability.

Design

Docs here

Installation

Prerequisites

To run this project, you need to have the following prerequisites installed:

Setup

  1. Clone the repository:
git clone https://github.com/Samagra-Development/yaus.git
  1. Navigate to the project directory:
cd yaus
  1. Create environment file:
cp sample.env .env

you may need to change few thing in .env file according to you environment.

  1. Start the project using Docker Compose:
docker-compose -f docker-compose.local.yml up -d

The -d flag is used to run the containers in the background (detached mode). If you want to see the container logs, you can omit the -d flag.

Docker Compose will read the docker-compose.local.yml file and start the defined services.

  1. Verify that the containers are running:
docker-compose -f docker-compose.local.yml ps

This command will display the status of the containers defined in the docker-compose.local.yml file.

  1. Run migration in the database
docker-compose -f docker-compose.local.yml exec yausapp bash

npx prisma migrate dev --schema=apps/api/src/app/prisma/schema.prisma

exit

First command will drop you into docker container and second command will run the migration and third will simply pull you out from container.

  1. Seed data in the database (Optional)
docker-compose -f docker-compose.local.yml exec yausapp bash

npx prisma db seed

exit

This command will seed the dummy data.

  1. If everything is set up correctly, you should be able to access your application at localhost:3000/api. If this opens swagger ui your setup is correct.

Note: You may want type hints as you code for that we would suggest you to install node 16 and yarn 1 and run command yarn install for installing local node modules. Do note that this is only for getting type hints and syntax highlighting. Docker will only be using node_modules that is inside the container. If you make any changes to package.json then you have to rebuild the container using docker-compose -f docker-compose.local.yml up -d --build

Contributing

It is recommended to develop on Gitpod since everything is coupled with a bunch of dependencies. To start your Gitpod session click on the button below.

Open in Gitpod

The repo is structured as a monorepo using the Nx.