updated post api
This commit is contained in:
parent
455240d312
commit
1438583e9f
3 changed files with 7 additions and 9 deletions
10
README.md
10
README.md
|
@ -35,17 +35,15 @@ spee.ch is a single-serving site that reads and publishes images to and from the
|
||||||
## API
|
## API
|
||||||
|
|
||||||
#### GET
|
#### GET
|
||||||
* spee.ch/api/resolve/:name
|
* /api/resolve/:name
|
||||||
* a successfull request returns the resolve results for the claim at that name in JSON format
|
* a successfull request returns the resolve results for the claim at that name in JSON format
|
||||||
* spee.ch/api/claim_list/:name
|
* /api/claim_list/:name
|
||||||
* a successfull request returns a list of claims at that claim name in JSON format
|
* a successfull request returns a list of claims at that claim name in JSON format
|
||||||
|
|
||||||
#### POST
|
#### POST
|
||||||
* spee.ch/api/publish
|
* /api/publish
|
||||||
* request parameters:
|
* request parameters:
|
||||||
* header:
|
* body (form-data):
|
||||||
* Content-Type: multipart/form-data
|
|
||||||
* body:
|
|
||||||
* claim: string (optional, defults to the file's name sans extension)
|
* claim: string (optional, defults to the file's name sans extension)
|
||||||
* license: string (optional, defaults to "No License Provided")
|
* license: string (optional, defaults to "No License Provided")
|
||||||
* nsfw: string ("on"/"off") or boolean (true/false). (optional, defaults `true`)
|
* nsfw: string ("on"/"off") or boolean (true/false). (optional, defaults `true`)
|
||||||
|
|
|
@ -8,7 +8,7 @@ module.exports = {
|
||||||
} else if (error.response) {
|
} else if (error.response) {
|
||||||
res.status(error.response.status).send(error.response.data.error.message);
|
res.status(error.response.status).send(error.response.data.error.message);
|
||||||
} else if (error.code === 'ECONNREFUSED') {
|
} else if (error.code === 'ECONNREFUSED') {
|
||||||
res.status(400).send('Connection refused. The daemon may not be running.');
|
res.status(503).send('Connection refused. The daemon may not be running.');
|
||||||
} else {
|
} else {
|
||||||
res.status(400).send(JSON.stringify(error));
|
res.status(400).send(JSON.stringify(error));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ module.exports = app => {
|
||||||
// route to run a publish request on the daemon
|
// route to run a publish request on the daemon
|
||||||
app.post('/api/publish', multipartMiddleware, ({ originalUrl, body, files }, res) => {
|
app.post('/api/publish', multipartMiddleware, ({ originalUrl, body, files }, res) => {
|
||||||
logger.debug(`POST request on ${originalUrl}`);
|
logger.debug(`POST request on ${originalUrl}`);
|
||||||
const file = files.file1 || files.null;
|
const file = files.thumbnail || files.null;
|
||||||
if (!file) {
|
if (!file) {
|
||||||
res.status(500).json({ 'success': false, 'error': 'No file was submitted. Form submission must have key "speechFile"', 'data': null });
|
res.status(400).send('error: No file was submitted or the key used was incorrect. Files posted through this route must use a key of "thumbnail" or null');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const name = body.claim || file.name.substring(0, file.name.indexOf('.'));
|
const name = body.claim || file.name.substring(0, file.name.indexOf('.'));
|
||||||
|
|
Loading…
Reference in a new issue