- switch to the postgres user
su postgres
- start psql
psql postgres
- in psql run the following:
CREATE USER shopdb_admin WITH PASSWORD 'pass@2022';
CREATE DATABASE shop_backend;
\c shop_backend
GRANT ALL PRIVILEGES ON DATABASE shop_backend TO shopdb_admin;
- to test that it is working run
\dt
and it should output "No relations found." - For the test database do the following:
CREATE DATABASE shop_backend_test;
\c shop_backend_test
GRANT ALL PRIVILEGES ON DATABASE shop_backend_test TO shopdb_admin;
add the following environment variables to your .env file and replace the placeholders with your values :
POSTGRES_HOST = 127.0.0.1
POSTGRES_PORT = 5432
POSTGRES_DB = shop_backend
POSTGRES_TEST_DB = shop_backend_test
POSTGRES_USER = shopdb_admin
POSTGRES_PASSWORD = pass@2022
ENV = dev
JWT_SECRET = <your_jwt_secret_string>
BCRYPT_PEPPER = <your_bcrypt_secret_string>
SALT_ROUNDS = <the_number_of_salt_rounds>
-
npm install
to install all dependencies -
npm run start-db
to set up the database and get access via http://127.0.0.1:5432 -
npm run build
to build the app
npm run start
to start the app and get access via http://127.0.0.1:3000
-
Set the ENV variable in the .env file to test
-
npm run test
to run all tests
The project uses a number of open source projects to work properly:
- TypeScript - a strongly typed programming language that builds on JavaScript
- node.js - evented I/O for the backend
- Express - fast node.js network app framework
- PostgreSQL - a powerful and open-source RDBMS
- Jasmine - behavior-driven development framework for testing JavaScript code
Distributed under the MIT License. See LICENSE.txt
for more information.