jonasknobloch / nhie Goto Github PK
View Code? Open in Web Editor NEWNo-bullshit "Never Have I Ever" implementation for the web.
Home Page: https://boozee.app
License: MIT License
No-bullshit "Never Have I Ever" implementation for the web.
Home Page: https://boozee.app
License: MIT License
if r := strings.Split(ctx.Request.URL.String(), "/random"); len(r) == 2 { // && r[1] == ""
s, err = getRandomStatement(g)
} else {
s, err = getStatementByID(g)
}
statement.go
Just use g.C.Params.ByName("id") == "random"
instead.
Before
{
"ID": "223005ec-1251-4dab-bc82-4f4ff759b525",
"statement": "Never have I ever been to a drive-in movie.",
"category": "offensive",
"translations": {
"de": "Ich war noch nie in einem Autokino.",
"es": "Nunca he estado en un autocine.",
}
}
After
{
"ID": "223005ec-1251-4dab-bc82-4f4ff759b525",
"statement": "Ich war noch nie in einem Autokino.",
"category": "delicate"
}
No reason for multiple translation -> keep it simple. Keeping the FetchTranslations
method for now.
Hallo, ich hoffe, es ist okay, dass ich eure/deine API in einem Software Development Projekt zur Entwicklung einer pwa nutze.
Ich habe die api auch schon eingebunden, allerdings ist die Website seit heute nicht mehr erreichbar. Ist es geplant die api wieder online zu stellen oder ist diese dauerhaft nicht mehr verfügbar?
mfG
Christopher
(Package documentations in the respective packages?)
A game guarantees unique statements. Finished games get cleaned up.
Endpoints
POST /games
starts a new game and returns game_id
GET /games/:game_id/statements/random
new random statementGET /games/:game_id/statements
game history (no duplicates)GET /games/:game_id/statements/:statement_id
redirects to /statements/:statement_id
func getStatementByID(g app.Gin) (*statement.Statement, error) {
// g.C.Params.ByName("id") returns an empty string if no matching key is found
id, err := uuid.Parse(g.C.Params.ByName("id"))
if err != nil {
g.ErrorResponse(problem.Default(http.StatusBadRequest))
return nil, nil
}
return statement.GetByID(id)
}
Problem
Returning nil, nil
to indicate that an error is handled (e.g. response is set) is probably a bad idea.
Possible Solution(s)
Custom error to indicated the response is set / the error is handled?
Just return error and set response in endpoint handler?
SA4010: this result of append is never used, except maybe in other appends
Nice project
wondering if you are planning to model parameters so that a string with parameters can be translated.
Deepl seems to support it
(Providing a public endpoint for available languages might prove useful)
TODO:
https://gorm.io/docs/v2_release_note.html
query := `SELECT * FROM "statements" WHERE "statements"."category" = $1 AND "statements"."deleted_at" IS NULL LIMIT 1`
The current query works because the test database contains only one row and GORM omits OFFSET 0
. Not testing the behaviour with more than one row seems like a bad idea.
Introduced it to store the whole translatepb.TranslateTextResponse
. This is overkill since we can simply extract the translated string and cache it directly.
The Postgres GORM driver switched from https://github.com/lib/pq to https://github.com/jackc/pgx so we have to update the affected error type assertion accordingly.
Promethues
Grafana visualisation
Using the existing basic auth might not suffice.
The request https://api.nhie.io/v1/statements/random?language=en
currently will return
{
"type": "about:blank",
"title": "Bad Request",
"status": 400,
"detail": "English is currently not supported."
}
this is fucking stupid
PLs FiX :/
KnObO wHatcH BeHaiN
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.