Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
dcae2b7
package.json: add @types/express
clairep94 Oct 8, 2025
e4e759c
Merge with develop
clairep94 Oct 8, 2025
fbccc7d
server/utils/isAuthenticated: update to ts, no-verify
clairep94 Oct 8, 2025
a84bf81
server/utils/isAuthenticated: update to named export & add Express ty…
clairep94 Oct 8, 2025
7a61ed3
server/routes/user.routes: organise routes into subdomains
clairep94 Oct 8, 2025
d8435a4
isAuthenticated: add test for middleware
clairep94 Oct 8, 2025
f62e9c4
move isAuthenticated to /server/middleware folder
clairep94 Oct 8, 2025
eae9ca6
server/controllers/user.controller/apiKey.test: migrate to ts, no-verify
clairep94 Oct 8, 2025
b19d61f
server/controllers/user.controller/apiKey.test: resolve type-errors
clairep94 Oct 8, 2025
c2ea2b1
server/controllers/user/apiKey: migrate to ts, no-verify
clairep94 Oct 8, 2025
8848ed5
types/express: add AuthenticatedRequest type, no-verify
clairep94 Oct 8, 2025
548e345
correctly extend the Express User interface with custom properties
clairep94 Oct 8, 2025
6ab4b3d
server/controllers/user.controller: finish typing request and respons…
clairep94 Oct 8, 2025
3f012dd
server/controllers/user.controller: Add tests for signup routes
clairep94 Oct 8, 2025
f4997b6
user controller: migrate relevant routes to /signup
clairep94 Oct 8, 2025
5c2e5d9
create user.controller/helpers.js
clairep94 Oct 8, 2025
d293ee7
controllers/user/helper: add tests and update to ts
clairep94 Oct 8, 2025
f8a7891
migrate emailVerificationInitiate to user.controller/signup & add tests
clairep94 Oct 8, 2025
e0e2aa3
server/controllers/user.controller/signup: update to ts, no-verify
clairep94 Oct 8, 2025
fff6e51
server/controllers/user.controller/signup: add response and request t…
clairep94 Oct 8, 2025
238f545
server/controllers/user.controller/userPreferences: add test for upda…
clairep94 Oct 8, 2025
df35eb4
server/controllers/user.controller/userPreferences: move updateUserPr…
clairep94 Oct 8, 2025
c455dd6
server/controllers/user.controller/userPreferences: add test for upda…
clairep94 Oct 9, 2025
6708adb
user controller tests: correct names in top-level describe
clairep94 Oct 9, 2025
2350199
user controller: add 3rd party auth management tests
clairep94 Oct 9, 2025
1afa044
user controller/auth management: migrate unlinkGithub and unlinkGoogl…
clairep94 Oct 9, 2025
85ef277
fix usercontroller helpers test
clairep94 Oct 9, 2025
13403dd
add test for resetPasswordInitiate
clairep94 Oct 9, 2025
f475d5a
migrate resetPasswordInitiate to /authManagement and add req res types
clairep94 Oct 9, 2025
d61ef5f
user controller: validResetPasswordToken, add test
clairep94 Oct 9, 2025
93695ad
user controller: validateResetPasswordToken, migrate to /authManageme…
clairep94 Oct 9, 2025
b82f974
add test for user.controller updateSettings
clairep94 Oct 9, 2025
c7cd791
user.controller/authManagement tests: re-organise with clearer describes
clairep94 Oct 9, 2025
12a98d9
user.controller updatePassword: add tests
clairep94 Oct 9, 2025
498cfe4
user.controller updatePassword: migrate to /authManagement, add req a…
clairep94 Oct 9, 2025
e845914
updateSettings: migrate to /authManagement, add req and res types, no…
clairep94 Oct 9, 2025
544bcb9
user.controller: migrate userExists to helpers & clean up file
clairep94 Oct 9, 2025
c496b67
migrate user.controller file into index file
clairep94 Oct 9, 2025
08fccf7
migrate types for userPreferences to types folder
clairep94 Oct 9, 2025
5fadd83
migrate types for user controller/signup to types folder
clairep94 Oct 9, 2025
2c14442
migrate types for usercontroller/apikey to types folder
clairep94 Oct 9, 2025
2e1bbe4
migrate tpyes for usercontroller/authManagement to types folder
clairep94 Oct 9, 2025
ea92905
add helper type in types/express to simplify defining route params
clairep94 Oct 9, 2025
3bce71f
fix logic in updateSettings to resolve type error, nest the currentPa…
clairep94 Oct 9, 2025
ea21fc1
add test util to create mockUser for typesafety
clairep94 Oct 9, 2025
33aa06b
add jsdocs to userController.signup routes
clairep94 Oct 9, 2025
57d38f7
add jsdocs to userController.userPreferences routes
clairep94 Oct 9, 2025
6332a45
update user.password to be optional per mongoose schema
clairep94 Oct 9, 2025
e8dcb59
add jsdocs to userController.authManagement routes
clairep94 Oct 9, 2025
3d78cdc
add jsdocs to userController.apiKey routes
clairep94 Oct 9, 2025
eeaa29a
add remaining tests for helpers
clairep94 Oct 9, 2025
0138eb2
uncomment failing tests for authManagement
clairep94 Oct 9, 2025
84396ed
user.controller/userPreferences: update request body type to Partial<…
clairep94 Oct 9, 2025
eb2fc4f
fix helpers tests
clairep94 Oct 9, 2025
bf9626e
fix updatePassword test
clairep94 Oct 9, 2025
df63907
clean up userPreferences test
clairep94 Oct 10, 2025
f78a692
clean up apiKey test
clairep94 Oct 10, 2025
47015cd
clean up authManagement tests
clairep94 Oct 10, 2025
b0548ea
split up authManagement tests into sub files for easier reading
clairep94 Oct 10, 2025
fd98175
clean up tests by migrating frequent mocks to mock files
clairep94 Oct 10, 2025
e46db9b
resolve updateSetting tests with current logic
clairep94 Oct 10, 2025
1426142
cleanup jsdocs
clairep94 Oct 10, 2025
37d3e2e
server/tsconfig, client/tsconfig: add alias to other folder
clairep94 Oct 10, 2025
affdf05
common/types: import server types to expose to client
clairep94 Oct 10, 2025
76c1750
client/persistState: migrate to ts, no-verify
clairep94 Oct 10, 2025
bebb22a
client/store: update to ts, no-verify
clairep94 Oct 10, 2025
b1dd2e8
client/storeInstance: migrate to ts, no-verify
clairep94 Oct 10, 2025
4a58547
client/reducers: migrate to ts, no-verify
clairep94 Oct 10, 2025
f15484f
client/reducers: create root reducer type & keep default export
clairep94 Oct 10, 2025
d423f80
client/store: add RootState type to setupStore
clairep94 Oct 10, 2025
01e4abe
client/testData/testReduxStore: migrate to ts, no-verify
clairep94 Oct 10, 2025
e895e52
client/testData/testReduxStore: add RootState type
clairep94 Oct 10, 2025
c203148
client/store: update to named export
clairep94 Oct 10, 2025
2c659b6
client/storeInstance: delete unused file, already defined in client/i…
clairep94 Oct 10, 2025
86fddba
client/persistState: resolve type errors, add RootState type
clairep94 Oct 10, 2025
f972900
client/custom.d.ts: extend window and nodemodules for redux
clairep94 Oct 10, 2025
8b33ce6
client/modules/IDE/reducers/preferences: update to ts, no-verify
clairep94 Oct 10, 2025
8ea4322
client/modules/IDE/reducers/preferences: update to named export, no-v…
clairep94 Oct 10, 2025
79340a5
client/modules/IDE/reduces/preferences: add types for state and actions
clairep94 Oct 10, 2025
df2c772
common/index: export type to resolve type error
clairep94 Oct 10, 2025
a1d3ba4
client/tsconfig & server/tsconfig: remove custom paths, doesnt work
clairep94 Oct 10, 2025
80484ea
client/modules/IDE/actions/preferences: migrate to ts, no-verify
clairep94 Oct 10, 2025
18751e3
client/modules/IDE/actions/preferences: define types for dispatcher, …
clairep94 Oct 10, 2025
867ef82
--amend
clairep94 Oct 10, 2025
3b5856f
--amend
clairep94 Oct 10, 2025
879c357
--amend
clairep94 Oct 10, 2025
e27761a
--amend
clairep94 Oct 10, 2025
da9d8fd
--amend
clairep94 Oct 10, 2025
3feeaf0
--amend
clairep94 Oct 10, 2025
24f63d5
reorganise preferences action type defs
clairep94 Oct 10, 2025
0896481
migrate preferences action types to co-located .types file
clairep94 Oct 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router';

