A simple URL shortener written in Next.js and Postgres.
You can run sURLs in two ways: either by running it directly on your machine, or by running it in a Docker container.
To run sURLs, you must have a PostgreSQL database in place for storing data. In the context of Docker, a database will be automatically bundled when employing the docker/common.yml
configuration. However, if you opt for docker/app.yml
(which solely dockerizes sURLs without including any databases), or if you run sURLs directly on your local machine, you will need to arrange for your own database. In the former case, make sure the database is already running before setup.
To ensure proper configuration of the database URL and the administrative password for the /admin page, you will also need a .env
file. Here are the instructions for different scenarios:
-
Running on Docker:
- If you opt for
docker/common.yml
, duplicatedocker/.env.docker.common.example
, then rename the copy to.env.docker.common
. Afterward, modify the values for thePOSTGRES_PASSWORD
andAUTHENTICATION_PASSWORD
properties as desired. - If you opt for
docker/app.yml
, duplicatedocker/.env.docker.app.example
, then change the name to.env.docker.app
. Update thePOSTGRES_URL
property to match the details of your external database. Also, set theAUTHENTICATION_PASSWORD
property to your preferred password.
- If you opt for
-
Running locally:
- Duplicate
env.example
and name the duplicate as.env
. Then, replace the values of thePOSTGRES_URL
property to match the details of your external database. Also, set theAUTHENTICATION_PASSWORD
property to your preferred password.
- Duplicate
-
Build & Run Project Run
npm run quick_start
to automatically setup and run the project. -
Access sURLs Service: Access the sURLs service at http://localhost:3000.
-
Build & Run Project: You can start the Docker container using one of the following commands:
- To launch sURLs along with a bundled Postgres database, cd into the root folder, then use:
docker compose -f ./docker/common.yml up -d
- If you want to run only sURLs without the bundled database:
docker compose -f ./docker/app.yml up -d
-
Access sURLs Service: Access the sURLs service at http://localhost:3000.
npm run setup
npm run dev
sURLs allows you to edit or remove your URLS in the /admin
page. However, to
hinder unauthenticated access, authentication has been added by means of a
password. To set it, edit the AUTHENTICATION_PASSWORD
property in your env file.
You can configure sURLs by going to config.ts
in the src
directory. Options
include:
custom_id_regex
: A regex which the custom ID has to match. Default^[a-zA-Z0-9_-]+$
.id_length
: The length of the generated and custom IDs. Default5
.