big update - fully functional

This commit is contained in:
Daniel Ledda
2021-03-21 16:19:52 +01:00
parent 50362860ae
commit 5466b8d2bb
25 changed files with 824 additions and 461 deletions

View File

@@ -3,7 +3,7 @@ import SnapshotCollection from "./SnapshotCollection";
import express, {Router} from "express";
import {CollectionRegistry} from "./Collections";
import {ClayPIError} from "./errors";
import {toMySQLDatetime} from "./utils";
import {unixTimeParamMiddleware} from "./utils";
function newSnapshotRouter(collections: CollectionRegistry) {
const router = Router();
@@ -80,14 +80,4 @@ function newSnapshotRouter(collections: CollectionRegistry) {
return router;
}
const unixTimeParamMiddleware: express.Handler = (req, res, next) => {
const timeFormat = req.query.timeFormat;
if (typeof timeFormat !== "undefined" && timeFormat !== "iso" && timeFormat !== "unix") {
throw new ClayPIError("Parameter 'timeFormat' must be either 'iso' or 'unix'");
} else {
res.locals.timeFormat = timeFormat;
next();
}
};
export default newSnapshotRouter;