Skip to content

Commit f578a44

Browse files
author
Dagger
committed
add_farewell_endpoints_with_multi-language_goodbye_support_1752552899
1 parent 64988f5 commit f578a44

File tree

4 files changed

+89
-34
lines changed

4 files changed

+89
-34
lines changed

.dagger/prompts/assignment.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ You are a programmer working on the Greetings API project
66
2. Evaluate the architecture of the project at `## Project Architecture` in CONTRIBUTING.md to think about what files may be relevant to the solution
77
3. Understand how the assignment should be implemented in the codebase
88
4. Implement the assignment in the workspace provided
9-
5. Run the checks to make sure the changes are valid and incorporate any changes needed to pass checks
9+
5. **CRITICAL**: Update documentation in `docs/index.mdx` to reflect any new functionality, endpoints, or changes
10+
6. Run the checks to make sure the changes are valid and incorporate any changes needed to pass checks
1011

1112
## Assignment
1213

@@ -17,4 +18,5 @@ Here is your assignment: $assignment
1718
- The workspace has tools to let you read and write the code as well as run the tests
1819
- Be sure to always write your changes to the workspace
1920
- Always run check after writing changes to the workspace
21+
- **IMPORTANT**: Changes to project functionality MUST be reflected in changes to the documentation (`docs/index.mdx`)
2022
- You are not done until the check tool is successful and the assignment is complete

CONTRIBUTING.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ greetings-api/
6464

6565
- **Language**: Go
6666
- **Framework**: Gorilla Mux for routing, CORS middleware
67-
- **Structure**: Simple REST API with two endpoints:
67+
- **Structure**: Simple REST API with endpoints for greetings and farewells:
6868
- `GET /` - Returns a random greeting
6969
- `GET /{language}` - Returns a greeting in the specified language
70-
- **Data**: Greetings are stored in `greetings.json` and embedded in the binary
70+
- `GET /farewell` - Returns a random farewell
71+
- `GET /farewell/{language}` - Returns a farewell in the specified language
72+
- **Data**: Greetings are stored in `greetings.json` and farewells in `farewells.json`, both embedded in the binary
7173
- **Testing**: Uses `gotest.tools` for unit tests
7274

7375
### Frontend Architecture
@@ -154,10 +156,17 @@ npm run lint
154156
- **TypeScript**: Follow the ESLint configuration in the project
155157
- **Commits**: Use clear, descriptive commit messages
156158

157-
### Documentation
159+
### Documentation Requirements
160+
161+
**⚠️ CRITICAL**: Changes to project functionality MUST be reflected in documentation updates.
158162

159163
- **Developer Docs**: Update CONTRIBUTING.md with any architectural changes
160-
- **Product Docs**: Update docs/ with relevant product changes
164+
- **Product Docs**: Update `docs/index.mdx` with any new endpoints, functionality, or changes that affect users
165+
- **API Documentation**: When adding new endpoints, ensure they are properly documented with:
166+
- Endpoint paths and HTTP methods
167+
- Example requests and responses
168+
- Updated supported languages table if applicable
169+
- Error handling examples
161170

162171
### Testing Requirements
163172

@@ -174,22 +183,25 @@ npm run lint
174183

175184
2. **Make your changes** following the code style guidelines
176185

177-
3. **Test your changes** thoroughly:
186+
3. **Update documentation** as required (see Documentation Requirements above)
187+
188+
4. **Test your changes** thoroughly:
178189
```bash
179190
dagger call check
180191
```
181192

182-
4. **Commit your changes** with clear commit messages
193+
5. **Commit your changes** with clear commit messages
183194

184-
5. **Push to your fork**:
195+
6. **Push to your fork**:
185196
```bash
186197
git push origin feature/your-feature-name
187198
```
188199

189-
6. **Create a Pull Request** on GitHub with:
200+
7. **Create a Pull Request** on GitHub with:
190201
- Clear description of changes
191202
- Reference to any related issues
192203
- Screenshots if UI changes are involved
204+
- Confirmation that documentation has been updated if functionality changed
193205

194206
## Getting Help
195207

docs/index.mdx

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Greetings API Documentation
22

3-
Welcome to the Greetings API! This simple service allows you to retrieve greetings in various languages.
3+
Welcome to the Greetings API! This simple service allows you to retrieve greetings and farewells in various languages.
44

55
## Using the REST API
66

7-
The Greetings API provides two main endpoints for retrieving greetings:
7+
The Greetings API provides endpoints for retrieving both greetings and farewells:
88

99
### Get a Random Greeting
1010

