There's a docker-compose.yml
in the root folder that includes backend, frontend, migrations, Redis, pgadmin 4, and a PostgreSQL database.
To build, ensure that the environment files are in the env
folder. Set up the environment variables and execute the following:
docker compose up
You're good to go!
Setup environment variables in the env
directory. Ensure your database server and Redis server (if applicable) are accessible. Then run the following commands:
yarn install
yarn frontend:build
NEXT_PORT=3001 yarn root:start
You're good to go!
To configure, use .env
files or pass variables to your environment.
NOTE: Some package.json
commands require environment variables set.
.backend.env
- Copy theenv/examples/.backend.env
file to theenv
directoryAPP_PORT
- The port on which the Express.JS server will be startedPOSTGRES_HOST
,POSTGRES_PORT
,POSTGRES_USER
,POSTGRES_PASSWORD
, andPOSTGRES_DB
are settings for PostgreSQLREDIS_REQUIRED
,REDIS_URL
- Use Redis? The application will fail if it cannot connect to the Redis serverACCESS_CONTROL_ALLOW_ORIGIN_HEADER
- Access-Control-Allow-OriginJWT_TOKEN_SECRET
- Secret key for signing JWT tokensLOG_LEVEL
- Log levelTEST_LOG_LEVEL
- Log level for testingUSER_EX
,USER_PERMISSIONS_EX
,POST_EX
,POST_REPLIES_EX
,HOT_TAGS_EX
, andVOTE_EX
- Cache expiration time for different records. Time is given in secondsNODE_ENV
.frontend.env
- Copy theenv/examples/.frontend.env
file to theenv
directorySERVER_URL
- URL of the backend server, NOTE: This variable cannot be changed after the frontend has been built. This is because any calls to process.env will simply be replaced with values from the environment. dotenv-webpackNEXT_PORT
- The port on which the Next.JS server will be startedCYPRESS_URL
- URL for Cypress to testNODE_ENV
-
Backend
backend:start
- Starts the backend serverbackend:dev
- Starts the backend server with nodemonbackend:migrate
- Runs Knex migrationsbackend:seed
- Seeds the databasebackend:test
- Runs Jest tests and fails if code coverage is below global thresholdsbackend:lint
- Runs ESLint against backend code
-
Frontend
frontend:test
- Runs Cypress tests against frontend codefrontend:test:open
- Opens Cypressfrontend:test:report
- Reports code coverage and fails if code coverage is below global thresholdsfrontend:test:full
- Starts backend and frontend servers and then runs Cypress tests against frontend code. NOTE: RequiresAPP_PORT
andNEXT_PORT
environment variables to be set
frontend:dev
- Starts the Next dev server. NOTE: RequiresNEXT_PORT
environment variable to be setfrontend:start
- Starts the Next production server. NOTE: RequiresNEXT_PORT
environment variable to be setfrontend:build
- Generates an optimized version of the frontend application for productionfrontend:lint
- Runs ESLint against frontend code
-
Root
root:lint
- Runs ESLint against backend and frontend coderoot:dev
- Starts backend and frontend dev serversroot:start
- Starts backend and frontend production servers