Skip to content

JosefJantzen/UniTasks

Repository files navigation

UniTasks

UniTasks is a todo web app specifically for your university todos. But it's not limited to that.
The backend is written in Go and the frontend in Vue.js 3. The databsae is a CockroachDB.
You can test UniTasks here.

Installation

  1. Create a new directory for example uni-tasks
  2. Create a .env file and define the following attributes:
BACKEND_CONFIG="/home/<user>/uni-tasks/config.json" # Full path to your config.json

DB_DATABASE="unitasks" # The name of the database that is created if not existing.
DB_CERTS_DIR="/home/<user>/uni-tasks/certs" # Full path to your generated certificates

SERVER_ALIASES="localhost 127.0.0.1 db" # All the possible host names of your database. These are used to generate the certificates. 
  1. Create your own config.json file as described here
  2. Run the following command to install the server. Note: You have to install cockraoch before that and add it to the PATH
curl -s https://raw.githubusercontent.com/JosefJantzen/UniTasks/main/gen-certs.sh -O ; chmod +x gen-certs.sh ; ./gen-certs.sh ; curl -s -o docker-compose.yml https://raw.githubusercontent.com/JosefJantzen/UniTasks/main/docker-compose.prod.yml ; sudo docker compose up -d
  1. Connect to your databse instance
docker exec -it uni-tasks-db ./cockroach sql --certs-dir=/certs
  1. Create a user with password for your database and grant him access to the database:
CREATE DATABASE unitasks;
CREATE USER api WITH PASSWORD '<password>';
GRANT ALL ON DATABASE unitasks TO api;
  1. Restart your rest server to connect again to the database
sudo docker restart uni-tasks-rest-server
  1. You should now find the frontend at localhost:8082, the api at localhost:8081 and the database dashboard at localhost:8180.

Config

If you don't have a config file or it doesn't contains all the attributes the default values are defined in here. Your config.json should look like this:

{
    "port": "8080",
    "jwtKey": "SecretYouShouldHide",
    "jwtExpireMin": 5,
    "frontendUrl": "http://localhost:8080"
    "DB": {
        "user": "totoro",
        "pwd": "whatever",
        "host": "db",
        "port": "26257",
        "database": "unitasks",
        "initial": "DB-initial.pgsql",
        "testData": "DB-test-data.pgsql"
    },
}
Attribute Description Default value
port Port of the backend. You don't need to change it normaly because it's only the port inside the docker container and the outside port is configured in the docker file anyways. 8080
jwtKey The secret key used to generate the json web tokens. SecretYouShouldHide
jwtExpireMin The time in minutes after the generated jwt will expire. You should choose a relatively small time here. 5
frontendUrl The url your frontend has. It's used in the backend for the CORS-Policy. http://localhost:8080

DB config

Attribute Description Default value
user The user you created in your database for the api. totoro
pwd The password of the databse user. This is only in production mode necessary with a secured database. whatever
host The address to the database instance. You can use here the internal hostnames of the docker containers. db
port The port of the database instance. 26257
database The name of the database that should be used. unitasks
initial A sql file that is executed on startup of the rest server DB-initial.pgsql
testData A sql file that is executed after the initial file if the enviroment variable DEBUG is set to true. DB-test-data.pgsql