@@ -39,38 +39,72 @@ GET http://locahost:8080/french
3939
}
4040
```
4141

42+
### Get a Random Farewell
43+
44+
```
45+
GET http://locahost:8080/farewell
46+
```
47+
48+
**Example Response:**
49+
```json
50+
{
51+
"farewell": "Goodbye, World!"
52+
}
53+
```
54+
55+
### Get a Farewell in a Specific Language
56+
57+
```
58+
GET http://locahost:8080/farewell/{language}
59+
```
60+
61+
Replace `{language}` with one of the supported language codes.
62+
63+
**Example Request:**
64+
```
65+
GET http://locahost:8080/farewell/french
66+
```
67+
68+
**Example Response:**
69+
```json
70+
{
71+
"farewell": "Au revoir, Monde !"
72+
}
73+
```
74+
4275
## Supported Languages
4376

4477
The API currently supports the following languages:
4578

46-
| Language Code | Greeting |
47-
|---------------|----------|
48-
| english | Hello, World! |
49-
| british | Hello, World! Cheers! |
50-
| french | Bonjour, Monde ! |
51-
| italian | Ciao, Mondo! |
52-
| spanish | ¡Hola, Mundo! |
53-
| german | Hallo, Welt! |
54-
| mandarin | 你好,世界! |
55-
| hindi | नमस्ते दुनिया! |
56-
| arabic | مرحبا بالعالم! |
57-
| bengali | ওহে বিশ্ব! |
58-
| russian | Привет, мир! |
59-
| portuguese | Olá, Mundo! |
60-
| urdu | ہیلو، دنیا! |
61-
| indonesian | Halo Dunia! |
62-
| japanese | こんにちは世界! |
63-
| marathi | नमस्कार जग! |
64-
| telugu | హలో ప్రపంచం! |
79+
| Language Code | Greeting | Farewell |
80+
|---------------|----------|----------|
81+
| english | Hello, World! | Goodbye, World! |
82+
| british | Hello, World! Cheers! | Goodbye, World! Cheerio! |
83+
| french | Bonjour, Monde ! | Au revoir, Monde ! |
84+
| italian | Ciao, Mondo! | Arrivederci, Mondo! |
85+
| spanish | ¡Hola, Mundo! | ¡Adiós, Mundo! |
86+
| german | Hallo, Welt! | Auf Wiedersehen, Welt! |
87+
| mandarin | 你好,世界! | 再见,世界! |
88+
| hindi | नमस्ते दुनिया! | अलविदा दुनिया! |
89+
| arabic | مرحبا بالعالم! | وداعا يا عالم! |
90+
| bengali | ওহে বিশ্ব! | বিদায় পৃথিবী! |
91+
| russian | Привет, мир! | До свидания, мир! |
92+
| portuguese | Olá, Mundo! | Adeus, Mundo! |
93+
| urdu | ہیلو، دنیا! | الوداع، دنیا! |
94+
| indonesian | Halo Dunia! | Selamat tinggal Dunia! |
95+
| japanese | こんにちは世界! | さようなら世界! |
96+
| marathi | नमस्कार जग! | निरोप जग! |
97+
| telugu | హలో ప్రపంచం! | వీడ్కోలు ప్రపంచం! |
6598

6699
## Using the Greetings Website
67100

68101
If you prefer a web interface, you can visit the website at http://locahost:8081/ where you can:
69102

70103
1. View random greetings with a simple click
71-
2. Experience our user-friendly interface
104+
2. View random farewells with a simple click
105+
3. Experience our user-friendly interface
72106

73-
Simply click the greeting button (👋) to get a new random greeting displayed on the screen.
107+
Simply click the greeting button (👋) to get a new random greeting or the farewell button (👋😢) to get a new random farewell displayed on the screen.
74108

75109
## API Limits
76110

@@ -80,13 +114,20 @@ Currently, there are no rate limits on the API usage, but please be respectful o
80114

81115
If you request a language that doesn't exist, the API will return an appropriate error message with a 400 status code.
82116

83-
Example error response:
117+
Example error response for greeting:
84118
```json
85119
{
86120
"error": "no greeting found for language 'klingon'"
87121
}
88122
```
89123

124+
Example error response for farewell:
125+
```json
126+
{
127+
"error": "no farewell found for language 'klingon'"
128+
}
129+
```
130+
90131
## Need Help?
91132

92133
If you have any questions or need assistance with the Greetings API, please open an issue on our GitHub repository.

website/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1 class="text-3xl font-bold mb-4">Greetings Daggernauts</h1>
2121
<script>
2222
async function getRandomGreeting() {
2323
try {
24-
const response = await fetch('http://localhost:8080/random');
24+
const response = await fetch('http://localhost:8080/');
2525
const data = await response.json();
2626
document.getElementById('greetingDisplay').textContent = data.greeting;
2727
} catch (error) {

0 commit comments

Comments
 (0)