feat(create_note): setup note
This commit is contained in:
parent
66f03daf83
commit
843b840583
3 changed files with 38 additions and 3 deletions
26
core/handlers/create_note.go
Normal file
26
core/handlers/create_note.go
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/KristianJBorgwarth/dendrite.daemon/core/rpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type createNoteCommand struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
TemplatePath string `json:"templatePath"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
Vars map[string]string `json:"vars"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateNoteHandler struct{
|
||||||
|
repository NoteRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h CreateNoteHandler) Handle(params []byte) (any, *rpc.Error) {
|
||||||
|
var cmd createNoteCommand
|
||||||
|
if err := json.Unmarshal(params, &cmd); err != nil {
|
||||||
|
return nil, &rpc.Error{Code: -32602, Message: "invalid params"}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
// Package repositories provides an interface for accessing dendrite index and configuration
|
// Package repositories provides an interface for accessing dendrite index and configuration
|
||||||
package repositories
|
package repositories
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
12
persistence/repositories/note_repository.go
Normal file
12
persistence/repositories/note_repository.go
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
package repositories
|
||||||
|
|
||||||
|
import "database/sql"
|
||||||
|
|
||||||
|
type NoteRepository interface {
|
||||||
|
CreateNote(title string, path string, slug string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type noteRepository struct {
|
||||||
|
db *sql.DB
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue