A node express server application providing restful api endpoints to manage products and user orders for an online store.
-
npm >= 6.9.0
-
node >= 12.0.0
-
yarn
Run the following command in the projects root folder to install dependencies. All provided yarn commands are run at the root level of the project.
yarn install
The server application is configured to run with a Postgresql database running with the following settings:
- Host: 127.0.0.1
- Port: 5432
- Database user: "shopping_user"
- Database name: "shopping"
- Test database name: "shopping_test"
To set up the database (dev + test), use the following commands in postgresql environment:
CREATE USER shopping_user WITH PASSWORD 'yourpasswordhere';
CREATE DATABASE shopping;
GRANT ALL PRIVILEGES ON DATABASE shopping TO shopping_user;
CREATE DATABASE shopping_test;
GRANT ALL PRIVILEGES ON DATABASE shopping_test TO shopping_user;
A .env file should also be created containing variables with names matching those seen in the database.json file and containing all the settings above.
A .env file is required to hold environment variables for project. Create a .env file and copy the following into it.
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_DB=shopping
POSTGRES_TEST_DB=shopping_test
POSTGRES_USER=shopping_user
POSTGRES_PASSWORD=yourpassword123
ENV=dev
BCRYPT_PASSWORD=your-secret-hash-password-123
SALT_ROUNDS=10
TOKEN_SECRET=wicked-witch-of-the-west
To start the server appplication run the following command.
yarn watch
The application is configured to run on localhost port 3000 - http://localhost:3000.
To run available tests, use following command.
yarn test
This temporarily modifies the ENV key in environment variables from 'dev' to 'test' and runs migrations to setup the test database to be used for testing. The test database is pulled down after tests are complete.
The following command can be used to compile and build the project from typescript to javascript.
yarn build
Once the build is complete the built project can be found in the dist folder. To start the built application you can run the following command in the root folder of the project.
node dist/.
👤 Amy Turnah
- Github: @amexaCree
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator