Skip to content

Commit

Permalink
prettier, lint, and client stuff (#113)
Browse files Browse the repository at this point in the history
* prettier, lint, and client stuff

* updated client deps and things
  • Loading branch information
evboggs302 authored Jan 7, 2025
1 parent 92304d0 commit 1de1782
Show file tree
Hide file tree
Showing 32 changed files with 1,545 additions and 1,750 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
**/generated/**/*
**/graphql.schema.json
**/dist/**/*
**/build/**/*
**/build/**/*
client/storybook-static/**/*
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
"@testing-library/user-event": "^14.4.3",
"@types/node": "^20.11.30",
"@types/react-dom": "^18.0.11",
"@types/react-router-dom": "^5.3.3",
"@types/react-router": "^5.1.20",
"@vitejs/plugin-react-swc": "^3.3.0",
"jsdom": "^24.0.0",
"msw": "^2.2.10",
"msw-storybook-addon": "2.0.0--canary.122.06f0c92.0",
"playwright": "^1.42.1",
"rollup-plugin-visualizer": "^5.12.0",
"storybook": "^8.0.4",
"storybook-addon-remix-react-router": "^3.0.1",
"storybook-addon-remix-react-router": "^4.0.1",
"typescript": "^5.0.2",
"vite": "^5.2.6",
"vite-plugin-auto-alias": "^1.0.4",
Expand Down
3 changes: 3 additions & 0 deletions client/public/mockServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable */
/* tslint:disable */

/**
* Mock Service Worker.
* @see https://github.com/mswjs/msw
Expand Down
2 changes: 1 addition & 1 deletion client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"@features/*": ["src/features/*"]
}
},
"exclude": ["node_modules"]
"exclude": ["node_modules", "storybook-static"]
}
45 changes: 31 additions & 14 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,25 @@
dependencies:
"@types/mdx" "^2.0.0"

"@mjackson/form-data-parser@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@mjackson/form-data-parser/-/form-data-parser-0.4.0.tgz#429dcd41a71c9f9e4d6873ef0dfa097110187a34"
integrity sha512-zDQ0sFfXqn2bJaZ/ypXfGUe0lUjCzXybBHYEoyWaO2w1dZ0nOM9nRER8tVVv3a8ZIgO/zF6p2I5ieWJAUOzt3w==
dependencies:
"@mjackson/multipart-parser" "^0.6.1"

"@mjackson/headers@^0.5.0":
version "0.5.1"
resolved "https://registry.yarnpkg.com/@mjackson/headers/-/headers-0.5.1.tgz#2d01fdd8909737b88438825b25ce21a14bfed182"
integrity sha512-sJpFgecPT/zJvwk3GRNVWNs8EkwaJoUNU2D0VMlp+gDJs6cuSTm1q/aCZi3ZtuV6CgDEQ4l2ZjUG3A9JrQlbNA==

"@mjackson/multipart-parser@^0.6.1":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@mjackson/multipart-parser/-/multipart-parser-0.6.3.tgz#17648f42c44147b45b53ef0c8d76d24fd444ae82"
integrity sha512-aQhySnM6OpAYMMG+m7LEygYye99hB1md/Cy1AFE0yD5hfNW+X4JDu7oNVY9Gc6IW8PZ45D1rjFLDIUdnkXmwrA==
dependencies:
"@mjackson/headers" "^0.5.0"

"@mswjs/interceptors@^0.37.0":
version "0.37.1"
resolved "https://registry.yarnpkg.com/@mswjs/interceptors/-/interceptors-0.37.1.tgz#fe30692c18318b0dba8aa36b390cb0a482fd81a7"
Expand Down Expand Up @@ -2184,6 +2203,11 @@
resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-8.4.4.tgz#3d209a235bf2b6f5543f1eebe78244f0104811b5"
integrity sha512-iq4yt3Fx35ZV5owNC//E6G+QPV19xHHVN2Ugi3p7KOSFK3chuXX9mxZ1rfir+t+U30a5EPOEnlsY3/1LXn7aTw==

"@storybook/theming@^8.0.0":
version "8.4.7"
resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-8.4.7.tgz#c308f6a883999bd35e87826738ab8a76515932b5"
integrity sha512-99rgLEjf7iwfSEmdqlHkSG3AyLcK0sfExcr0jnc6rLiAkBhzuIsvcHjjUwkR210SOCgXqBPW0ZA6uhnuyppHLw==

"@svgr/babel-plugin-add-jsx-attribute@8.0.0":
version "8.0.0"
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-8.0.0.tgz#4001f5d5dd87fa13303e36ee106e3ff3a7eb8b22"
Expand Down Expand Up @@ -2543,16 +2567,7 @@
dependencies:
"@types/react" "*"

"@types/react-router-dom@^5.3.3":
version "5.3.3"
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83"
integrity sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==
dependencies:
"@types/history" "^4.7.11"
"@types/react" "*"
"@types/react-router" "*"

"@types/react-router@*":
"@types/react-router@^5.1.20":
version "5.1.20"
resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.20.tgz#88eccaa122a82405ef3efbcaaa5dcdd9f021387c"
integrity sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q==
Expand Down Expand Up @@ -5882,11 +5897,13 @@ stop-iteration-iterator@^1.0.0:
dependencies:
internal-slot "^1.0.4"

storybook-addon-remix-react-router@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/storybook-addon-remix-react-router/-/storybook-addon-remix-react-router-3.0.1.tgz#e646c06592a5f00d5344ce96e4cd0b4df6300690"
integrity sha512-3tXvjDXFEZCfhGcoX6zdx6jRGH+QciDtSjmc0M8M4DlgEpwhflHwbS4J2NqaFmFTlsRXuh2+qjLfVzp4bkCixg==
storybook-addon-remix-react-router@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/storybook-addon-remix-react-router/-/storybook-addon-remix-react-router-4.0.1.tgz#8b77181ac64faf43fd28e7809a38577be3660808"
integrity sha512-Plhul9kInTKdOhoHumiJ0KRmuIVYhT5WBCnAlNt9MlsmDGEuuiimh8msyj5LPWnGD51/t38i14xI8gmmTyu1ow==
dependencies:
"@mjackson/form-data-parser" "^0.4.0"
"@storybook/theming" "^8.0.0"
compare-versions "^6.0.0"
react-inspector "6.0.2"

Expand Down
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export default [
"**/dist/**/*",
"**/build/**/*",
"**/generated/**/*",
"client/storybook-static/**/*",
"server/controllers/**/*",
"server/server_rest.ts",
],
},
{
Expand Down
13 changes: 13 additions & 0 deletions server/__tests__/utils/createBsonObjectId.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createBsonObjectId } from "../../utils/transforms/createBsonObjectId";
import { Types } from "mongoose";

describe("createBsonObjectId", () => {
test("no argument", () => {
const bsonObj = createBsonObjectId();
expectTypeOf(bsonObj).toEqualTypeOf<Types.ObjectId>();
});
test("string argument", () => {
const bsonObj = createBsonObjectId("677c390b938d16151238f0f1");
expectTypeOf(bsonObj).toEqualTypeOf<Types.ObjectId>();
});
});
6 changes: 4 additions & 2 deletions server/graphql.schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"__schema": {
"queryType": {
"name": "Query"
"name": "Query",
"kind": "OBJECT"
},
"mutationType": {
"name": "Mutation"
"name": "Mutation",
"kind": "OBJECT"
},
"subscriptionType": null,
"types": [
Expand Down
12 changes: 6 additions & 6 deletions server/models/clues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export const clueSchema = new Schema(
/**
* @returns ClueType with Date and ObjectId fields stringified
*/
stringifyDatesAndObjectIds: () => {
const obj = Object(this);
obj._id.toString();
obj.hunt_id.toString();
stringifyDatesAndObjectIds: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
obj.hunt_id = obj.hunt_id.toString();
return obj;
},
/**
* @returns ClueType with `__typename: "Clue"`
*/
transformWithTypename: () => {
const obj = Object(this);
transformWithTypename: function () {
const obj = Object(this.toObject());
return {
...obj.stringifyDatesAndObjectIds(),
__typename: "Clue" as const,
Expand Down
6 changes: 3 additions & 3 deletions server/models/event_logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const logSchema = new Schema(
{
versionKey: false,
methods: {
transformId: () => {
const obj = Object(this);
obj._id.toString();
transformId: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
return obj;
},
},
Expand Down
18 changes: 9 additions & 9 deletions server/models/hunts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ export const huntSchema = new Schema(
/**
* @returns HuntType with Date and ObjectId fields stringified
*/
stringifyDatesAndObjectIds: () => {
const obj = Object(this);
obj._id.toString();
obj.created_by.toString();
obj.start_date.toISOString();
obj.end_date.toISOString();
obj.created_date.toISOString();
stringifyDatesAndObjectIds: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
obj.created_by = obj.created_by.toString();
obj.start_date = obj.start_date.toISOString();
obj.end_date = obj.end_date.toISOString();
obj.created_date = obj.created_date.toISOString();
return obj;
},
/**
* @returns HuntType with `__typename: "Hunt"`
*/
transformWithTypename: () => {
const obj = Object(this);
transformWithTypename: function () {
const obj = Object(this.toObject());
return {
...obj.stringifyDatesAndObjectIds(),
__typename: "Hunt" as const,
Expand Down
16 changes: 8 additions & 8 deletions server/models/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ export const responseSchema = new Schema(
/**
* @returns ResponseType with Date and ObjectId fields stringified
*/
stringifyDatesAndObjectIds: () => {
const obj = Object(this);
obj._id.toString();
obj.team_id.toString();
obj.clue_id.toString();
obj.time_received.toISOString();
stringifyDatesAndObjectIds: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
obj.team_id = obj.team_id.toString();
obj.clue_id = obj.clue_id.toString();
obj.time_received = obj.time_received.toISOString();
return obj;
},
/**
* @returns ResponseType with `__typename: "ResponsePayload"`
*/
transformWithTypename: () => {
const obj = Object(this);
transformWithTypename: function () {
const obj = Object(this.toObject());
return {
...obj.stringifyDatesAndObjectIds(),
__typename: "ResponsePayload" as const,
Expand Down
12 changes: 6 additions & 6 deletions server/models/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ const teamSchema = new Schema(
/**
* @returns TeamType with Date and ObjectId fields stringified
*/
stringifyDatesAndObjectIds: () => {
const obj = Object(this);
obj._id.toString();
obj.hunt_id.toString();
stringifyDatesAndObjectIds: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
obj.hunt_id = obj.hunt_id.toString();
return obj;
},
/**
* @returns TeamType with `__typename: "Team"`
*/
transformWithTypename: () => {
const obj = Object(this);
transformWithTypename: function () {
const obj = Object(this.toObject());
return {
...obj.stringifyDatesAndObjectIds(),
__typename: "Team" as const,
Expand Down
6 changes: 3 additions & 3 deletions server/models/token_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const tokenStorageSchema = new Schema(
/**
* @returns Token with `__typename: "AuthPayload"`
*/
transformWithTypename: () => {
const obj = Object(this);
obj._id.toString();
transformWithTypename: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
return {
...obj,
__typename: "AuthPayload" as const,
Expand Down
16 changes: 3 additions & 13 deletions server/models/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,12 @@ export const userSchema = new Schema(
/**
* @returns UserType without the hash field
*/
transformWithoutHash: () => {
const obj = Object(this);
transformWithoutHash: function () {
const obj = Object(this.toObject());
obj._id = obj._id.toString();
delete obj.hash;
obj._id.toString();
return obj;
},
/**
* @returns UserType without the hash field and with `__typename: "UserPayload"`
*/
transformWithTypename: () => {
const obj = Object(this);
return {
...obj.stringifyWithoutHash(),
__typename: "UserPayload" as const,
};
},
},
statics: {
async getUserForLogin(user_name: string) {
Expand Down
16 changes: 11 additions & 5 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "yarn compile && npx nodemon ./dist/server_gql.js",
"dev": "nodemon server_gql.ts",
"start-server": "node --experimental-modules --es-module-specifier-resolution=node ./dist/server_gql.js",
"tsc-check": "tsc --noEmit",
"codegen": "graphql-codegen --config codegen.ts",
"compile": "rm -rf ./dist && npx tsc && cp -R node_modules ./dist/node_modules && cp -R graphql ./dist/graphql"
"compile": "rm -rf ./dist && npx tsc && cp -R node_modules ./dist/node_modules && cp -R graphql ./dist/graphql",
"test": "vitest"
},
"dependencies": {
"@apollo/server": "^4.11.2",
"@graphql-tools/graphql-file-loader": "^8.0.11",
"@graphql-tools/load": "^8.0.12",
"@graphql-tools/load-files": "^7.0.0",
"body-parser": "^1.20.3",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
Expand Down Expand Up @@ -40,16 +44,18 @@
"@types/express-jwt": "^7.4.2",
"@types/express-session": "^1.17.7",
"@types/graphql": "^14.5.0",
"@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9.0.1",
"@types/node": "^22.10.1",
"@types/supertest": "^6.0.2",
"@vitest/coverage-v8": "^2.1.8",
"bcryptjs": "^2.4.3",
"graphql-import-node": "^0.0.5",
"jest": "^29.7.0",
"nodemon": "^3.1.0",
"supertest": "^7.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
"typescript": "^5.4.2",
"vite": "^6.0.7",
"vite-node": "^2.1.8",
"vitest": "^2.1.8"
}
}
16 changes: 9 additions & 7 deletions server/resolvers/clueResolver.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ClueModel } from "@models/clues";
import { ResponseModel } from "@models/responses";
import { returnedItems } from "@/utils/transforms/returnedItems";
import { CluePayload, Resolvers } from "@generated/graphql";
import { createBsonObjectId } from "@/utils/transforms/createBsonObjectId";
import { ClueModel } from "../models/clues";
import { ResponseModel } from "../models/responses";
import { returnedItems } from "../utils/transforms/returnedItems";
import { CluePayload, Resolvers } from "../generated/graphql";
import { createBsonObjectId } from "../utils/transforms/createBsonObjectId";
import {
throwResolutionError,
throwServerError,
} from "@utils/apolloErrorHandlers";
} from "../utils/apolloErrorHandlers";

export const clueResolver: Resolvers = {
const clueResolver: Resolvers = {
Query: {
getCluesByHuntId: async (
_: unknown,
Expand Down Expand Up @@ -220,3 +220,5 @@ export const clueResolver: Resolvers = {
},
},
};

export default { ...clueResolver };
Loading

0 comments on commit 1de1782

Please sign in to comment.