Website for learning how to code from unique perspectives
This project uses Nx to manage the monorepo and npm as the package manager. To use nx commands, install nx CLI globally:
npm i -g nx
Navigate to codewit.us/codewit/ and create a .env file with the following content (replace with your real values):
# FrontendYT_KEY='YOUR YOUTUBE API KEY'YT_CHANNEL_ID='YOUR CHANNEL ID'# BackendGOOGLE_REDIRECT_URL="GOOGLE AUTH REDIRECT URL"GOOGLE_CLIENT_ID="YOUR CLIENT ID"GOOGLE_CLIENT_SECRET="YOUR SECRET"COOKIE_KEY="ANY ALPHANUMERICAL STRING"# DatabaseDB_HOST=DB_HOSTDB_USER=DB_USERDB_PASSWORD=DB_PASSDB_NAME=DB_NAMEDB_PORT=PORT_NUMFrom the codewit directory, you can run nx commands
Running front end:
nx serve clientRunning back end:
nx serve apiRunning both frontend and backend using docker-compose with watching for file changes enabled:
docker-compose up -d && docker compose watch.This will start the frontend, backend and the db in separate containers and watch for file changes in the
codewitdirectory.To stop the containers, run
docker-compose down, as doingCtrl+Cwill not stop the containers. it will stop the watcher but the containers will still be running.To view logs from each container use
docker logs -f <container-name>.
The codewit.us/codewit/api/src/scripts/seed-admins.ts file is used to seed the database with admin users. This can be done in two ways: manually using the npm command or with the provided seed.sh script, which not only handles environment variables but also provides options for both admin and data seeding.
To manually seed admin users, ensure the required environment variables are set in a .env file or exported in your terminal. Here are the necessary variables:
DB_HOST=localhostDB_USER=codewitus_userDB_PASSWORD=12345DB_NAME=codewitus_dbDB_PORT=5432Once the environment variables are set, you can run the npm command directly. For example, to seed admin users with the emails abc@example.com and def@example.com, run:
npm run seed-admins -- --admin abc@example.com def@example.comThe seed.sh script automates environment variable setup, as well as admin and data seeding, making it easier to initialize the database. The script checks for required environment variables, setting any missing ones to default values, and provides options for various seeding needs.
To seed emails as admins using seed.sh execute the following:
./seed.sh -e abc@example.com def@example.comTo seed the database with general data, using a single emial for roster setup, run:
./seed.sh -d abc@example.comTo seed the database with both admin emails and general data (using the first email for data seeding), run:
./seed.sh -b abc@example.com def@example.comIf your machine already has a local Postgres instance running on the default port (5432), you can specify a different port when running the seed script using the -p flag:
./seed.sh -p 5440 -e abc@example.comFor more details on all available options, you can use the -h flag to display the help information, which lists each command and provides usage examples.
See the contributing guide.
An overview of the features of the software is available in our roadmap