import configureStore from '../client/store';
import { setupStore } from '../client/store';
import '../client/i18n-test';
import '../client/styles/storybook.css'
import '../client/styles/storybook.css';
import { withThemeProvider, themeToolbarItem } from './decorator-theme';

const initialState = window.__INITIAL_STATE__;

const store = configureStore(initialState);
const store = setupStore(initialState);

export const decorators = [
(Story) => (
Expand Down
13 changes: 13 additions & 0 deletions client/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,18 @@ declare module '*.svg' {
const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>;
// eslint-disable-next-line import/no-default-export
export default ReactComponent;
}

// Extend window for Redux DevTools
interface Window {
__REDUX_DEVTOOLS_EXTENSION__?: () => any;
}

// Extend NodeModule for hot reloading
interface NodeModule {
hot?: {
accept(path?: string, callback?: () => void): void;
};
}
4 changes: 2 additions & 2 deletions client/index.integration.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import React from 'react';
import Routing from './routes';

import { reduxRender, act, waitFor, screen, within } from './test-utils';
import configureStore from './store';
import { setupStore } from './store';
import * as Actions from './modules/User/actions';
import { userResponse } from './testData/testServerResponses';

// setup for the app
const initialState = window.__INITIAL_STATE__;
const store = configureStore(initialState);
const store = setupStore(initialState);

// need to mock this file or it'll throw ERRCONNECTED
jest.mock('./i18n');
Expand Down
4 changes: 2 additions & 2 deletions client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Router } from 'react-router-dom';

import { useTranslation } from 'react-i18next';
import browserHistory from './browserHistory';
import configureStore from './store';
import { setupStore } from './store';
import Routing from './routes';
import ThemeProvider from './modules/App/components/ThemeProvider';
import Loader from './modules/App/components/loader';
Expand All @@ -19,7 +19,7 @@ require('./images/p5js-square-logo.png');

const initialState = window.__INITIAL_STATE__;

const store = configureStore(initialState);
const store = setupStore(initialState);

const DONATE_LOGO_IMAGE_URL = 'https://donorbox.org/images/white_logo.svg';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import i18next from 'i18next';
import { UpdatePreferencesRequestBody } from '../../../../common/types';
import { apiClient } from '../../../utils/apiClient';
import * as ActionTypes from '../../../constants';
import type {
UpdatePreferencesDispatch,
SetPreferencesTabValue,
SetFontSizeValue,
GetRootState,
SetLineNumbersValue,
SetAutocloseBracketsQuotesValue,
SetAutocompleteHinterValue,
SetAutosaveValue,
SetLinewrapValue,
SetLintWarningValue,
SetTextOutputValue,
SetAllAccessibleOutputValue,
SetAutorefreshValue,
SetGridOutputValue,
SetLanguageValue,
SetThemeValue
} from './preferences.types';

function updatePreferences(formParams, dispatch) {
function updatePreferences(
formParams: UpdatePreferencesRequestBody,
dispatch: UpdatePreferencesDispatch
) {
apiClient
.put('/preferences', formParams)
.then(() => {})
Expand All @@ -14,15 +36,15 @@ function updatePreferences(formParams, dispatch) {
});
}

export function setPreferencesTab(value) {
export function setPreferencesTab(value: SetPreferencesTabValue) {
return {
type: ActionTypes.SET_PREFERENCES_TAB,
value
};
}

export function setFontSize(value) {
return (dispatch, getState) => {
export function setFontSize(value: SetFontSizeValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
// eslint-disable-line
dispatch({
type: ActionTypes.SET_FONT_SIZE,
Expand All @@ -40,8 +62,8 @@ export function setFontSize(value) {
};
}

export function setLineNumbers(value) {
return (dispatch, getState) => {
export function setLineNumbers(value: SetLineNumbersValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_LINE_NUMBERS,
value
Expand All @@ -58,8 +80,10 @@ export function setLineNumbers(value) {
};
}

export function setAutocloseBracketsQuotes(value) {
return (dispatch, getState) => {
export function setAutocloseBracketsQuotes(
value: SetAutocloseBracketsQuotesValue
) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES,
value
Expand All @@ -76,8 +100,8 @@ export function setAutocloseBracketsQuotes(value) {
};
}

export function setAutocompleteHinter(value) {
return (dispatch, getState) => {
export function setAutocompleteHinter(value: SetAutocompleteHinterValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_AUTOCOMPLETE_HINTER,
value
Expand All @@ -94,8 +118,8 @@ export function setAutocompleteHinter(value) {
};
}

export function setAutosave(value) {
return (dispatch, getState) => {
export function setAutosave(value: SetAutosaveValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_AUTOSAVE,
value
Expand All @@ -112,8 +136,8 @@ export function setAutosave(value) {
};
}

export function setLinewrap(value) {
return (dispatch, getState) => {
export function setLinewrap(value: SetLinewrapValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_LINEWRAP,
value
Expand All @@ -130,8 +154,8 @@ export function setLinewrap(value) {
};
}

export function setLintWarning(value) {
return (dispatch, getState) => {
export function setLintWarning(value: SetLintWarningValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_LINT_WARNING,
value
Expand All @@ -148,8 +172,8 @@ export function setLintWarning(value) {
};
}

export function setTextOutput(value) {
return (dispatch, getState) => {
export function setTextOutput(value: SetTextOutputValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_TEXT_OUTPUT,
value
Expand All @@ -166,8 +190,8 @@ export function setTextOutput(value) {
};
}

export function setGridOutput(value) {
return (dispatch, getState) => {
export function setGridOutput(value: SetGridOutputValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_GRID_OUTPUT,
value
Expand All @@ -184,12 +208,8 @@ export function setGridOutput(value) {
};
}

export function setTheme(value) {
// return {
// type: ActionTypes.SET_THEME,
// value
// };
return (dispatch, getState) => {
export function setTheme(value: SetThemeValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_THEME,
value
Expand All @@ -206,12 +226,8 @@ export function setTheme(value) {
};
}

export function setAutorefresh(value) {
// return {
// type: ActionTypes.SET_AUTOREFRESH,
// value
// };
return (dispatch, getState) => {
export function setAutorefresh(value: SetAutorefreshValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch({
type: ActionTypes.SET_AUTOREFRESH,
value
Expand All @@ -228,15 +244,18 @@ export function setAutorefresh(value) {
};
}

export function setAllAccessibleOutput(value) {
return (dispatch) => {
export function setAllAccessibleOutput(value: SetAllAccessibleOutputValue) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
dispatch(setTextOutput(value));
dispatch(setGridOutput(value));
};
}

export function setLanguage(value, { persistPreference = true } = {}) {
return (dispatch, getState) => {
export function setLanguage(
value: SetLanguageValue,
{ persistPreference = true } = {}
) {
return (dispatch: UpdatePreferencesDispatch, getState: GetRootState) => {
i18next.changeLanguage(value);
dispatch({
type: ActionTypes.SET_LANGUAGE,
Expand Down
116 changes: 116 additions & 0 deletions client/modules/IDE/actions/preferences.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import * as ActionTypes from '../../../constants';
import type { PreferencesState } from '../reducers/preferences';
import type { RootState } from '../../../reducers';

// Value Definitions:
export type SetPreferencesTabValue = PreferencesState['tabIndex'];
export type SetFontSizeValue = PreferencesState['fontSize'];
export type SetLineNumbersValue = PreferencesState['lineNumbers'];
export type SetAutocloseBracketsQuotesValue = PreferencesState['autocloseBracketsQuotes'];
export type SetAutocompleteHinterValue = PreferencesState['autocompleteHinter'];
export type SetAutosaveValue = PreferencesState['autosave'];
export type SetLinewrapValue = PreferencesState['linewrap'];
export type SetLintWarningValue = PreferencesState['lintWarning'];
export type SetTextOutputValue = PreferencesState['textOutput'];
export type SetGridOutputValue = PreferencesState['gridOutput'];
export type SetThemeValue = PreferencesState['theme'];
export type SetAutorefreshValue = PreferencesState['autorefresh'];
export type SetLanguageValue = PreferencesState['language'];
export type SetAllAccessibleOutputValue =
| SetTextOutputValue
| SetGridOutputValue;

// Action Definitions:
export type OpenPreferencesAction = {
type: typeof ActionTypes.OPEN_PREFERENCES;
};
export type SetPreferencesAction = {
type: typeof ActionTypes.SET_PREFERENCES;
preferences: PreferencesState;
};
export type SetErrorAction = {
type: typeof ActionTypes.ERROR;
error: unknown;
};

export type SetPreferencesTabAction = {
type: typeof ActionTypes.SET_PREFERENCES_TAB;
value: SetPreferencesTabValue;
};
export type SetFontSizeAction = {
type: typeof ActionTypes.SET_FONT_SIZE;
value: SetFontSizeValue;
};
export type SetLineNumbersAction = {
type: typeof ActionTypes.SET_LINE_NUMBERS;
value: SetLineNumbersValue;
};
export type SetAutocloseBracketsQuotesAction = {
type: typeof ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES;
value: SetAutocloseBracketsQuotesValue;
};
export type SetAutocompleteHinterAction = {
type: typeof ActionTypes.SET_AUTOCOMPLETE_HINTER;
value: SetAutocompleteHinterValue;
};
export type SetAutosaveAction = {
type: typeof ActionTypes.SET_AUTOSAVE;
value: SetAutosaveValue;
};
export type SetLinewrapAction = {
type: typeof ActionTypes.SET_LINEWRAP;
value: SetLinewrapValue;
};
export type SetLintWarningAction = {
type: typeof ActionTypes.SET_LINT_WARNING;
value: SetLintWarningValue;
};
export type SetTextOutputAction = {
type: typeof ActionTypes.SET_TEXT_OUTPUT;
value: SetTextOutputValue;
};
export type SetGridOutputAction = {
type: typeof ActionTypes.SET_GRID_OUTPUT;
value: SetGridOutputValue;
};
export type SetThemeAction = {
type: typeof ActionTypes.SET_THEME;
value: SetThemeValue;
};
export type SetAutorefreshAction = {
type: typeof ActionTypes.SET_AUTOREFRESH;
value: SetAutorefreshValue;
};
export type SetLanguageAction = {
type: typeof ActionTypes.SET_LANGUAGE;
language: SetLanguageValue;
};

export type PreferencesAction =
| OpenPreferencesAction
| SetPreferencesAction
| SetErrorAction
| SetPreferencesTabAction
| SetFontSizeAction
| SetLineNumbersAction
| SetAutocloseBracketsQuotesAction
| SetAutocompleteHinterAction
| SetAutosaveAction
| SetLinewrapAction
| SetLintWarningAction
| SetTextOutputAction
| SetGridOutputAction
| SetThemeAction
| SetAutorefreshAction
| SetLanguageAction;

export type UpdatePreferencesDispatch = (
action: PreferencesAction | PreferencesThunk
) => void;

export type PreferencesThunk = (
dispatch: UpdatePreferencesDispatch,
getState: GetRootState
) => void;

export type GetRootState = () => RootState;
Loading
Loading