The following steps will walk you through setting up a PostgreSQL database and tables required for this service.
- Ensure you have
postgresql
installed and running on your machine. If you are using MacOS with Homebrew you can get set up by running the following:
brew install postgresql
brew services start postgresql
- Open up the PostgreSQL shell and create a user with permissions to create a database.
psql postgres
CREATE ROLE rest_user WITH LOGIN PASSWORD 'password';
ALTER ROLE rest_user CREATEDB;
- Again, connect to the PostgreSQL shell, this time with the newly created user.
psql -d postgres -U rest_user
- Create a new database and connect to it.
CREATE DATABASE treez_api;
\c treez_api;
-
Run the SQL queries in
/init.sql
to set up the necessary tables. -
Modify the environment variables in
/.env
to match your development environment.
To start the development server:
-
Install dependencies (
npm i
) -
Build TypeScript files to
/dist
(npm run build
) -
Run npm
start
script (npm start
)
Assuming you have installed project dependencies and built TS files to /dist
, you can run the tests with the npm script test
(npm test
).