new API page in docs
This commit is contained in:
parent
2bcf1fc9a0
commit
a1073642b5
9 changed files with 185 additions and 10 deletions
57
docs/.api.md
Normal file
57
docs/.api.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
|
||||
## Add a new event
|
||||
|
||||
POST
|
||||
{: .label .label-orange}
|
||||
|
||||
**`/event`**
|
||||
|
||||
> info "info"
|
||||
> `Content-Type` has to be `multipart/form-data` 'cause support image upload
|
||||
|
||||
|
||||
**Params**
|
||||
|
||||
| title | `string` | event's title |
|
||||
| description | `string` | event's description (html accepted and sanitized) |
|
||||
| place_name | `string` | the name of the place |
|
||||
| place_address | `string` | the address of the place |
|
||||
| start_datetime | `integer` | start timestamp |
|
||||
| multidate | `integer` | is a multidate event? |
|
||||
| tags | `array` | List of tags |
|
||||
| recurrent | `object` | Recurrent event details |
|
||||
| recurrent.frequency | `string` | could be `1w` or `2w` |
|
||||
| recurrent.type | `string` | not used |
|
||||
| recurrent.days | `array` | array of days |
|
||||
| image | `image` | Image |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Get current authenticated user
|
||||
|
||||
GET
|
||||
{: .label .label-green}
|
||||
|
||||
**`/api/user`**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**Response**
|
||||
```json
|
||||
{
|
||||
"description" : null,
|
||||
"recover_code" : "",
|
||||
"id" : 1,
|
||||
"createdAt" : "2020-01-29T18:10:16.630Z",
|
||||
"updatedAt" : "2020-01-30T22:42:14.789Z",
|
||||
"is_active" : true,
|
||||
"settings" : "{}",
|
||||
"email" : "eventi@cisti.org",
|
||||
"is_admin" : true
|
||||
}
|
||||
```
|
||||
---
|
||||
|
|
@ -1,6 +1,14 @@
|
|||
---
|
||||
layout: default
|
||||
title: API
|
||||
permalink: /api
|
||||
permalink: /dev/api
|
||||
parent: Hacking
|
||||
nav_order: 8
|
||||
---
|
||||
|
||||
|
||||
1. TOC
|
||||
{:toc}
|
||||
|
||||
|
||||
|
||||
|
|
8
docs/.api_helpers.js
Normal file
8
docs/.api_helpers.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
exports.if_eq = function(a, b, opts) {
|
||||
if (a == b) {
|
||||
return opts.fn(this);
|
||||
} else {
|
||||
return opts.inverse(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,34 @@
|
|||
{{#orphans}}
|
||||
|
||||
### {{description}}
|
||||
## {{description}}
|
||||
|
||||
{{type.names}}
|
||||
{{#if_eq type.names 'POST'}}
|
||||
{: .label .label-orange}
|
||||
{{else}}
|
||||
{: .label .label-green}
|
||||
{{/if_eq}}
|
||||
|
||||
`{{name}}`
|
||||
|
||||
{{#each params}}
|
||||
| {{name}} | `{{type.names}}` | {{{description}}} |
|
||||
{{/each}}
|
||||
**`{{name}}`**
|
||||
|
||||
{{#each customTags}}
|
||||
> {{tag}} "{{tag}}"
|
||||
> {{{value}}}
|
||||
{{/each}}
|
||||
|
||||
|
||||
{{#if params}}
|
||||
**Params**
|
||||
|
||||
{{#each params}}
|
||||
| {{name}} | `{{type.names}}` | {{{description}}} |
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{#each examples}}
|
||||
{{{this}}}
|
||||
{{/each}}
|
||||
---
|
||||
{{/orphans}}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
}
|
||||
|
||||
.navigation-list-item a {
|
||||
color: blue;
|
||||
color: #7253ed;
|
||||
}
|
||||
|
||||
.navigation-list-item a:hover {
|
||||
|
|
71
docs/dev/api.md
Normal file
71
docs/dev/api.md
Normal file
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
layout: default
|
||||
title: API
|
||||
permalink: /dev/api
|
||||
parent: Hacking
|
||||
nav_order: 8
|
||||
---
|
||||
|
||||
|
||||
1. TOC
|
||||
{:toc}
|
||||
|
||||
|
||||
|
||||
|
||||
## Add a new event
|
||||
|
||||
POST
|
||||
{: .label .label-orange}
|
||||
|
||||
**`/event`**
|
||||
|
||||
> info "info"
|
||||
> `Content-Type` has to be `multipart/form-data` 'cause support image upload
|
||||
|
||||
|
||||
**Params**
|
||||
|
||||
| title | `string` | event's title |
|
||||
| description | `string` | event's description (html accepted and sanitized) |
|
||||
| place_name | `string` | the name of the place |
|
||||
| place_address | `string` | the address of the place |
|
||||
| start_datetime | `integer` | start timestamp |
|
||||
| multidate | `integer` | is a multidate event? |
|
||||
| tags | `array` | List of tags |
|
||||
| recurrent | `object` | Recurrent event details |
|
||||
| recurrent.frequency | `string` | could be `1w` or `2w` |
|
||||
| recurrent.type | `string` | not used |
|
||||
| recurrent.days | `array` | array of days |
|
||||
| image | `image` | Image |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Get current authenticated user
|
||||
|
||||
GET
|
||||
{: .label .label-green}
|
||||
|
||||
**`/api/user`**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**Response**
|
||||
```json
|
||||
{
|
||||
"description" : null,
|
||||
"recover_code" : "",
|
||||
"id" : 1,
|
||||
"createdAt" : "2020-01-29T18:10:16.630Z",
|
||||
"updatedAt" : "2020-01-30T22:42:14.789Z",
|
||||
"is_active" : true,
|
||||
"settings" : "{}",
|
||||
"email" : "eventi@cisti.org",
|
||||
"is_admin" : true
|
||||
}
|
||||
```
|
||||
---
|
||||
|
|
@ -326,6 +326,9 @@ export default {
|
|||
min-height: 300px;
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
.el-dialog__body {
|
||||
word-break: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,20 @@ api.use(express.json())
|
|||
* @category User
|
||||
* @name /api/user
|
||||
* @type GET
|
||||
* @example **Response**
|
||||
* ```json
|
||||
{
|
||||
"description" : null,
|
||||
"recover_code" : "",
|
||||
"id" : 1,
|
||||
"createdAt" : "2020-01-29T18:10:16.630Z",
|
||||
"updatedAt" : "2020-01-30T22:42:14.789Z",
|
||||
"is_active" : true,
|
||||
"settings" : "{}",
|
||||
"email" : "eventi@cisti.org",
|
||||
"is_admin" : true
|
||||
}
|
||||
```
|
||||
*/
|
||||
api.get('/user', isAuth, (req, res) => res.json(req.user))
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||
const User = sequelize.define('user', {
|
||||
settings: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: '{}'
|
||||
defaultValue: []
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
|
|
Loading…
Reference in a new issue