Guide for contributors
You will need npm as a package manager and build runner.
Run ./scripts/install.sh
from the top level of the Vaken repository. Note that the variables in
the new .env
file will need to be changed to valid values.
Installing MongoDB:
You will need a MongoDB instance running in order for the application to work correctly. We recommend using MongoDB Atlas to set up a cluster. Another option is to install MongoDB locally and run it.
In addition, we recommend getting MongoDB Compass to view and edit data easily.
npm run dev # runs backend + frontend, both reloading on changes
Now to go localhost:8081
to see the page.
NOTE: you can also go to localhost:8080/graphql
to see an interactive GraphQL IDE to try out queries and mutations (disabled in production env by default).
To create a production build, run npm build
.
We use Jest for testing. Snapshot testing is mostly for frontend, while mocking is preferable for backend.
Our local jest tests use the --only-changed
option, which runs tests only for files that are actually changed, to speed up testing. NOTE: the CI will run all the tests regardless.
Jest configs are split using projects into specific backend and frontend configurations (see ./jest.config.js)
Running tests
npm run check:test # runs only changed tests
npm run check:test:ci # runs all tests
We use Eslint for linting. The linting tests are cached with the --cache
option.
NOTE: there are multiple eslint files. The rules are cascaded with the rule in the more specific directory taking priority (see Eslint cascading hierarchy)
- client-specific config: ./src/client/.eslintrc.js
- common (shared between server+client) config: ./.eslintrc.js
npm run check:lint # runs the linter
npm run check:lint:fix # runs the linter with autofix
/__mocks__
- mocks for testing/__snapshots__
- jest snapshots for frontend testing/.vscode
- vscode workspace settings, recommended plugins, and launch debug config/scripts
- runnable scripts to do certain tasks (install, populate DB, make an organizer, make a volunteer, etc.)/src
/client
/assets
- static assets/routes.js
- all frontend routes mapped to React components
/components
- all frontend components/contexts
/generated
- autogenerated files, don't modify/routes
/common
/server
/auth
- authentication/generated
- autogenerated files, don't modifyindex.ts
- main Express API server and Apollo Servermodels.ts
- graphql modelsresolvers.ts
- graphql resolvers
/types
- misc. type declaration files// lots of config files here
NOTE: We use dotansimha/graphql-code-generator for automatic code generation. The mappings for schema models to db models are in ./codegen.json.
Schemas:
- ./src/common/schema.graphql.ts - main schema, shared among server and client
- ./src/client/routes/team/teams.graphql.ts - team data
- ./src/client/routes/profile/user.graphql.ts - for a specific user
- ./src/client/routes/manage/hackers.graphql.ts - hacker table
- ./src/client/me.graphql.ts - personal logged in user
Models: In ./src/server/models.ts
Resolvers: In ./src/server/resolvers.ts
We use:
- Jest for testing
- Circle CI
- Eslint (there's a different config for server and client)
- Prettier (can be used with
npm format
but we also use the eslint integration) - Ts-node-dev for auto reloading server
- dotansimha/graphql-code-generator for automatic code generation
- Webpack Dev Server
- TypeDoc - for documentation
- Dependabot Preview - makes PRs for dependency upgrades (set to monthly updates, configure in Dashboard
- Codecov - creates code coverage report for each PR, works with Circle CI
In this repo, Github Actions are used for:
- delete merged PR branches