From cbdddae71e6611fb350ff8305176d1a7a244f723 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 20:48:54 +0100 Subject: [PATCH 01/19] Wip setup --- client/tsconfig.json | 2 ++ server/tsconfig.json | 11 +++++++++++ tsconfig.json | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 server/tsconfig.json diff --git a/client/tsconfig.json b/client/tsconfig.json index 0bc03b38de..9e63548a60 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -6,4 +6,6 @@ "lib": ["DOM", "ESNext"], "jsx": "react", }, + "include": ["./**/*"], + "exclude": ["../node_modules", "../server"] } \ No newline at end of file diff --git a/server/tsconfig.json b/server/tsconfig.json new file mode 100644 index 0000000000..b2b0814a4b --- /dev/null +++ b/server/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "target": "ES2022", + "module": "commonjs", + "lib": ["ES2022"], + "types": ["node"], + }, + "include": ["./**/*"], + "exclude": ["../node_modules", "../client"] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index bcb601b012..97fe81b722 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "files": [], "references": [ - { "path": "client" }, - // { "path": "server" } + { "path": "./client" }, + { "path": "./server" } ], } \ No newline at end of file From 75bbf09af79eea212f406067b0bcbdd7136d5ee6 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 20:55:28 +0100 Subject: [PATCH 02/19] package.json: add typecheck command for server --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f21f1c3c12..989ef2a75c 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,9 @@ "storybook:build:css": "sass client/styles/main.scss client/styles/storybook.css", "storybook": "npm run storybook:build:css && storybook dev -p 6006", "build-storybook": "storybook build", - "typecheck": "npm run typecheck:client", - "typecheck:client": "npx tsc --noEmit -p ./client/tsconfig.json" + "typecheck": "npm run typecheck:client && npm run typecheck:server", + "typecheck:client": "npx tsc --noEmit -p ./client/tsconfig.json", + "typecheck:server": "npx tsc --noEmit -p ./server/tsconfig.json" }, "husky": { "hooks": { From b4dac8c0ddf12ebf64749a8308e0db5c597de2ab Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:05:30 +0100 Subject: [PATCH 03/19] 404Page: update to ts, no-verify --- server/views/{404Page.js => 404Page.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/views/{404Page.js => 404Page.ts} (100%) diff --git a/server/views/404Page.js b/server/views/404Page.ts similarity index 100% rename from server/views/404Page.js rename to server/views/404Page.ts From 9895ed358e0d78b8cbf93ed0b8e520ab998fcbe8 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:13:19 +0100 Subject: [PATCH 04/19] server/types: create ProjectFile interface --- server/types/project.type.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 server/types/project.type.ts diff --git a/server/types/project.type.ts b/server/types/project.type.ts new file mode 100644 index 0000000000..c7e855594a --- /dev/null +++ b/server/types/project.type.ts @@ -0,0 +1,8 @@ +export interface ProjectFile { + name: string; + content: string; + url: string; + children: string[]; + fileType: string; + isSelectedFile: boolean; +} From 71a60dcfc748eae8a71c45fc8c76905ee973d19f Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:14:43 +0100 Subject: [PATCH 05/19] 404Page: update to named export and add type for project file --- server/views/404Page.ts | 31 +++++++----- server/views/index.js | 102 ++++++++++++++++++++++++++++++---------- 2 files changed, 96 insertions(+), 37 deletions(-) diff --git a/server/views/404Page.ts b/server/views/404Page.ts index 7c864f4009..66cc117dc2 100644 --- a/server/views/404Page.ts +++ b/server/views/404Page.ts @@ -1,7 +1,8 @@ import User from '../models/user'; import Project from '../models/project'; +import { ProjectFile } from '../types/project.type'; -const insertErrorMessage = (htmlFile) => { +const insertErrorMessage = (htmlFile: string) => { const html = htmlFile.split(''); const metaDescription = 'A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.'; // eslint-disable-line html[0] = ` @@ -84,7 +85,10 @@ export const get404Sketch = async () => { return errorMessage; } - const projects = await Project.find({ user: p5User._id }).exec(); + const projects = await Project.find({ + // eslint-disable-next-line no-underscore-dangle + user: p5User._id + }).exec(); if (!projects.length) { return errorMessage; @@ -94,33 +98,36 @@ export const get404Sketch = async () => { const sketch = projects[randomIndex]; // Get sketch files - let htmlFile = sketch.files.find((file) => file.name.match(/.*\.html$/i)) - .content; - const jsFiles = sketch.files.filter((file) => file.name.match(/.*\.js$/i)); - const cssFiles = sketch.files.filter((file) => + let htmlFile = sketch.files.find((file: ProjectFile) => + file.name.match(/.*\.html$/i) + ).content; + const jsFiles = sketch.files.filter((file: ProjectFile) => + file.name.match(/.*\.js$/i) + ); + const cssFiles = sketch.files.filter((file: ProjectFile) => file.name.match(/.*\.css$/i) ); - const linkedFiles = sketch.files.filter((file) => file.url); + const linkedFiles = sketch.files.filter((file: ProjectFile) => file.url); const instanceMode = jsFiles - .find((file) => file.name === 'sketch.js') + .find((file: ProjectFile) => file.name === 'sketch.js') .content.includes('Instance Mode'); - jsFiles.forEach((file) => { + jsFiles.forEach((file: ProjectFile) => { // Add js files as script tags const html = htmlFile.split(''); html[0] = `${html[0]}`; htmlFile = html.join(''); }); - cssFiles.forEach((file) => { + cssFiles.forEach((file: ProjectFile) => { // Add css files as style tags const html = htmlFile.split(''); html[0] = `${html[0]}`; htmlFile = html.join(''); }); - linkedFiles.forEach((file) => { + linkedFiles.forEach((file: ProjectFile) => { // Add linked files as link tags const html = htmlFile.split(''); html[1] = `${html[1]}`; @@ -153,5 +160,3 @@ export const get404Sketch = async () => { throw err; } }; - -export default get404Sketch; diff --git a/server/views/index.js b/server/views/index.js index e1c78d3437..4d1368ca59 100644 --- a/server/views/index.js +++ b/server/views/index.js @@ -1,7 +1,8 @@ -import get404Sketch from './404Page'; +import { get404Sketch } from './404Page'; export function renderIndex() { - const assetsManifest = process.env.webpackAssets && JSON.parse(process.env.webpackAssets); + const assetsManifest = + process.env.webpackAssets && JSON.parse(process.env.webpackAssets); return ` @@ -11,7 +12,11 @@ export function renderIndex() { p5.js Web Editor - ${process.env.NODE_ENV === 'production' ? `` : ''} + ${ + process.env.NODE_ENV === 'production' + ? `` + : '' + } @@ -25,16 +30,34 @@ export function renderIndex() { window.process.env.API_URL = '${process.env.API_URL}'; window.process.env.NODE_ENV = '${process.env.NODE_ENV}'; window.process.env.S3_BUCKET = '${process.env.S3_BUCKET}'; - window.process.env.S3_BUCKET_URL_BASE = ${process.env.S3_BUCKET_URL_BASE ? `'${process.env.S3_BUCKET_URL_BASE}'` : undefined}; + window.process.env.S3_BUCKET_URL_BASE = ${ + process.env.S3_BUCKET_URL_BASE + ? `'${process.env.S3_BUCKET_URL_BASE}'` + : undefined + }; window.process.env.AWS_REGION = '${process.env.AWS_REGION}'; - window.process.env.FORCE_TO_HTTPS = ${process.env.FORCE_TO_HTTPS === 'false' ? false : undefined}; + window.process.env.FORCE_TO_HTTPS = ${ + process.env.FORCE_TO_HTTPS === 'false' ? false : undefined + }; window.process.env.CLIENT = true; - window.process.env.LOGIN_ENABLED = ${process.env.LOGIN_ENABLED === 'false' ? false : true}; - window.process.env.EXAMPLES_ENABLED = ${process.env.EXAMPLES_ENABLED === 'false' ? false : true}; - window.process.env.UI_ACCESS_TOKEN_ENABLED = ${process.env.UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true}; - window.process.env.UI_COLLECTIONS_ENABLED = ${process.env.UI_COLLECTIONS_ENABLED === 'false' ? false : true}; - window.process.env.UPLOAD_LIMIT = ${process.env.UPLOAD_LIMIT ? `${process.env.UPLOAD_LIMIT}` : undefined}; - window.process.env.TRANSLATIONS_ENABLED = ${process.env.TRANSLATIONS_ENABLED === 'true' ? true : false}; + window.process.env.LOGIN_ENABLED = ${ + process.env.LOGIN_ENABLED === 'false' ? false : true + }; + window.process.env.EXAMPLES_ENABLED = ${ + process.env.EXAMPLES_ENABLED === 'false' ? false : true + }; + window.process.env.UI_ACCESS_TOKEN_ENABLED = ${ + process.env.UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true + }; + window.process.env.UI_COLLECTIONS_ENABLED = ${ + process.env.UI_COLLECTIONS_ENABLED === 'false' ? false : true + }; + window.process.env.UPLOAD_LIMIT = ${ + process.env.UPLOAD_LIMIT ? `${process.env.UPLOAD_LIMIT}` : undefined + }; + window.process.env.TRANSLATIONS_ENABLED = ${ + process.env.TRANSLATIONS_ENABLED === 'true' ? true : false + }; window.process.env.PREVIEW_URL = '${process.env.PREVIEW_URL}'; window.process.env.GA_MEASUREMENT_ID='${process.env.GA_MEASUREMENT_ID}'; @@ -42,14 +65,19 @@ export function renderIndex() {
- + `; } export function renderProjectIndex(username, projectName) { - const assetsManifest = process.env.webpackAssets && JSON.parse(process.env.webpackAssets); + const assetsManifest = + process.env.webpackAssets && JSON.parse(process.env.webpackAssets); return ` @@ -59,7 +87,11 @@ export function renderProjectIndex(username, projectName) { ${`${projectName} by ${username} -`}p5.js Web Editor - ${process.env.NODE_ENV === 'production' ? `` : ''} + ${ + process.env.NODE_ENV === 'production' + ? `` + : '' + } @@ -73,16 +105,34 @@ export function renderProjectIndex(username, projectName) { window.process.env.API_URL = '${process.env.API_URL}'; window.process.env.NODE_ENV = '${process.env.NODE_ENV}'; window.process.env.S3_BUCKET = '${process.env.S3_BUCKET}'; - window.process.env.S3_BUCKET_URL_BASE = ${process.env.S3_BUCKET_URL_BASE ? `'${process.env.S3_BUCKET_URL_BASE}'` : undefined}; + window.process.env.S3_BUCKET_URL_BASE = ${ + process.env.S3_BUCKET_URL_BASE + ? `'${process.env.S3_BUCKET_URL_BASE}'` + : undefined + }; window.process.env.AWS_REGION = '${process.env.AWS_REGION}'; - window.process.env.FORCE_TO_HTTPS = ${process.env.FORCE_TO_HTTPS === 'false' ? false : undefined}; + window.process.env.FORCE_TO_HTTPS = ${ + process.env.FORCE_TO_HTTPS === 'false' ? false : undefined + }; window.process.env.CLIENT = true; - window.process.env.LOGIN_ENABLED = ${process.env.LOGIN_ENABLED === 'false' ? false : true}; - window.process.env.EXAMPLES_ENABLED = ${process.env.EXAMPLES_ENABLED === 'false' ? false : true}; - window.process.env.UI_ACCESS_TOKEN_ENABLED = ${process.env.UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true}; - window.process.env.UI_COLLECTIONS_ENABLED = ${process.env.UI_COLLECTIONS_ENABLED === 'false' ? false : true}; - window.process.env.UPLOAD_LIMIT = ${process.env.UPLOAD_LIMIT ? `${process.env.UPLOAD_LIMIT}` : undefined}; - window.process.env.TRANSLATIONS_ENABLED = ${process.env.TRANSLATIONS_ENABLED === 'true' ? true : false}; + window.process.env.LOGIN_ENABLED = ${ + process.env.LOGIN_ENABLED === 'false' ? false : true + }; + window.process.env.EXAMPLES_ENABLED = ${ + process.env.EXAMPLES_ENABLED === 'false' ? false : true + }; + window.process.env.UI_ACCESS_TOKEN_ENABLED = ${ + process.env.UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true + }; + window.process.env.UI_COLLECTIONS_ENABLED = ${ + process.env.UI_COLLECTIONS_ENABLED === 'false' ? false : true + }; + window.process.env.UPLOAD_LIMIT = ${ + process.env.UPLOAD_LIMIT ? `${process.env.UPLOAD_LIMIT}` : undefined + }; + window.process.env.TRANSLATIONS_ENABLED = ${ + process.env.TRANSLATIONS_ENABLED === 'true' ? true : false + }; window.process.env.PREVIEW_URL = '${process.env.PREVIEW_URL}'; window.process.env.GA_MEASUREMENT_ID='${process.env.GA_MEASUREMENT_ID}'; @@ -90,7 +140,11 @@ export function renderProjectIndex(username, projectName) {
- + `; @@ -110,4 +164,4 @@ export default async function sendHtml(req, res, exists = true) { } else { res.send(renderIndex()); } -}; +} From 51b96ccb5ab6050919a3c039e29c42d295188321 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:19:00 +0100 Subject: [PATCH 06/19] consolidationMailLayout: update to ts, no-verify --- .../{consolidationMailLayout.js => consolidationMailLayout.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/views/{consolidationMailLayout.js => consolidationMailLayout.ts} (100%) diff --git a/server/views/consolidationMailLayout.js b/server/views/consolidationMailLayout.ts similarity index 100% rename from server/views/consolidationMailLayout.js rename to server/views/consolidationMailLayout.ts From ee1248e5f8ac54e5099aee6b0d826a96cc232aa7 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:24:07 +0100 Subject: [PATCH 07/19] consolidationMailLayout: update to named export and add interface --- server/views/consolidationMailLayout.ts | 19 +++++++++++++++++-- server/views/mail.js | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/server/views/consolidationMailLayout.ts b/server/views/consolidationMailLayout.ts index e317a8bfcd..e116e5ba91 100644 --- a/server/views/consolidationMailLayout.ts +++ b/server/views/consolidationMailLayout.ts @@ -1,4 +1,19 @@ -export default ({ +interface consolidationMailLayoutProps { + domain: string; + headingText: string; + greetingText: string; + messageText: string; + username: string; + email: string; + message2Text: string; + resetPasswordLink: string; + directLinkText: string; + resetPasswordText: string; + noteText: string; + meta: { keywords: string; description: string }; +} + +export const consolidationMailLayout = ({ domain, headingText, greetingText, @@ -11,7 +26,7 @@ export default ({ resetPasswordText, noteText, meta -}) => +}: consolidationMailLayoutProps) => ` diff --git a/server/views/mail.js b/server/views/mail.js index 0d478fff94..462054f6d7 100644 --- a/server/views/mail.js +++ b/server/views/mail.js @@ -1,6 +1,6 @@ import renderMjml from '../utils/renderMjml'; import mailLayout from './mailLayout'; -import consolidationMailLayout from './consolidationMailLayout'; +import { consolidationMailLayout } from './consolidationMailLayout'; export const renderAccountConsolidation = (data) => { const subject = 'p5.js Web Editor Account Consolidation'; From c3b6680e6c5afdaffd9110bad59a6667509faac7 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:27:11 +0100 Subject: [PATCH 08/19] server/types: Add MailTemplate type and updaet consolidationMailLayout --- server/types/mail.type.ts | 14 ++++++++++++++ server/views/consolidationMailLayout.ts | 17 ++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 server/types/mail.type.ts diff --git a/server/types/mail.type.ts b/server/types/mail.type.ts new file mode 100644 index 0000000000..6fdb02d9fb --- /dev/null +++ b/server/types/mail.type.ts @@ -0,0 +1,14 @@ +export interface MailTemplate { + domain: string; + headingText: string; + greetingText: string; + messageText: string; + username: string; + email: string; + message2Text: string; + resetPasswordLink: string; + directLinkText: string; + resetPasswordText: string; + noteText: string; + meta: { keywords: string; description: string }; +} diff --git a/server/views/consolidationMailLayout.ts b/server/views/consolidationMailLayout.ts index e116e5ba91..192b3612bf 100644 --- a/server/views/consolidationMailLayout.ts +++ b/server/views/consolidationMailLayout.ts @@ -1,17 +1,4 @@ -interface consolidationMailLayoutProps { - domain: string; - headingText: string; - greetingText: string; - messageText: string; - username: string; - email: string; - message2Text: string; - resetPasswordLink: string; - directLinkText: string; - resetPasswordText: string; - noteText: string; - meta: { keywords: string; description: string }; -} +import { MailTemplate } from '../types/mail.type'; export const consolidationMailLayout = ({ domain, @@ -26,7 +13,7 @@ export const consolidationMailLayout = ({ resetPasswordText, noteText, meta -}: consolidationMailLayoutProps) => +}: MailTemplate) => ` From 674da65622acbf14578e725b77febb74fbcfc40b Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:37:00 +0100 Subject: [PATCH 09/19] mailLayout: migrate to ts, no-verify --- server/views/{mailLayout.js => mailLayout.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/views/{mailLayout.js => mailLayout.ts} (100%) diff --git a/server/views/mailLayout.js b/server/views/mailLayout.ts similarity index 100% rename from server/views/mailLayout.js rename to server/views/mailLayout.ts From 80a377ec13f9dd6be2c833487f44590a62603365 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:37:10 +0100 Subject: [PATCH 10/19] clean up mail template types --- server/types/mail.type.ts | 18 ++++++++++++++---- server/views/consolidationMailLayout.ts | 4 ++-- server/views/mail.js | 2 +- server/views/mailLayout.ts | 6 ++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/server/types/mail.type.ts b/server/types/mail.type.ts index 6fdb02d9fb..9def204eeb 100644 --- a/server/types/mail.type.ts +++ b/server/types/mail.type.ts @@ -1,14 +1,24 @@ -export interface MailTemplate { +interface BaseMailTemplate { domain: string; headingText: string; greetingText: string; messageText: string; + directLinkText: string; + noteText: string; + meta: { keywords: string; description: string }; +} + +/** Email template for account consolidation, when user has previously registered with another account */ +export interface AccountConsolidationMailTemplate extends BaseMailTemplate { username: string; email: string; message2Text: string; resetPasswordLink: string; - directLinkText: string; resetPasswordText: string; - noteText: string; - meta: { keywords: string; description: string }; +} + +/** Standard email template */ +export interface MailTemplate extends BaseMailTemplate { + link: string; + buttonText: string; } diff --git a/server/views/consolidationMailLayout.ts b/server/views/consolidationMailLayout.ts index 192b3612bf..7af1657304 100644 --- a/server/views/consolidationMailLayout.ts +++ b/server/views/consolidationMailLayout.ts @@ -1,4 +1,4 @@ -import { MailTemplate } from '../types/mail.type'; +import { AccountConsolidationMailTemplate } from '../types/mail.type'; export const consolidationMailLayout = ({ domain, @@ -13,7 +13,7 @@ export const consolidationMailLayout = ({ resetPasswordText, noteText, meta -}: MailTemplate) => +}: AccountConsolidationMailTemplate) => ` diff --git a/server/views/mail.js b/server/views/mail.js index 462054f6d7..3e60720cbc 100644 --- a/server/views/mail.js +++ b/server/views/mail.js @@ -1,5 +1,5 @@ import renderMjml from '../utils/renderMjml'; -import mailLayout from './mailLayout'; +import { mailLayout } from './mailLayout'; import { consolidationMailLayout } from './consolidationMailLayout'; export const renderAccountConsolidation = (data) => { diff --git a/server/views/mailLayout.ts b/server/views/mailLayout.ts index 58f1479e03..7ed0523d2d 100644 --- a/server/views/mailLayout.ts +++ b/server/views/mailLayout.ts @@ -1,4 +1,6 @@ -export default ({ +import { MailTemplate } from '../types/mail.type'; + +export const mailLayout = ({ domain, headingText, greetingText, @@ -8,7 +10,7 @@ export default ({ directLinkText, noteText, meta -}) => +}: MailTemplate) => ` From 0949eee1d96fe695e5a7c1a6c43d0f933bea142b Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:46:49 +0100 Subject: [PATCH 11/19] views/mail: migrate to ts, no-verify --- server/views/{mail.js => mail.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/views/{mail.js => mail.ts} (100%) diff --git a/server/views/mail.js b/server/views/mail.ts similarity index 100% rename from server/views/mail.js rename to server/views/mail.ts From 88e18f13ed8db496e43a0008ccc1616ce7c44dac Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:52:46 +0100 Subject: [PATCH 12/19] views/mail: add types --- server/types/mail.type.ts | 19 ++++++++++++++++++- server/views/mail.ts | 12 +++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/server/types/mail.type.ts b/server/types/mail.type.ts index 9def204eeb..39241b95fd 100644 --- a/server/types/mail.type.ts +++ b/server/types/mail.type.ts @@ -16,9 +16,26 @@ export interface AccountConsolidationMailTemplate extends BaseMailTemplate { resetPasswordLink: string; resetPasswordText: string; } +/** Email options for account consolidation, when user has previously registered with another account */ +export interface AccountConsolidationMailOptions { + body: { + domain: string; + username: string; + email: string; + }; + to: string; +} -/** Standard email template */ +/** Standard email template, used for email confirmation & password reset */ export interface MailTemplate extends BaseMailTemplate { link: string; buttonText: string; } +/** Standard email options, used for email confirmation & password reset */ +export interface MailOptions { + body: { + domain: string; + link: string; + }; + to: string; +} diff --git a/server/views/mail.ts b/server/views/mail.ts index 3e60720cbc..480fbb8da8 100644 --- a/server/views/mail.ts +++ b/server/views/mail.ts @@ -1,8 +1,14 @@ import renderMjml from '../utils/renderMjml'; import { mailLayout } from './mailLayout'; import { consolidationMailLayout } from './consolidationMailLayout'; +import { + MailOptions, + AccountConsolidationMailOptions +} from '../types/mail.type'; -export const renderAccountConsolidation = (data) => { +export const renderAccountConsolidation = ( + data: AccountConsolidationMailOptions +) => { const subject = 'p5.js Web Editor Account Consolidation'; const templateOptions = { domain: data.body.domain, @@ -40,7 +46,7 @@ export const renderAccountConsolidation = (data) => { return Object.assign({}, data, { html, subject }); }; -export const renderResetPassword = (data) => { +export const renderResetPassword = (data: MailOptions) => { const subject = 'p5.js Web Editor Password Reset'; const templateOptions = { domain: data.body.domain, @@ -71,7 +77,7 @@ export const renderResetPassword = (data) => { return Object.assign({}, data, { html, subject }); }; -export const renderEmailConfirmation = (data) => { +export const renderEmailConfirmation = (data: MailOptions) => { const subject = 'p5.js Email Verification'; const templateOptions = { domain: data.body.domain, From 944bc04cdd33c7445ae6d0187c0e4fab51111f96 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 21:56:02 +0100 Subject: [PATCH 13/19] views/previewIndex: migrate to ts --- server/views/{previewIndex.js => previewIndex.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/views/{previewIndex.js => previewIndex.ts} (100%) diff --git a/server/views/previewIndex.js b/server/views/previewIndex.ts similarity index 100% rename from server/views/previewIndex.js rename to server/views/previewIndex.ts From 539530a3835c0413d88a88302b28d297b706100a Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 22:09:16 +0100 Subject: [PATCH 14/19] previewIndex: update to named export --- server/previewServer.js | 2 +- server/views/previewIndex.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/previewServer.js b/server/previewServer.js index 8160e9a1ab..e46c8a454a 100644 --- a/server/previewServer.js +++ b/server/previewServer.js @@ -8,7 +8,7 @@ import webpackHotMiddleware from '@gatsbyjs/webpack-hot-middleware'; import config from '../webpack/config.dev'; import embedRoutes from './routes/embed.routes'; import assetRoutes from './routes/asset.routes'; -import renderPreviewIndex from './views/previewIndex'; +import { renderPreviewIndex } from './views/previewIndex'; const app = new Express(); diff --git a/server/views/previewIndex.ts b/server/views/previewIndex.ts index 60cb6e15b4..f3de4df4d5 100644 --- a/server/views/previewIndex.ts +++ b/server/views/previewIndex.ts @@ -1,4 +1,4 @@ -function renderPreviewIndex() { +export function renderPreviewIndex() { const assetsManifest = process.env.webpackAssets && JSON.parse(process.env.webpackAssets); return ` @@ -34,5 +34,3 @@ function renderPreviewIndex() { `; } - -export default renderPreviewIndex; From cc1891882c672eccfc28adc1959418823654045d Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 22:24:28 +0100 Subject: [PATCH 15/19] views/index: update to ts, no-verify --- server/views/{index.js => index.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/views/{index.js => index.ts} (100%) diff --git a/server/views/index.js b/server/views/index.ts similarity index 100% rename from server/views/index.js rename to server/views/index.ts From 1f1a412e8581fb945f4096d188854cb2ac5e10c3 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 22:27:05 +0100 Subject: [PATCH 16/19] views/index: update to named export and add express types --- server/routes/server.routes.js | 2 +- server/views/index.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js index 83b155a151..ec153f03c6 100644 --- a/server/routes/server.routes.js +++ b/server/routes/server.routes.js @@ -1,5 +1,5 @@ import { Router } from 'express'; -import sendHtml, { renderIndex, renderProjectIndex } from '../views/index'; +import { renderIndex, renderProjectIndex, sendHtml } from '../views/index'; import { userExists } from '../controllers/user.controller'; import { projectExists, diff --git a/server/views/index.ts b/server/views/index.ts index 4d1368ca59..50414f3913 100644 --- a/server/views/index.ts +++ b/server/views/index.ts @@ -1,3 +1,5 @@ +/* eslint-disable no-unneeded-ternary */ +import { Request, Response } from 'express'; import { get404Sketch } from './404Page'; export function renderIndex() { @@ -75,7 +77,7 @@ export function renderIndex() { `; } -export function renderProjectIndex(username, projectName) { +export function renderProjectIndex(username: string, projectName: string) { const assetsManifest = process.env.webpackAssets && JSON.parse(process.env.webpackAssets); return ` @@ -156,7 +158,11 @@ export function renderProjectIndex(username, projectName) { * @param {import('express').e.Response} res * @param {boolean} [exists] */ -export default async function sendHtml(req, res, exists = true) { +export async function sendHtml( + req: Request, + res: Response, + exists: boolean = true +) { if (!exists) { res.status(404); const html = await get404Sketch(); From c01d866caba24e53eb570a7c578e0d4a154ed950 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 22:30:08 +0100 Subject: [PATCH 17/19] utils/generateFileSystemSafeName: update to ts, no-verify --- ...enerateFileSystemSafeName.js => generateFileSystemSafeName.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/utils/{generateFileSystemSafeName.js => generateFileSystemSafeName.ts} (100%) diff --git a/server/utils/generateFileSystemSafeName.js b/server/utils/generateFileSystemSafeName.ts similarity index 100% rename from server/utils/generateFileSystemSafeName.js rename to server/utils/generateFileSystemSafeName.ts From 2ac712c9e6a263ff9c8edfc67696d3d96c025057 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Fri, 5 Sep 2025 22:31:18 +0100 Subject: [PATCH 18/19] utils/generateFileSystemSafeName: add types to params and update to named export --- server/controllers/project.controller.js | 2 +- server/utils/generateFileSystemSafeName.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index b1e167969b..18611eafb5 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -9,7 +9,7 @@ import slugify from 'slugify'; import Project from '../models/project'; import User from '../models/user'; import { resolvePathToFile } from '../utils/filePath'; -import generateFileSystemSafeName from '../utils/generateFileSystemSafeName'; +import { generateFileSystemSafeName } from '../utils/generateFileSystemSafeName'; export { default as createProject, diff --git a/server/utils/generateFileSystemSafeName.ts b/server/utils/generateFileSystemSafeName.ts index db835979a7..ba300034a2 100644 --- a/server/utils/generateFileSystemSafeName.ts +++ b/server/utils/generateFileSystemSafeName.ts @@ -5,12 +5,10 @@ * @param {String} string * @param {String} replacer (optional) character to replace invalid characters */ -function generateFileSystemSafeName(string, replacer) { +export function generateFileSystemSafeName(string: string, replacer: string) { // from here https://serverfault.com/a/242134 const INVALID_CHARS_REGEX = /[*/?:\\<>|"\u0000-\u001F]/g; // eslint-disable-line const slug = string.replace(INVALID_CHARS_REGEX, replacer || ''); return slug; } - -export default generateFileSystemSafeName; From bc7e1ab2cc24cef54e648b8bb2e75ef24531fe87 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Sat, 6 Sep 2025 20:11:17 +0100 Subject: [PATCH 19/19] attempt to resolve auto-resolve imports errors, no-verify --- server/controllers/project.controller.js | 3 ++- webpack/config.dev.js | 2 +- webpack/config.examples.js | 6 +++--- webpack/config.prod.js | 2 +- webpack/config.server.js | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index 18611eafb5..1ac4213428 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -9,7 +9,8 @@ import slugify from 'slugify'; import Project from '../models/project'; import User from '../models/user'; import { resolvePathToFile } from '../utils/filePath'; -import { generateFileSystemSafeName } from '../utils/generateFileSystemSafeName'; +// eslint-disable-next-line import/extensions +import { generateFileSystemSafeName } from '../utils/generateFileSystemSafeName.ts'; export { default as createProject, diff --git a/webpack/config.dev.js b/webpack/config.dev.js index 0475ddc327..f2fe8e2720 100644 --- a/webpack/config.dev.js +++ b/webpack/config.dev.js @@ -30,7 +30,7 @@ module.exports = { }, resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'], - modules: ['client', 'node_modules'], + mmodules: ['client', 'server', 'node_modules'], fallback: { os: require.resolve('os-browserify/browser') } diff --git a/webpack/config.examples.js b/webpack/config.examples.js index d36959c8ac..268403971d 100644 --- a/webpack/config.examples.js +++ b/webpack/config.examples.js @@ -16,7 +16,7 @@ module.exports = [ resolve: { extensions: ['*', '.js', '.jsx', '.ts', '.tsx'], - modules: ['client', 'node_modules'] + modules: ['client', 'server', 'node_modules'] }, module: { @@ -46,7 +46,7 @@ module.exports = [ resolve: { extensions: ['*', '.js', '.jsx', '.ts', '.tsx'], - modules: ['client', 'node_modules'] + modules: ['client', 'server', 'node_modules'] }, module: { @@ -76,7 +76,7 @@ module.exports = [ resolve: { extensions: ['*', '.js', '.jsx', '.ts', '.tsx'], - modules: ['client', 'node_modules'] + modules: ['client', 'server', 'node_modules'] }, module: { diff --git a/webpack/config.prod.js b/webpack/config.prod.js index 269d64b9bd..e125c621c5 100644 --- a/webpack/config.prod.js +++ b/webpack/config.prod.js @@ -36,7 +36,7 @@ module.exports = { resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'], - modules: ['client', 'node_modules'], + modules: ['client', 'server', 'node_modules'], fallback: { os: require.resolve('os-browserify/browser') } diff --git a/webpack/config.server.js b/webpack/config.server.js index a4b58ea5ab..bbca1c1b7b 100644 --- a/webpack/config.server.js +++ b/webpack/config.server.js @@ -29,7 +29,7 @@ module.exports = { resolve: { extensions: ['*', '.js', '.jsx', '.ts', '.tsx'], - modules: ['client', 'node_modules'] + modules: ['client', 'server', 'node_modules'] }, module: {