This project is built using Deno and MongoDB as a dependency. The goal of this project is to create and manage chronometers that, upon finishing their countdown, send a request to an endpoint with the data configured at the time of scheduling.
Follow these steps to get the project up and running:
First, you need to set up MongoDB with a ReplicaSet. To do this, use the following commands:
openssl rand -base64 756 > ./keyfile
chmod 600 ./keyfile
docker run -d --name mongo -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=adminpassword -p 27017:27017 -v ./keyfile:/etc/mongo-keyfile:ro mongo --replSet rs0 --keyFile /etc/mongo-keyfile
docker run -it --rm --network container:mongo mongo:6.0 mongosh --host localhost --authenticationDatabase admin -u admin -p adminpassword
rs.initiate({ _id: "rs0", members: [ { _id: 0, host: "localhost:27017" }] });
rs.status();
Ensure that your environment variables are properly set up. You can add them to a .env
file or set them directly in your environment.
To build the project, use the following command:
docker build -t chronometer .
After building the project, you can run it using Docker with the following command:
docker run -p 8080:8080 chronometer
To schedule a new chronometer, use the following curl
command:
curl --location 'localhost:8080/api/ms/chronometer' --header 'Content-Type: application/json' --data '{
"reference_id": "1123",
"seconds_for_run": 100,
"request_config": {
"headers": {"prueba": "prueba"},
"url": "https://chronometerbb.free.beeceptor.com",
"method": "POST",
"body": {"pepe": "sabe"}
}
}'
To delete a chronometer, use the following curl
command with the chronometer's ID:
curl --location --request DELETE 'localhost:8080/api/ms/chronometer/1123' --data ''
To check the status of a chronometer, use this curl
command with the chronometer's ID:
curl --location 'localhost:8080/api/ms/chronometer/1123' --data ''
- Deno: JavaScript/TypeScript runtime
- MongoDB: NoSQL database with ReplicaSet
- Docker: Containerization of the application
This project is licensed under the MIT License - see the LICENSE file for details.