0.1.1 • Published 5 years ago
@tsei/note v0.1.1
Install via npm
npm i -S @tsei/note
Get Started
git clone https://github.com/tseijp/notecd note,npm iandnpm start- open browser and visit http://localhost:3000
- Now you can go to our demo, and try its usage.
Recipes
Note
manage note data and apiconst [note, set] = useNote(url, fetcher, config)
<Note url="..."
fetcher={...}
{...config}>
{(note, set) =>
<>{/*_*/}</>
}
</Note>- @url: string
- @fetcher: function
- @config: object
- @note: Note
- @set: function
User
manage user info and APIconst [user, set] = useUser(url, fetcher, config)
<User url="..."
fetcher={...}
{...config}>
{(user, set) =>
<>{/*_*/}</>
}
</User>- @url: string
- @fetcher: function
- @config : object
@user:
User- @username : user name from fetched API e.g. tseijp
- @authtoken: user token from cookie
- @input : for input Components
- @status : the acton at fetch e.g. IN, UP, OUT or ""
- @userlang : user language from window.navigator.language e.g. ja, en
@set:
<details> - `setUser()` : Toggle fetching - ~`setUser(null)` : switch status IN->UP or UP->IN~ - ~`setUser(boolean)`: switch status '' or IN|UP|OUT~ </details>
Available API
| URL | Description |
|---|---|
| /auth/ | Distribute Auth Token |
| /api/ | Restful Api Router |
| /api/note/ | Note Api |
key of /api/note | Description |
|---|---|
| next | next pagination url |
| previous | previous pagination url |
| results | seriaized data as array |
| results0.id | primary key |
| results0.note_id | primary key of parent |
| results0.ja_text | text data |
| results0.en_text | text data |
| results0.is_author | whether request user is author |
| results0.posted_time | time when it was posted |
| results0.author_name | username of posted user |