Build - sardothien/BuyAndDrive Wiki

Building backend

In order to build backend you need to position yourself inside of the server folder and then run:

npm i

This installs needed npm packages.

After you've done that, for local development purposes, you need to prepare local Postgres database.

The local development Postgres database is set up using the provided Dockerfile in the root of the project. To generate a docker image, navigate to the root folder of the project and run:

docker build -t kupi_i_vozi_database .

To start the database server on the localhost port 5432, run:

docker run -dp 5432:5432 kupi_i_vozi_database

In order for Node application to be able to connect to the database, create the .env file, using the .env.example as a template and fill in the information about the database.

For the local development database described in the Dockerfile, you can use the following connection string:

PGCONNECTION_STRING=postgresql://root:[email protected]:5432/kupi_i_vozi

Last thing you need to do, which is optional, is to populate database with some already existing values so you can start testing right away. You can do that with the following command:

npm run import-data

To start local development server run:

npm run start

To create build for deployment run:

npm run build

Building frontend

In order to build backend you need to position yourself inside of the server folder and then run:

npm i

This installs needed npm packages.

Make sure to have environment.local.ts file prefilled with valid values. See environment.ts to see what values are needed.

To run code in local environment run:

npm run start

To create build for deployment run:

npm run build

Sending emails

You will need throwaway gmail account where you should turn ON access to less secure apps. Go to account settings >> security and you should see the option. Keep in mind that it could be turned off without your input, don't know why, looks like default Google behavior. If the sending fails, you should check that.

Using JWT

Value for JWT_SECRET_KEY in .env file can be whatever you like, as long as it's encoded to BASE64. See this site to get that done: http://www.unit-conversion.info/texttools/base64/

Same goes for every other JWT-related variable.

Setting up Google Auth