The Captcha Service allows to generate new captchas and to validate previously generated captchas. Read the Overview and the Usage documentation for more details.
Install the dependencies:
npm install
Run the tests:
npm run coverage
In order to run the Captcha Service locally you must first install node and docker.
Install the dependencies:
npm install
Spin up a mongodb docker container:
npm run start:mongodb
Start the server:
npm run dev
Start the service locally following these steps.
Generate a new captcha with the /generate-captcha endpoint:
curl -X POST "http://127.0.0.1:3000/generate-captcha"
Save the captcha id, copy paste the captcha svg tag in a viewer like this one and read the captcha text.
Validate the captcha with the /validate-captcha endpoint, adding the captcha id and the captcha text in the request body:
curl -X POST "http://127.0.0.1:3000/validate-captcha" \
-H "Content-Type: application/json" \
-d '{"id":"$CAPTCHA_ID", "text": "$CAPTCHA_TEXT"}'
Build a docker image:
docker build -t captcha-service:0.1.0 .
Run a container passing the MONGODB_URI
environment variable with an .env
file:
docker run -p 3000:3000 --env-file=.env captcha-service:0.1.0