moved all sources to src directory

This commit is contained in:
azivner
2018-01-28 22:18:14 -05:00
parent 669d189ab7
commit 52ad7f64b4
468 changed files with 18 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
"use strict";
const express = require('express');
const router = express.Router();
const sql = require('../../services/sql');
const auth = require('../../services/auth');
const wrap = require('express-promise-wrap').wrap;
router.get('', auth.checkApiAuth, wrap(async (req, res, next) => {
await deleteOld();
const result = await sql.getAll("SELECT * FROM event_log ORDER BY dateAdded DESC");
res.send(result);
}));
async function deleteOld() {
const cutoffId = await sql.getFirstValue("SELECT id FROM event_log ORDER BY id DESC LIMIT 1000, 1");
if (cutoffId) {
await sql.doInTransaction(async () => {
await sql.execute("DELETE FROM event_log WHERE id < ?", [cutoffId]);
});
}
}
module.exports = router;