This file is intended for developers. It provides details on the project's structure and instructions on how to work with it.
Common:
types
- Declarations of interfaces and constants, used in different packages.
Client-side (browser):
procaptcha-bundle
- Displaying captcha widgetprocaptcha-frictionless
procaptcha-react
(image)procaptcha-pow
Server-side (node.js):
provider
- API Endpoints for the captcha widgetcli
- CLI wrapper for theprovider
, that startsExpress
database
- Mongo DB Query buildertypes-database
- declaration of interfaces and types used in the Query builder
If your IDE supports biome
(directly, or via plugin), you can configure it to work with the /biome.json
).
dapp
,dappAccount
=clientId
=siteKey
in the portaluser
,userAccount
=userId
- Installation:
npm install
- Building packages:
npm run build:all
- Building the bundle:
npm run build:bundle
- Lint checks:
npm run lint
- Lint formatting fixes:
npm run lint-fix
This step should be done only once, after the repository has been cloned, then this step should be omitted.
To set up the environment for testing, run the following commands:
cp demos/client-example-server/env.development demos/client-example-server/.env.test
cp demos/client-example/env.development demos/client-example/.env.test
cp demos/client-bundle-example/env.development demos/client-bundle-example/.env.test
cp dev/scripts/env.test .env.test
cp dev/scripts/env.test dev/scripts/.env.test
cp dev/scripts/env.test packages/cli/.env.test
cp dev/scripts/env.test packages/procaptcha-bundle/.env.test
The DB is necessary for all kind of the tests. Since the DB is docked, to start the DB service run the following:
docker compose --file ./docker/docker-compose.test.yml up -d --remove-orphans --force-recreate --always-recreate-deps
Note: After the testing is done, stop it using the down
command:
docker compose --file ./docker/docker-compose.test.yml down
This command should be called once per the container lifetime, and adds the initial data, like domains, siteKeys, etc.
NODE_ENV="test" npm run setup
Launch services:
NODE_ENV=test npm run start:provider:admin
Provider:admin
service is required for theprovider
unit tests.
Run all the unit tests:
npm run test
- The command will loop through all the
package/*
folders, and run individual unit tests for each package.
Tip: You can also run package-related unit tests individually, by running npm run test
inside the target package
folder.
Launch services:
npm run -w @prosopo/client-example-server build && NODE_ENV=test npm run start:server
NODE_ENV=test npm run start:demo
NODE_ENV=test npm run start:provider:admin
Run tests:
NODE_ENV=test npm run -w @prosopo/cypress-shared cypress:open:client-example
Launch services:
npm run -w @prosopo/client-example-server build && NODE_ENV=test npm run start:server
NODE_ENV=test npm run start:demo
NODE_ENV=test npm run start:provider:admin
NODE_ENV="development" npm -w @prosopo/procaptcha-bundle run bundle
NODE_ENV=test npm run start:bundle
Run tests:
NODE_ENV=test npm -w @prosopo/cypress-shared run cypress:open:client-bundle-example