Skip to content

Dueet-Live/backend

Repository files navigation

Dueet-Live Backend

Dueet Live Logo

The backend of Dueet-Live!

Development Setup

Install dependencies

npm install

Start Postgres server

Start the Postgres server and create a database called dueet-live (or any name you like).

Sample SQL command:

CREATE DATABASE "dueet-live";

Configure the environment variables

First, create a .env file from the template.

cp .env.example .env

Then, modify .env to change the configuration options. In particular, you might need to change the database URL. Remember to use the database name that you created in the previous step.

Seed the database

Seed the database with initial songs and genres by running

npm run build
npm run seed

Build and run the project

Run the following 3 commands in 3 different terminal windows.

npm run watch:build
npm run watch:rest
npm run watch:ws

This will let nodemon observe file changes and automatically recompile the server as you modify the files.

Manipulating the database

To drop the database, run

npm run db:drop

To synchronise the database schema with the entities in the source code, run

npm run db:sync

Remember to re-seed after you re-create the database.

To drop, sync, and then reseed the database, run

npm run reseed

You might also be interested in other npm scripts. Take a look at package.json.

Caveats

The database schema is set to automatically update whenever the entities change. When this happens, all the pre-existing data is lost.