From b7044af0e69664cb266b8408e1f2b27af7d0ef95 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Wed, 1 Dec 2021 02:17:23 +0400 Subject: [PATCH] Moved exports to the bottom. It just looks prettier. --- shared/util.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/shared/util.js b/shared/util.js index 5b0a11e..6d7603b 100644 --- a/shared/util.js +++ b/shared/util.js @@ -1,26 +1,22 @@ const moment = require("moment-timezone"); -const formats = Object.freeze({ +const date_formats = Object.freeze({ post_date: "Do MMMM YYYY HH:mm:ss z", file_date: "YYYY-MM-DD HH:mm:ss z", id_date: "YYYYMMDD-HHmm" }); -exports.formats = formats; - -function datetime(date, format=formats.post_date, timezone="UTC") { +function datetime(date, format=date_formats.post_date, timezone="UTC") { return moment.utc(date).tz(timezone).format(format); } -exports.datetime = datetime; - -exports.getClientTimezone = ctx => { +function getClientTimezone(ctx) { if (ctx.header['x-client-timezone'] !== undefined) return ctx.header['x-client-timezone']; else return "UTC"; -}; +} -exports.getServiceByHost = (host, service="") => { +function getServiceByHost(host, service="") { if (host.endsWith("onion")) switch (service) { case "radio": return "http://wsmkgnmhmzqm7kyzv7jnzzafvgm7xlmlfvzhgorpapd5or2arnhuktqd.onion"; @@ -44,12 +40,13 @@ exports.getServiceByHost = (host, service="") => { } } -exports.rssLink = (proto, host, date, category, timezone="UTC") => - `${proto}://${host}/mindflow#${category}-${datetime(date, formats.id_date, timezone)}`; +function rssLink(proto, host, date, category, timezone="UTC") { + return `${proto}://${host}/mindflow#${category}-${datetime(date, date_formats.id_date, timezone)}`; +} // This code was taken from https://www.npmjs.com/package/mysql#custom-format // Only fourth line was changed. -exports.mysqlQueryFormat = function (query, values) { +function mysqlQueryFormat(query, values) { if (!values) return query; return query.replace(/\:(\w+)/g, function (txt, key) { if (values[key] !== undefined) @@ -58,3 +55,4 @@ exports.mysqlQueryFormat = function (query, values) { }.bind(this)); }; +module.exports = { date_formats, datetime, getClientTimezone, getServiceByHost, rssLink, mysqlQueryFormat } \ No newline at end of file