This is a sample tools service for Opal using the TypeScript SDK. It provides two tools:
- Greeting Tool: Greets a person in a random language (English, Spanish, or French)
- Today's Date Tool: Returns today's date in the specified format
# Install dependencies
npm install
# Run in development mode
npm run dev
# Or build and run
npm run build
npm start# Build the Docker image
docker build -t opal-sample-tools-typescript .
# Run the container
docker run -p 3000:3000 opal-sample-tools-typescriptOnce the service is running, you can access:
- Discovery endpoint: http://localhost:3000/discovery
- Tools endpoints:
- Greeting tool: http://localhost:3000/tools/greeting
- Today's date tool: http://localhost:3000/tools/todays-date
curl -X POST http://localhost:3000/tools/greeting \
-H "Content-Type: application/json" \
-d '{"name":"John"}'Response:
{
"greeting": "Hello, John! How are you?",
"language": "english"
}curl -X POST http://localhost:3000/tools/todays-date \
-H "Content-Type: application/json" \
-d '{"format":"%B %d, %Y"}'Response:
{
"date": "March 18, 2023",
"format": "%B %d, %Y",
"timestamp": 1679145600.0
}