An open-sourced backend service for Resell.
Make sure that npm
installed (nvm
is recomended to manage node versions.)
Depending on preference, either run yarn install
or npm install
to ensure
all required dependencies are installed. Copy the .env_template
to either a
.env
file , and update with necessary credentials. Sourcing the file is not
necessary.
Steps to install Postgres:
brew update
brew install postgresql
brew services start postgresql
initdb /usr/local/var/postgres
psql postgres
create user postgres with password 'postgres';
alter user postgres with superuser;
create database "resell-dev";
In order to connect to the database, follow these steps:
Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Update Homebrew to ensure you have the latest information
brew update
Install pgAdmin
brew install --cask pgadmin4
Open pgAdmin and configure the connection using the defined user and password.
To create/update the database objects, run:
npm run db:migrate
This project includes a mechanism for seeding consistent data for the development environment using TypeORM and typeorm-seeding. The seeders generate users, posts, feedback, reviews, reports, and requests, ensuring all developers work with the same data set.
To seed the database for development, use the following command:
npm run db:seed
The seeding script checks the environment to ensure it only runs in the development environment. If the environment variable IS_PROD
is set to "true"
, the seeding process will be skipped to prevent accidental execution in production.
The factories and seeders are configured to generate consistent data that is shared across all development environments. This allows developers to have predictable data while working on the project.
index
to differentiate between records.SeedInitialData
) handles the creation of all entities, ensuring relationships are properly established.This consistent seeding process ensures that all developers work with the same initial data, making it easier to test features and maintain alignment across the team.
To run in a development environment, open two terminal tabs. In one, run either
yarn dev
if using yarn, or npm run dev
otherwise. This command will
watch the TypeScript files for changes and recompile the JavaScript whenever an
update occurs. If the compilation succeeds, it will restart the server with the
changes applied.