mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:17:09 +00:00
Add YAML support to events GET endpoint
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
const json = require('./json');
|
||||
const yaml = require('./yaml');
|
||||
const geojson = require('./geojson');
|
||||
const seis = require('./seis');
|
||||
const csv = require('./csv');
|
||||
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
try {
|
||||
const handlers = {
|
||||
"application/json": json,
|
||||
"application/yaml": yaml,
|
||||
"application/geo+json": geojson,
|
||||
"application/vnd.seis+json": seis,
|
||||
"text/csv": csv
|
||||
|
||||
14
lib/www/server/api/middleware/event/list/yaml.js
Normal file
14
lib/www/server/api/middleware/event/list/yaml.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const YAML = require('yaml');
|
||||
const { event } = require('../../../../lib/db');
|
||||
|
||||
const yaml = async function (req, res, next) {
|
||||
try {
|
||||
const response = await event.list(req.params.project, req.query);
|
||||
res.status(200).send(YAML.stringify(response));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = yaml;
|
||||
Reference in New Issue
Block a user