add API boilerplate + /accounts/{accountID} and /accounts/@me endpoints
This commit is contained in:
parent
0fa769a248
commit
dfc116d828
7 changed files with 335 additions and 0 deletions
36
web/api/blog.go
Normal file
36
web/api/blog.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"git.sleepycat.moe/sam/mercury/internal/database"
|
||||
"github.com/oklog/ulid/v2"
|
||||
)
|
||||
|
||||
// Blog is the basic blog returned by endpoints.
|
||||
type Blog struct {
|
||||
ID ulid.ULID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Domain *string `json:"domain"`
|
||||
Bio string `json:"bio"`
|
||||
|
||||
Account blogPartialAccount `json:"account"`
|
||||
}
|
||||
|
||||
type blogPartialAccount struct {
|
||||
ID ulid.ULID `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Domain *string `json:"domain"`
|
||||
}
|
||||
|
||||
func DBBlogToBlog(b database.Blog, a database.Account) Blog {
|
||||
return Blog{
|
||||
ID: b.ID,
|
||||
Name: b.Name,
|
||||
Domain: b.Domain,
|
||||
Bio: b.Bio,
|
||||
Account: blogPartialAccount{
|
||||
ID: a.ID,
|
||||
Username: a.Username,
|
||||
Domain: a.Domain,
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue