From d07cd177b380800d931ee8d65be340281953ea4a Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 24 Jul 2023 01:17:00 +0100 Subject: [PATCH] Extend TS Usage Signed-off-by: Fred Boniface --- .eslintrc.js | 6 ++++++ src/utils/{auth.utils.js => auth.utils.ts} | 6 +++--- tsconfig.json | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) rename src/utils/{auth.utils.js => auth.utils.ts} (91%) diff --git a/.eslintrc.js b/.eslintrc.js index eaa1a24..640023c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,12 @@ module.exports = { }, 'extends': 'eslint:recommended', 'overrides': [ + { + files: ['**/*.ts','**/*.js'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended'] + } ], 'parserOptions': { 'ecmaVersion': 'latest' diff --git a/src/utils/auth.utils.js b/src/utils/auth.utils.ts similarity index 91% rename from src/utils/auth.utils.js rename to src/utils/auth.utils.ts index c32c417..72fdd2b 100644 --- a/src/utils/auth.utils.js +++ b/src/utils/auth.utils.ts @@ -5,7 +5,7 @@ const fs = require('fs/promises'); const minify = require('../utils/minify.utils'); // Checks users registration key against issued keys -async function isAuthed(uuid) { // Needs testing +async function isAuthed(uuid: string) { // Needs testing const q = {uuid: uuid}; const res = await db.query('users', q); log.out('authUtils.checkUser: DB Query answer: ' + @@ -16,7 +16,7 @@ async function isAuthed(uuid) { // Needs testing } // Checks whether a registration request key is valid -async function checkRequest(key) { +async function checkRequest(key: string) { const collection = 'registrations'; const query = {uuid: key}; const res = await db.query(collection, query); @@ -33,7 +33,7 @@ async function generateKey() { // Needs testing & moving to 'register.utils' return crypto.randomUUID(); } -async function generateConfirmationEmail(eml, uuid) { +async function generateConfirmationEmail(eml: string, uuid: string) { try { const htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8'); const htmlStr = htmlTpl.replace(/>>ACCESSCODE<