feat: adding song write endpoints (#25)

This commit is contained in:
paranarimasu
2022-06-03 23:22:36 -05:00
committed by GitHub
parent 21922aeb61
commit d568e0d692
7 changed files with 258 additions and 16 deletions
+18 -2
View File
@@ -263,12 +263,28 @@ module.exports = {
to: '/song',
children: [
{
title: 'Show',
to: '/song/show/',
title: 'Destroy',
to: '/song/destroy/'
},
{
title: 'Force Delete',
to: '/song/forceDelete/'
},
{
title: 'Index',
to: '/song/index/'
},
{
title: 'Show',
to: '/song/show/',
},
{
title: 'Store',
to: '/song/store/',
},
{
title: 'Update',
to: '/song/update/',
}
]
},
+18 -2
View File
@@ -29,10 +29,26 @@ For example, Staple Stable is the song for the Bakemonogatari OP1 AnimeTheme.
### Endpoints
**[Song Destroy](/song/destroy/)**
The song destroy endpoint soft deletes a song and returns the deleted song resource.
**[Song Force Delete](/song/forceDelete/)**
The song force delete endpoint hard deletes a song and returns a confirmation message.
**[Song Index](/song/index/)**
The song index endpoint displays a listing of song resources.
**[Song Show](/song/show/)**
The song show endpoint returns a song resource.
**[Song Index](/song/index/)**
**[Song Store](/song/store/)**
The song index endpoint displays a listing of song resources.
The song store endpoint creates a new song and returns the new song resource.
**[Song Update](/song/update/)**
The song update endpoint updates a song and returns the updated song resource.
+53
View File
@@ -0,0 +1,53 @@
---
title: Song Destroy
---
<Block>
# Song Destroy Endpoint
The song destroy endpoint soft deletes a song and returns the deleted song resource.
For example, the `/api/song/3373` endpoint will soft delete the "staple stable" song and return the deleted "staple stable" resource.
## URL
```sh
DELETE /api/song/{id}
```
## Authentication
**Required Permission**: delete song
**Roles with Permission**: Wiki Editor, Admin
## Parameters
None
## Response
```json
{
song: {
id: id,
title: "title",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/song/3373
```
</CURL>
</Example>
</Block>
+47
View File
@@ -0,0 +1,47 @@
---
title: Song Force Delete
---
<Block>
# Song Force Delete Endpoint
The song force delete endpoint hard deletes a song and returns a confirmation message.
For example, the `/api/forceDelete/song/3373` endpoint will hard delete the "staple stable" song and return a confirmation message.
## URL
```sh
DELETE /api/forceDelete/song/{id}
```
## Authentication
**Required Permission**: force delete song
**Roles with Permission**: Admin
## Parameters
None
## Response
```json
{
message: "The Song 'staple stable' was deleted.",
}
```
<Example>
<CURL>
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/forceDelete/song/3373
```
</CURL>
</Example>
</Block>
+55
View File
@@ -0,0 +1,55 @@
---
title: Song Store
---
<Block>
# Song Store Endpoint
The song store endpoint creates a new song and returns the new song resource.
For example, the `/api/song?title=staple+stable` endpoint will create a new "staple stable" song and return the new "staple stable" resource.
## URL
```sh
POST /api/song
```
## Authentication
**Required Permission**: create song
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :------: | :------: | :---------------------------------- |
| title | No | string, max:192 |
## Response
```json
{
song: {
id: id,
title: "title",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/song/
```
</CURL>
</Example>
</Block>
+55
View File
@@ -0,0 +1,55 @@
---
title: Song Update
---
<Block>
# Song Update Endpoint
The song update endpoint updates a song and returns the updated song resource.
For example, the `/api/song/song?title=staple+stable` endpoint will update the "staple stable" song title attribute and return the updated "staple stable" resource.
## URL
```sh
PUT|PATCH /api/song/{id}
```
## Authentication
**Required Permission**: update song
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :------: | :------: | :---------------------------------- |
| title | No | string, max:192 |
## Response
```json
{
song: {
id: id,
title: "title",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl -X PATCH -H "Authorization: Bearer {token}" https://api.animethemes.moe/song/3373
```
</CURL>
</Example>
</Block>
+12 -12
View File
@@ -1881,9 +1881,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "17.0.38",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz",
"integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==",
"version": "17.0.39",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.39.tgz",
"integrity": "sha512-JDU3YLlnPK3WDao6/DlXLOgSNpG13ct+CwIO17V8q0/9fWJyeMJJ/VyZ1lv8kDprihvZMydzVwf0tQOqGiY2Nw==",
"dev": true
},
"node_modules/@types/q": {
@@ -5703,9 +5703,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.4.144",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.144.tgz",
"integrity": "sha512-R3RV3rU1xWwFJlSClVWDvARaOk6VUO/FubHLodIASDB3Mc2dzuWvNdfOgH9bwHUTqT79u92qw60NWfwUdzAqdg==",
"version": "1.4.145",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.145.tgz",
"integrity": "sha512-g4VQCi61gA0t5fJHsalxAc8NpvxC/CEwLAGLfJ+DmkRXTEyntJA7H01771uVD6X6nnViv3GToPgb0QOVA8ivOQ==",
"dev": true
},
"node_modules/elliptic": {
@@ -16303,9 +16303,9 @@
"dev": true
},
"@types/node": {
"version": "17.0.38",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz",
"integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==",
"version": "17.0.39",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.39.tgz",
"integrity": "sha512-JDU3YLlnPK3WDao6/DlXLOgSNpG13ct+CwIO17V8q0/9fWJyeMJJ/VyZ1lv8kDprihvZMydzVwf0tQOqGiY2Nw==",
"dev": true
},
"@types/q": {
@@ -19496,9 +19496,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.4.144",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.144.tgz",
"integrity": "sha512-R3RV3rU1xWwFJlSClVWDvARaOk6VUO/FubHLodIASDB3Mc2dzuWvNdfOgH9bwHUTqT79u92qw60NWfwUdzAqdg==",
"version": "1.4.145",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.145.tgz",
"integrity": "sha512-g4VQCi61gA0t5fJHsalxAc8NpvxC/CEwLAGLfJ+DmkRXTEyntJA7H01771uVD6X6nnViv3GToPgb0QOVA8ivOQ==",
"dev": true
},
"elliptic": {