From 40ae2accbdf9a187319aa3a0c8124f0027b8f985 Mon Sep 17 00:00:00 2001 From: Jakub Czajkowski Date: Tue, 4 Mar 2025 20:15:52 +0100 Subject: [PATCH] docs: generate readme using GPT --- .env.example | 2 +- README.md | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 12ede91..dcf9ff8 100644 --- a/.env.example +++ b/.env.example @@ -9,4 +9,4 @@ DB_PORT=5432 DB_USER=root DB_PASSWORD=root DB_DATABASE=app -OPENAI_API_KEY= +OPENAI_API_KEY=elo_zelo diff --git a/README.md b/README.md index ddcc971..dc024bd 100644 --- a/README.md +++ b/README.md @@ -1 +1,193 @@ # backend-translator + +![Solvro banner](https://github.com/Solvro/backend-topwr-sks/blob/main/assets/solvro_dark.png#gh-dark-mode-only) +![Solvro banner](https://github.com/Solvro/backend-topwr-sks/blob/main/assets/solvro_dark.png#gh-light-mode-only) + +# Translation API Documentation + +## Base URL + +``` +/api/v1 +``` + +## Endpoints + +### Languages + +#### Get All Languages + +``` +GET /languages +``` + +**Response:** List of all available languages. + +#### Create a Language + +``` +POST /languages +``` + +**Body:** + +```json +{ + "isoCode": "en", + "name": "English" +} +``` + +**Response:** Created language object. + +#### Get Language by ISO Code + +``` +GET /languages/:isoCode +``` + +**Response:** Language object. + +#### Update Language + +``` +PUT /languages/:isoCode +``` + +**Body:** + +```json +{ + "name": "Updated Name" +} +``` + +**Response:** Updated language object. + +#### Delete Language + +``` +DELETE /languages/:isoCode +``` + +**Response:** No content. + +--- + +### Translations + +#### Get All Translations + +``` +GET /translations +``` + +**Response:** List of all translations. + +#### Create a Translation + +``` +POST /translations +``` + +**Body:** + +```json +{ + "originalText": "Hello", + "originalLanguageCode": "en", + "translatedLanguageCode": "fr", + "translatedText": "Bonjour" +} +``` + +**Response:** Created translation object. + +#### Get Translations for a Specific Text + +``` +GET /translations/:hash +``` + +**Response:** List of translations for the given text hash. + +#### Get Translations for a Specific Language + +``` +GET /translations/:isoCode +``` + +**Response:** List of translations in the given language. + +#### Get Specific Translation + +``` +GET /translations/:hash/:isoCode +``` + +**Response:** Translation object. + +#### Update Translation + +``` +PUT /translations/:hash/:isoCode +``` + +**Body:** + +```json +{ + "originalText": "Hello", + "translatedText": "Salut" +} +``` + +**Response:** Updated translation object. + +#### Delete Translation + +``` +DELETE /translations/:hash/:isoCode +``` + +**Response:** No content. + +#### Approve Translation + +``` +POST /translations/:hash/:isoCode/approve +``` + +**Response:** Approved translation object. + +#### Request Translation via OpenAI + +``` +POST /translations/openAI +``` + +**Body:** + +```json +{ + "originalText": "Hello", + "originalLanguageCode": "en", + "translatedLanguageCode": "es" +} +``` + +**Response:** Translation object created using OpenAI. + +--- + +## Notes + +- The `hash` parameter is generated using SHA-256 from `originalText`. +- The OpenAI translation request utilizes `gpt-4o-mini`. +- All responses follow JSON format. +- Errors return appropriate HTTP status codes with messages. +- **The API is generated by ChatGPT - watch out for inconsistencies** + +## Links + +[![docs.solvro.pl](https://i.imgur.com/fuV0gra.png)](https://docs.solvro.pl)