found-pleiade / dionysos-server Goto Github PK
View Code? Open in Web Editor NEWAPI instance for dionysos client application
License: GNU General Public License v3.0
API instance for dionysos client application
License: GNU General Public License v3.0
Many false positives in the linter job due to typecheck rule
When patching a model, any field without omitempty
will be erased if not specified in the database during an UpdateDocument.
But during creation you need to have fields with binding:required
.
Right now, in each route, we call c.JSON and log.Printf.
It might be better to have a set of constant return codes that routes will return/set in context ; and to grab them to call set response and logger.
That way we will centralize responses formatting (like "Room not found")
exceptedID instead of expectedID in utils/routes/responses.go
https://stackoverflow.blog/2021/10/06/best-practices-for-authentication-and-authorization-for-rest-apis/
https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Authorization
We will be using header Authorization Basic id:password
where id:password
is in base64. In addition, we will use a middleware in gin to verify credentials. Continue to the route if it is okay and send 401 if not.
Need to implement WWW-Authenticate as well https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/WWW-Authenticate
We need to complexify room ID so it cannot be guessed by a random user
On commit :
On PR on main :
With tests on changing a user's name, the following GET still returns the old name and we have a stack trace in the code
api | 2022/08/11 13:22:18 [Recovery] 2022/08/11 - 13:22:18 panic recovered:
api | PATCH /users/3 HTTP/1.1
api | Host: localhost:8080
api | Accept: */*
api | Accept-Encoding: gzip, deflate, br
api | Authorization: *
api | Cache-Control: no-cache
api | Connection: keep-alive
api | Content-Length: 31
api | Content-Type: application/json
api | Postman-Token: 27c919f7-b5c7-4516-a896-3d061442e07c
api | User-Agent: PostmanRuntime/7.29.2
api | X-Requested-With: XMLHttpRequest
api |
api |
api | runtime error: invalid memory address or nil pointer dereference
api | /usr/local/go/src/runtime/panic.go:220 (0x44b7d5)
api | panicmem: panic(memoryError)
api | /usr/local/go/src/runtime/signal_unix.go:818 (0x44b7a5)
api | sigpanic: panicmem()
api | /app/routes/router.go:141 (0xb853ca)
api | invalidateCacheURI: code := c.Request.Response.StatusCode
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:173 (0xb85155)
api | (*Context).Next: c.handlers[c.index](c)
api | /app/routes/router.go:113 (0xb8502f)
api | authentication: c.Next()
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:173 (0x8e91e1)
api | (*Context).Next: c.handlers[c.index](c)
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:101 (0x8e91cc)
api | CustomRecoveryWithWriter.func1: c.Next()
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:173 (0xb852fb)
api | (*Context).Next: c.handlers[c.index](c)
api | /app/routes/router.go:133 (0xb852d3)
api | options: c.Next()
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:173 (0x8e91e1)
api | (*Context).Next: c.handlers[c.index](c)
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:101 (0x8e91cc)
api | CustomRecoveryWithWriter.func1: c.Next()
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:173 (0x8e82c6)
api | (*Context).Next: c.handlers[c.index](c)
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:240 (0x8e82a9)
api | LoggerWithConfig.func1: c.Next()
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:173 (0x8e7390)
api | (*Context).Next: c.handlers[c.index](c)
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:616 (0x8e6ff8)
api | (*Engine).handleHTTPRequest: c.Next()
api | /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:572 (0x8e6b3c)
api | (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
api | /usr/local/go/src/net/http/server.go:2916 (0x6a1fba)
api | serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
api | /usr/local/go/src/net/http/server.go:1966 (0x69cfb6)
api | (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
api | /usr/local/go/src/runtime/asm_amd64.s:1571 (0x465ac0)
api | goexit: BYTE $0x90 // NOP
api |
api | [GIN-debug] [WARNING] Headers were already written. Wanted to override status code 204 with 500
api | [GIN] 2022/08/11 - 13:22:18 | 500 | 5.1419ms | 172.18.0.1 | PATCH "/users/3"
The client has added the base path to its default url, so we should not return this on POST
Useful to setup different log granularity for each environment for example
The PATCH request seems to request first OPTIONS.
This is used to request which methods is allowed by the API (https://developer.mozilla.org/fr/docs/Web/HTTP/Methods/OPTIONS)
We need to configure CORS to send this info or to use a custom route to respond to this request OPTIONS
Add continous deployment for dionysos-test server
It is redondant. Better to rename it "name".
Switch to the old good postgres SQL with GORM
Remove golanci-lint from super linter cause it is super heavy, replace it by https://golangci-lint.run/usage/install/#ci-installation
EDIT: Probably still a good idea to replace it so it can suggest code changements directly in PR
Consider testing out the following:
c.Status(http.StatusNotFound)
c.Error("error": "User not found")
Instead of
c.JSON(http.StatusNotFound, gin.H{"error": "User not found"})
Remove password request when in DEV mode because it is annoying for manual tests.
It looks like some small errors have been missed in the tests
Just need to delete the operation named Deploy in the docker push github action.
Because we have migrating to render.com
One can create a Room with whatever OwnerID/User list he wants.
Have
runtime error: invalid memory address or nil pointer dereference
Happens on line 132 of the router.go
file, c.Next()
call, which seems weird.
if c.Request.Method != "OPTIONS" {
c.Next()
} else {
c.AbortWithStatus(http.StatusOK)
}
After a bit of research:
https://github.com/cosmtrek/air
NB: I already tried this solution in the early steps of the projects but it wasn’t working for the reason due to go environment variables.
https://github.com/codegangsta/gin
Seems unmaintained but could work.
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.