design and implement scribe server v1 API#29
Conversation
- Add versioned API endpoints for language data retrieval - Implement GET /v1/data/:lang for full language datasets - Implement GET /v1/data-version/:lang for version metadata - Add CORS middleware optimized for GET-only requests - Include proper error handling with structured responses - Add mock data support for English (en) language
Thank you for the pull request! ❤️The Scribe-Server team will do our best to address your contribution as soon as we can. If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the |
Maintainer ChecklistThe following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)
|
There was a problem hiding this comment.
First PR Commit Check
- The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution
- The contributor's name and icon in remote commits should be the same as what appears in the PR
- If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for
git config user.emailin their local Scribe-Server repo (can be set withgit config --global user.email "GITHUB_EMAIL")
|
Hi @andrewtavis and @axif0 I have migrated the project I have set up the routes we will need:
I have added basic test cases to the project and the test code coverage is next steps now is to use connect the handlers to read the mariadb content for real data. What do you two think? |
|
Thanks so much for the PR, @DeleMike! 🎉 So amazing that the API is starting to take shape 😊 I'm realizing that we need to update the maintainer checklist here with a checkbox for making sure the CI passes. @DeleMike, could we also add the coverage report to the pr_ci workflow? |
|
That way we can easily track the progress of testing in PRs as we do in other projects :) |
|
Thanks for the review @andrewtavis Will that be a separate PR? Or I add it to this? |
|
I think we can just add it here, @DeleMike, but if you'd like to make an issue for it as well and link that one to here that would be totally fine! 😊 |
|
Okay, that's fine. I will decide which one is better asap! |
|
One think I like to mention that, We need to sanitize isos and data types
|
Yeah, great point! And thanks! Could you point me to an example? I don't fully understand. |
We should need a checker function like |
Oh! Of course, I will add these! Thanks!! |
|
Hi @axif0 , func isValidLanguageCode(lang string) bool {
allowedLanguages := []string{"en", "es", "fr", etc....}
if len(lang) != 2 {
return false
}
for _, allowed := range allowedLanguages {
if lang == allowed {
return true
}
}
return false
}
is this a better approach?
The drawback of this is that we will hit the DB and then have no data. Seems like a waste of time. But if we define a list or some other advanced data structure like a map(this is faster), then we can do something like this: var iso639_1Codes = map[string]bool{"en": true, "fr": true, "de": true}Then quickly check if the key exists or not. but here we still have to define or append to the list later what language types is supported. I'm trying to remove the process of writing allowed languages. or is inevitable? At the end of the day, we will still check if that table still exists or not, because we can still define it there in the map but the table does not actually exist in the DB. what do you think? I hope this makes sense 🥲 cc: @andrewtavis |
I think for now we can hard-code the list of available languages. But later release, we'll need to dynamically fetch the available languages , ideally filtering out the ones that have no data. And needs SQL injection checker function. |
|
Alright. thanks, @axif0! I will improve my work and then try to see if I can lay up the ground work for the SQL checker. You should expect a PR update sometime from Monday! 👌🏾 |
- Added `/api/v1/data/:lang` to serve language-specific structured data - Added `/api/v1/data-version/:lang` for last modified tracking of data types - Added `/api/v1/languages` to list supported languages and their data types - Refactored error messages into constants for reuse and clarity - Defined contract version and date formatting in internal/constants These endpoints form the foundation of the Scribe API contract and support client-side syncing, schema introspection, and multi-language support.
…int tests Temporarily removed detailed tests for `/data/:lang` and `/data-version/:lang` to unblock CI and stabilize test coverage. Added minimal tests for root hello endpoint and CORS header presence. Full endpoint tests will be restructured and reintroduced later.
|
Hi @axif0 and @andrewtavis , I have made an update for our API. You can access the draft plan here.. It's more like a guide for this PR and also your previous comments. Now, I have implemented
See example response after I dragged and dropped Endpoint:
|
|
Few suggestions that comes in my mind that,
Routes work good in my machine. Nice work @DeleMike 🚀 🔥 |
|
Thanks @axif0! What next steps do we take? I have already pointed it out in my previous comments. Do we do 1, 2 or 3? Thanks!
|
|
Works good in my machine. Is it possible to have some review for this PR? @henrikth93 ? 👀 |
I can check! |
andrewtavis
left a comment
There was a problem hiding this comment.
Approving given the call that we're doing right now with @DeleMike, @axif0 and @henrikth93 🎉 Thanks all so much for the amazing work here! 😊

Contributor checklist
Description
This PR refactors the HTTP server from
net/httpto the Gin web framework, improving routing, middleware support, and extensibility. It also introduces a RESTful API design for handling language data.Changes
net/httpwith Gin throughout the appapi/handler.gotoapi/handlers.gofor consistencyMotivation
Gin provides a cleaner syntax for routing and middleware, along with better performance. This migration improves the codebase structure and sets a strong foundation for future API development.
Related issue