From 81a859a8d9c31123aac97a9e3fe4cd0620153a4d Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 24 Jul 2023 01:04:55 +0100 Subject: [PATCH] Conversion to TS Signed-off-by: Fred Boniface --- app.js => app.ts | 0 src/utils/{minify.utils.js => minify.utils.ts} | 4 ++-- src/utils/{sanitizer.utils.js => sanitizer.utils.ts} | 10 +++++----- .../{timeConvert.utils.js => timeConvert.utils.ts} | 4 ++-- tsconfig.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename app.js => app.ts (100%) rename src/utils/{minify.utils.js => minify.utils.ts} (59%) rename src/utils/{sanitizer.utils.js => sanitizer.utils.ts} (66%) rename src/utils/{timeConvert.utils.js => timeConvert.utils.ts} (74%) diff --git a/app.js b/app.ts similarity index 100% rename from app.js rename to app.ts diff --git a/src/utils/minify.utils.js b/src/utils/minify.utils.ts similarity index 59% rename from src/utils/minify.utils.js rename to src/utils/minify.utils.ts index caeb190..3f37545 100644 --- a/src/utils/minify.utils.js +++ b/src/utils/minify.utils.ts @@ -1,8 +1,8 @@ const htmlShrink = require('html-minifier').minify; const juice = require('juice'); -module.exports = async function minifyMail(input) { - const inlined = juice(input); +module.exports = async function minifyMail(input: string): Promise { + const inlined: string = juice(input); return htmlShrink(inlined, { removeComments: true, collapseWhitespace: true diff --git a/src/utils/sanitizer.utils.js b/src/utils/sanitizer.utils.ts similarity index 66% rename from src/utils/sanitizer.utils.js rename to src/utils/sanitizer.utils.ts index 9b7d99b..5dd82f0 100644 --- a/src/utils/sanitizer.utils.js +++ b/src/utils/sanitizer.utils.ts @@ -1,26 +1,26 @@ //const log = require('../utils/log.utils'); -function removeNonAlphanumeric(inputString) { +function removeNonAlphanumeric(inputString: string) { return inputString.replace(/[^a-zA-Z0-9]/g, ''); } -function removeNonAlpha(inputString) { +function removeNonAlpha(inputString: string) { return inputString.replace(/[^a-zA-Z]/g, ''); } -function removeNonNumeric(inputString) { +function removeNonNumeric(inputString: string) { return inputString.replace(/[^0-9]/g, ''); } const cleanApiEndpointTxt = removeNonAlpha; const cleanApiEndpointNum = removeNonAlphanumeric; -function cleanNrcc(input) { // Remove newlines and then

tags from input +function cleanNrcc(input: string) { // Remove newlines and then

tags from input const cleanInput = input.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, ''); return cleanInput; } -async function getDomainFromEmail(mail) { // Needs testing +async function getDomainFromEmail(mail: string) { // Needs testing let split = mail.split('@'); return split[1]; } diff --git a/src/utils/timeConvert.utils.js b/src/utils/timeConvert.utils.ts similarity index 74% rename from src/utils/timeConvert.utils.js rename to src/utils/timeConvert.utils.ts index c8710a5..3d4499e 100644 --- a/src/utils/timeConvert.utils.js +++ b/src/utils/timeConvert.utils.ts @@ -1,10 +1,10 @@ -function unixLocal(unix) { +function unixLocal(unix: number) { var jsTime = unix*1000; var dt = new Date(jsTime); return dt.toLocaleString(); } -function jsUnix(js) { +function jsUnix(js: number) { var preRound = js / 1000; return Math.round(preRound); } diff --git a/tsconfig.json b/tsconfig.json index f85d1cb..82caffb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -55,7 +55,7 @@ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */