This is the backend for the Cleaning List Webapp (v2).
Note: All commands are written to work on *nix systems, everything should work on Windows as well but some commands may need to be altered, e.g. cp .env.example .env
-> copy .env.example .env
.
- Docker
- Node
- Yarn
yarn
, install dependenciesyarn db:create
, create an image for the databaseyarn db:start
, start the containercp .env.example .env
, create an env fileyarn migrate dev
, perform migrationsyarn seed:users
, (optional) create sample usersyarn dev
, start the development server
In order to test email services, i.e. password reset, you must add email configuration the .env
file. You can use any Gmail account for this. Note: this does not mean that it has to end with @gmail.com
, it just has to be managed by the Gmail client.
EMAIL_USERNAME
Any email address connected to Google, e.g. [email protected]
or [email protected]
.
EMAIL_PASSWORD
Gmail doesn't allow SMTP connections using users' regular passwords. Instead you have to set up an App password.
App passwords can be found in a google account's settings in Security under Signing in to Google. 2-Step Verification must be enabled in order for App passwords to be available.
Select Other under Select app and give the password a name, e.g. nodemailer
or cleaning-list-be
.
EMAIL_USERNAME="[email protected]"
EMAIL_PASSWORD="xlygfluhgrquikhc"
Code style is maintained using prettier.
Commands:
yarn lint
to check styling, will only verify that styling is correctyarn format
to fix styling, will find style errors and resolve them if possible
Code style is automatically checked by GitHub when work is pushed.
Testing is performed using jest
, jest-when
, and supertest
, with faker
providing sample data.
yarn test
is used to run the complete test suite, after making sure dependencies are installed.
Tests are automatically run by GitHub when work is pushed.
If you wish to only run the tests of one file you can specify a pattern to select the file using yarn test <pattern>
. Jest uses regex to pattern match for files, so the pattern doesn't need to be an exact filename, just unique enough to select only the file you want.
yarn test authentication
will run tests intest/src/utils/authentication.test.ts
yarn test server
will run tests intest/src/server/user.routes.test.ts
andtest/src/server/list.routes.test.ts
yarn test user.routes
will run tests intest/src/server/user.routes.test.ts
(note thatyarn test user
would run all tests depending on the system if there's aUser
directory somewhere above where the project is located)
If you wish to run only describe block or test you can specify a pattern to select the describe block/test using yarn test -t <pattern>
. Jest uses regex to pattern match for tests, so the pattern doesn't need to be the exact name, just unique enough to select only the describe block/test you want.