To allow for a reproducible dev-environment, we use Nix and direnv!
Nix can be easily installed using the Determinate Systems Nix Installer.
Installation & integration instructions for direnv can be found here.
When using Nix flakes with direnv integration, skip right ahead to step 6 in the installation instructions below. The database can be started by running devenv up.
To develop locally without using Nix, follow the instructions below:
- Install Node.js and NPM.
- Install Rancher (or Docker if you prefer/you have a license) and make sure it is running.
- Spin up a postgres database with the following command. You need to choose your own password and username:
docker run --name tech-survey -e "POSTGRES_USER=dummyusr" -e "POSTGRES_PASSWORD=dummypw" -e "POSTGRES_DB=tech-survey" -d -p 5432:5432 docker.io/postgres- Copy
.env.exampleto.envand update theDATABASE_URLvariable with the username and password you chose in the previous step. The default value is:DATABASE_URL="postgresql://dummyusr:dummypw@localhost/tech-survey - Create a secret for AUTH_SECRET by running the following command. Use WSL for this command if you are on Windows.
openssl rand -base64 32-
Ask a co-worker for the Azure credentials or the rights to create an app registration yourself.
- AUTH_MICROSOFT_ENTRA_ID_SECRET: A secret credential created in an app registration.
- AUTH_MICROSOFT_ENTRA_ID_ID: The client ID of the app registration.
- AUTH_MICROSOFT_ENTRA_ID_ISSUER: The tenant ID of the Azure AD.
- AUTH_MICROSOFT_ENTRA_ID_ADMIN_GROUP: The group ID of the Azure AD group that has admin rights in the app registration.
-
Install NPM dependencies using the following command:
npm i- Run the following commands to setup your db locally.
npm run db:generate
npm run db:push- (Optional): You can seed the database with some initial data by running the following command.
npm run db:seedNote that this will delete all survey data (but not accounts) from your database. If you have a csv file with survey data, you can import it by running the following command:
tsx .\prisma\seed.jsFor this, put the csv-file in ./import/survey.csv
- Now you should be ready to go! 🎉 You can check your local database by opening the studio of Prisma. If you followed step 7, you should see that the database has been populated with questions, roles, etc.
npm run db:studioTo run the application, you can use the following command:
npm run devTests are done using Testcontainers & Playwright. To run the tests locally, you must have docker installed.
Use the following command to run the tests:
npm run testIn this project, the code style is enforced by ESLint and Prettier. You can run the following command to check if your code is compliant with the code style:
npm run lintIf you want to automatically fix the code style issues, you can run the following command:
npm run lint:fixYour IDE can help you with this, check out these links:
If you make changes to the database schema, you need to generate a new migration. You can do this by running the following command:
npx prisma migrate dev --name <name-of-your-migration>For more information, look at the Prisma documentation.