Commit 16868f36 authored by A. Koch's avatar A. Koch

fix find queries, add custom error handler

parent e718a88a
......@@ -5,6 +5,7 @@ const
Primus = require('primus'),
morgan = require('morgan'),
cors = require('cors')({ origin: true }),
send = require('@polka/send-type'),
jwt = require('express-jwt'),
jwks = require('jwks-rsa'),
{ json } = require('body-parser'),
......@@ -45,7 +46,12 @@ const setup = async function () {
const
models = require('mbjs-data-models'),
Service = require('./service'),
app = polka({ server })
app = polka({
server,
onError (err, req, res, next) {
send(res, err.status || 500, { code: err.code })
}
})
const jwtCheck = jwt(ObjectUtil.merge({
secret: jwks.expressJwtSecret(config.get('auth.jwks'))
......
......@@ -18,7 +18,7 @@ class Service extends TinyEmitter {
const _this = this
app.get(`/${this._name}`, async (req, res) => {
const results = await this.client.find(JSON.parse(req.params.query || '{}'), req.params)
const results = await this.client.find(JSON.parse(req.query.query || '{}'), req.params)
_this._response(req, res, { items: results })
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment