lamassu-server/lib/new-admin/server-logs.js
Rafael Taranto b8e0c2175b feat: add graphql support (#349)
* fix: eslint warnings

* refactor: use ramda + sanctuary instead of lodash

* refactor: use prettier-standard for formatting

* feat: enable security

* feat: add graphql

* chore: remove trailing commas from linter

* docs: new scripts on react and new-admin-server

* feat: handle authentication on graphql

* fix: perf improvement to date picker

* chore: add insecure-dev script to run servers
2019-12-24 15:36:41 +01:00

24 lines
583 B
JavaScript

const _ = require('lodash/fp')
const uuid = require('uuid')
const db = require('../db')
const NUM_RESULTS = 500
function getServerLogs (until = new Date().toISOString()) {
const sql = `select id, log_level, timestamp, message from server_logs
order by timestamp desc
limit $1`
return db.any(sql, [ NUM_RESULTS ])
.then(_.map(_.mapKeys(_.camelCase)))
}
function insert () {
const sql = `insert into server_support_logs
(id) values ($1) returning *`
return db.one(sql, [uuid.v4()])
.then(_.mapKeys(_.camelCase))
}
module.exports = { getServerLogs, insert }