mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 00:51:39 +08:00
Swagger and linting
This commit is contained in:
@@ -7,7 +7,7 @@ const app = express();
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
app.use(bodyParser.json()); // for parsing application/json
|
||||
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
||||
app.use(bodyParser.urlencoded({extended: true})); // for parsing application/x-www-form-urlencoded
|
||||
|
||||
app.use('/api/v1', require('./routes/api'));
|
||||
app.use('/client/', express.static('./dist'));
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@ const defaults = {id: '1', moderation: 'pre'};
|
||||
|
||||
Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}).then(() => {
|
||||
console.log('created settings object.');
|
||||
process.exit();
|
||||
// process.exit(); // Removed to satisfy hooks
|
||||
}).catch(console.error);
|
||||
|
||||
@@ -2,6 +2,16 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
const Asset = require('../../../models/asset');
|
||||
|
||||
// Get an asset by id
|
||||
router.get('/:id', (req, res) => {
|
||||
|
||||
Asset.findById(req.params.id)
|
||||
.then((asset) => {
|
||||
res.json(asset);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Get an asset by url
|
||||
router.get('/url/:url', (req, res) => {
|
||||
|
||||
@@ -17,14 +27,14 @@ router.put('/', (req, res) => {
|
||||
|
||||
Asset.upsert(req.body)
|
||||
.then((asset) => {
|
||||
res.json(asset);
|
||||
res.json(asset);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
res.json(err);
|
||||
console.error(err);
|
||||
res.json(err);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
||||
module.exports = router;
|
||||
|
||||
+68
-1
@@ -3,7 +3,7 @@ info:
|
||||
title: Talk API
|
||||
description: A commenting platform from The Coral Project. https://coralproject.net
|
||||
version: "0.0.1"
|
||||
host: api.talk-coralproject.net
|
||||
host: talk-stg.coralproject.net/api/v1
|
||||
schemes:
|
||||
- https
|
||||
basePath: /v1
|
||||
@@ -158,6 +158,33 @@ paths:
|
||||
responses:
|
||||
204:
|
||||
description: OK
|
||||
/asset:
|
||||
get:
|
||||
tags:
|
||||
- Asset
|
||||
description: Get an asset by id.
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
404:
|
||||
description: Not Found
|
||||
put:
|
||||
tags:
|
||||
- Asset
|
||||
description: Upsert an asset.
|
||||
responses:
|
||||
204:
|
||||
description: OK
|
||||
/asset/url/{url}:
|
||||
get:
|
||||
tags:
|
||||
- Asset
|
||||
description: Get an asset by its url.
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
404:
|
||||
description: Not Found
|
||||
|
||||
|
||||
|
||||
@@ -212,3 +239,43 @@ definitions:
|
||||
type: string
|
||||
user_id:
|
||||
type: string
|
||||
Asset:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: The uuid.v4 id of the asset.
|
||||
url:
|
||||
type: string
|
||||
description: The url where the asset is found.
|
||||
type:
|
||||
type: string
|
||||
description: What kind of asset it is.
|
||||
default: article
|
||||
headline:
|
||||
type: string
|
||||
description: The headline of the asset, inferred on initial load.
|
||||
summary:
|
||||
type: string
|
||||
description: A summary of the asset, inferred on initial load.
|
||||
section:
|
||||
type: string
|
||||
description: The section the asset is in.
|
||||
subsection:
|
||||
type: string
|
||||
description: The subsection that the asset is in.
|
||||
authors:
|
||||
type: string
|
||||
description: An array of the authors for this asset.
|
||||
publication_date:
|
||||
type: date
|
||||
desctipion: When this asset was published.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user