https://github.com/amdev9/medusa-store
medusajs endpoint implementation
https://github.com/amdev9/medusa-store
Last synced: about 9 hours ago
JSON representation
medusajs endpoint implementation
- Host: GitHub
- URL: https://github.com/amdev9/medusa-store
- Owner: amdev9
- Created: 2025-11-21T11:48:12.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2025-11-21T12:52:27.000Z (7 months ago)
- Last Synced: 2025-11-21T14:29:54.521Z (7 months ago)
- Language: TypeScript
- Size: 1.56 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Medusajs project
Добавить API endpoint в MedusaJS v2 проект для конвертации валют с использованием внешнего API.
Инструкция по запуску
```
mv .env.template .env // for test purpose show some secrets (not the best practice)
npm i // install dependencies
npm run docker:up // run docker
docker compose logs -f // to see logs
npm run docker:down // stop docker
```
Use your {your_publishable_api_key} from admin panel instead
my example: pk_e5ac14e5fb0ee1b9f0af8d1cd2ffed632aece2243e5cb6c7d876d6860c7b097b
```
curl 'http://localhost:9000/store/currency/convert?amount=200&from=USD&to=EUR' \
-H 'x-publishable-api-key: pk_e5ac14e5fb0ee1b9f0af8d1cd2ffed632aece2243e5cb6c7d876d6860c7b097b'
{"message":"173.16"}
```
# Endpoint curl examples
```
curl 'http://localhost:9000/store/currency/convert?amount=200&from=USD&to=EUR' \
-H 'x-publishable-api-key: {your_publishable_api_key}'
{"message":"173.16"}
```
```
curl 'http://localhost:9000/store/currency/convert?amount=100&from=USD&to=EUR' \
-H 'x-publishable-api-key: {your_publishable_api_key}'
{"message":"86.58"}
```
```
curl 'http://localhost:9000/store/currency/convert?amount=100&to=EUR' \
-H 'x-publishable-api-key: {your_publishable_api_key}'
{"message":"Initial country code not found or have invalid format"}
```
```
curl 'http://localhost:9000/store/currency/convert?amount=100&from=USD&to=' \
-H 'x-publishable-api-key: {your_publishable_api_key}'
{"message":"Result country code not defined or have invalid format"}
```
```
curl 'http://localhost:9000/store/currency/convert?amount=10a&from=USD&to=EUR' \
-H 'x-publishable-api-key: {your_publishable_api_key}'
{"message":"Initial amount not defined or not valid"}
```
External api not accessible - for example no network
```
curl 'http://localhost:9000/store/currency/convert?amount=100&from=GBP&to=USD' \
-H 'x-publishable-api-key: {your_publishable_api_key}'
{"message":"Convert workflow errors: fetch failed"}
```