diff --git a/Dockerfile b/Dockerfile index 599a10c..8e7d73a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:23-alpine RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app WORKDIR /home/node/app -COPY package*.json ./ +COPY --chown=node:node package*.json ./ USER node diff --git a/package.json b/package.json index 9cc6b34..18056ff 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,12 @@ "name": "SubmissionsTrackingDBAPI", "version": "0.1.0", "dependencies": { - "express": "4.12.x", - "body-parser": "1.17.1", - "csvtojson": "0.5.14", - "dateformat": "2.0.0", - "mysql": "2.13.0", - "fs": "0.0.2", + "express": "4.21.1", + "body-parser": "1.20.3", + "csvtojson": "2.0.10", + "mysql": "2.18.1", "yamljs": "0.3.0", - "dotenv": "10.0.0" + "dotenv": "16.4.5", + "date-fns-tz": "3.2.0" } } diff --git a/sbRestApiServer.js b/sbRestApiServer.js index d86c607..79c4f64 100644 --- a/sbRestApiServer.js +++ b/sbRestApiServer.js @@ -1,12 +1,12 @@ // Based on https://github.com/sbalagop/neo/blob/master/nserver.js -var express = require('express'); -var fs = require('fs'); +import express from 'express'; +import bodyParser from 'body-parser'; +import mysql from 'mysql'; +import { formatInTimeZone } from 'date-fns-tz'; +import yamljs from 'yamljs'; +import dotenv from 'dotenv'; + var app = express(); -var bodyParser = require('body-parser'); -var mysql = require('mysql'); -var dateFormat = require('dateformat'); -var yamljs = require('yamljs'); -const dotenv = require('dotenv'); dotenv.config(); // Serve static files in 'ui' subdirectory of the directory in which this server is being run (i.e. the Submissions Tracking DB Home page) @@ -126,8 +126,7 @@ function returnResults(res, err, results, format, tsvFields) { tsvFields.forEach(function(entry) { var val = result[entry]; if (entry == "date_last_processed") { // i.e. entry.startsWith("date") - // Note that dates in DB are always GMT - hence are incorrect during BST period - hence the adjustment below - var dateTimeInCurrentTimeZone = dateFormat(new Date(result[entry]),'yyyy-mm-dd HH:MM'); + var dateTimeInCurrentTimeZone = formatInTimeZone(new Date(result[entry]), "Europe/London", 'yyyy-MM-dd HH:mm'); row.push(dateTimeInCurrentTimeZone); } else if (entry === "nextflow_run_id") { if(result[entry] != null && result[entry] != undefined){