kaonashi

package module
v0.0.0-...-973ca52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2016 License: MIT Imports: 14 Imported by: 0

README

kaonashi

Build Status MIT License

Headless local note app with just-enough set of RESTful APIs

Why created

There are wide range of note apps out there, but the fundamental functionality is not so different among them. Programmers and desingers are kind of people who are good at creating whatever tools/UIs suitable for their own use case, and it has became substantially easier to create UI for multiple devices as variety of tools evolved in the past few years. This go gettable binary, called kaonashi, will get your back. You can create and keep polishing valuable note UIs for your own use case on top of RESTful APIs that should be just-enough for simple note app.

Example UIs

Instalation

go get -u github.com/achiku/kaonashi/cmd/kaonashi

Create database

$ kaonashi -init

Start service

$ kaonashi -d &

What it can do

Interacting with kaonashi using curl.

POST a note
curl -v -H "Accept: application/json" \
    -H "Content-type: application/json" \
    -X POST \
    -d '{"data":{"title":"my first note","body":"note body"}}' \
    http://localhost:8080/note
{
    "data": {
        "message": "created"
    }
}
PUT a note
curl -v -H "Accept: application/json" \
    -H "Content-type: application/json" \
    -X PUT \
    -d '{"data":{"title":"my first note","body":"note body updated"}}' \
    http://localhost:8080/note/1
{
    "data": {
        "message": "updated"
    }
}
DELETE a note
curl -v -H "Accept: application/json" \
    -H "Content-type: application/json" \
    -X DELETE \
    http://localhost:8080/note/1
{
    "data": {
        "message": "deleted"
    }
}
GET note titles
curl -v -H "Accept: application/json" \
    -H "Content-type: application/json" \
    -X GET \
    http://localhost:8080/note
{
    "data": [
        {
            "created": "2016-01-09 22:51:10.860726046 +0900 JST",
            "id": 2,
            "title": "title 02",
            "updated": "2016-01-09 22:51:10.861432579 +0900 JST"
        },
        {
            "created": "2016-01-09 22:20:45.814969118 +0900 JST",
            "id": 1,
            "title": "title 01",
            "updated": "2016-01-09 22:20:45.816734399 +0900 JST"
        }
    ]
}
GET a note
curl -v -H "Accept: application/json" \
    -H "Content-type: application/json" \
    -X GET \
    http://localhost:8080/note/2
{
    "data": {
        "body": "hello, kaonashi!",
        "created": "2016-01-09 22:51:10.860726046 +0900 JST",
        "id": 2,
        "title": "title01",
        "updated": "2016-01-09 22:51:10.861432579 +0900 JST"
    }
}

Contribute

Pull requests for new features, bug fixes, and suggestions are welcome!

Install gom

This project is using gom for dependency management.

$ go get -u github.com/mattn/gom
$ gom install
Test
$ go test -v
Write code and auto-reload

Using wbs, it will be really easy to code and reload.

$ cd cmd/kaonashi
$ gom exec wbs -c wbs.toml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Debug        bool   `toml:"debug"`
	Testing      bool   `toml:"testing"`
	DatabasePath string `toml:"database_path"`
	ServerPort   string `toml:"server_port"`
}

AppConfig struct

func NewAppConfig

func NewAppConfig(configFilePath string) (*AppConfig, error)

NewAppConfig creates new config

func NewAppDefaultConfig

func NewAppDefaultConfig() *AppConfig

NewAppDefaultConfig create new default config

type DB

type DB struct {
	*sqlx.DB
}

DB struct

func NewDB

func NewDB(config *AppConfig) (*DB, error)

NewDB Create new DB

type Kaonashi

type Kaonashi struct {
	// contains filtered or unexported fields
}

Kaonashi struct

func NewKaonashi

func NewKaonashi(confPath string) (*Kaonashi, error)

NewKaonashi create tables

func (*Kaonashi) InitDB

func (k *Kaonashi) InitDB()

InitDB create tables

func (*Kaonashi) Run

func (k *Kaonashi) Run()

Run kaonashi

type MessageResponse

type MessageResponse struct {
	Data StatusMessage `json:"data"`
}

MessageResponse struct

type Note

type Note struct {
	ID      int         `json:"id"`
	Title   string      `json:"title"`
	Body    null.String `json:"body"`
	Created string      `json:"created"`
	Updated string      `json:"updated"`
}

Note struct

type NoteRequest

type NoteRequest struct {
	Data Note `json:"data"`
}

NoteRequest struct

type NoteResponse

type NoteResponse struct {
	Data Note `json:"data"`
}

NoteResponse struct

type NoteTitle

type NoteTitle struct {
	ID      int    `json:"id"`
	Title   string `json:"title"`
	Created string `json:"created"`
	Updated string `json:"updated"`
}

NoteTitle struct

type NoteTitlesResponse

type NoteTitlesResponse struct {
	Data []NoteTitle `json:"data"`
}

NoteTitlesResponse struct

type NotesResponse

type NotesResponse struct {
	Data []Note `json:"data"`
}

NotesResponse struct

type StatusMessage

type StatusMessage struct {
	Message string `json:"message"`
}

StatusMessage struct

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL