Skip to content

Commit

Permalink
chore: integrated knip and little code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumm committed Jan 27, 2024
1 parent b6d2aa1 commit af88dad
Show file tree
Hide file tree
Showing 9 changed files with 1,435 additions and 97 deletions.
1,412 changes: 1,404 additions & 8 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
"format:check": "prettier --check \"{src,test}/**\"",
"type-check": "tsc --noEmit",
"prepare": "husky install",
"pre": "npm run lint && npm run type-check && npm run format:check && npm run build",
"pre": "npm run lint && npm run type-check && npm run format:check && knip && npm run build",
"release": "release-it"
},
"dependencies": {
"@mantine/core": "^7.4.2",
"@mantine/form": "^7.4.2",
"@mantine/hooks": "^7.4.2",
"@mantine/modals": "^7.4.2",
"@mantine/next": "^6.0.21",
"@mantine/notifications": "^7.4.2",
"@planetscale/database": "^1.14.0",
Expand All @@ -47,11 +46,9 @@
"drizzle-orm": "^0.29.3",
"framer-motion": "^11.0.3",
"geist": "^1.2.1",
"luxon": "^3.4.4",
"nanoid": "^5.0.4",
"next": "^13.4.13",
"next-axiom": "^1.1.1",
"node-fetch": "^3.3.2",
"nodemailer": "^6.9.8",
"normalize.css": "^8.0.1",
"react": "^18.2.0",
Expand All @@ -69,7 +66,6 @@
"@release-it/conventional-changelog": "^8.0.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/eslint": "^8.56.2",
"@types/luxon": "^3.4.1",
"@types/node": "^20.11.6",
"@types/nodemailer": "^6.4.14",
"@types/react": "^18.2.48",
Expand All @@ -82,6 +78,7 @@
"eslint": "^8.56.0",
"eslint-config-next": "^14.1.0",
"husky": "^8.0.3",
"knip": "^4.2.1",
"postcss": "^8.4.33",
"prettier": "^3.2.4",
"prettier-plugin-tailwindcss": "^0.5.11",
Expand All @@ -92,6 +89,9 @@
},
"ct3aMetadata": {
"initVersion": "7.18.1-beta.e1ce1f5"
},
"knip": {

},
"release-it": {
"git": {
Expand Down
62 changes: 0 additions & 62 deletions src/components/analytics/bar-chart.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/layout/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const links = [
},
];

export function Footer() {
function Footer() {
const latestTag = useConfigStore((state) => state.latestTag);

return (
Expand Down
9 changes: 9 additions & 0 deletions src/constants/error.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export interface ServerLog extends GlobalLoggingType {
city?: string | null;
country?: string | null;
region?: string | null;
startTime?: number;
endTime?: number;
duration?: number;
httpCode?: number;
error?: {
name?: string;
message?: string;
stack?: string;
};
}

export interface ClientLog extends GlobalLoggingType {
Expand Down
2 changes: 1 addition & 1 deletion src/server/room-state/room-state.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function getAverageFromUsers(users: User[]): number {
);
}

export interface IStackedEstimation {
interface IStackedEstimation {
number: number;
amount: number;
}
Expand Down
21 changes: 13 additions & 8 deletions src/utils/api-logger.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import { type AxiomRequest, Logger } from 'next-axiom';
import { type RequestReport } from 'next-axiom/src/logger';

import {
BadRequestError,
type BaseError,
InternalServerError,
NotFoundError,
NotImplementedError,
type ServerLog,
TooManyRequestsError,
removeNulls,
} from 'fpp/constants/error.constant';

Expand Down Expand Up @@ -105,7 +110,7 @@ export function withLogger(handler: NextHandler) {

const e = error as BaseError;

let errorLogPayload = {
let errorLogPayload: ServerLog = {
...report,
...reportExtension,
...e?.meta,
Expand All @@ -121,7 +126,7 @@ export function withLogger(handler: NextHandler) {
stack: e?.stack,
message: e?.message,
},
} as ServerLog;
};
errorLogPayload = removeNulls(errorLogPayload);

Sentry.captureException(error, {
Expand All @@ -136,14 +141,14 @@ export function withLogger(handler: NextHandler) {
});

switch (e.constructor.name) {
case 'BadRequestError':
case 'NotFoundError':
case 'NotImplementedError':
case 'TooManyRequestsError':
case BadRequestError.name:
case NotFoundError.name:
case NotImplementedError.name:
case TooManyRequestsError.name:
logger.warn('Warn in Next route handler', errorLogPayload);
break;
case 'InternalServerError':
case 'Error':
case InternalServerError.name:
case Error.name:
default:
logger.error('Error in Next route handler', errorLogPayload);
break;
Expand Down
5 changes: 2 additions & 3 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
import { httpBatchLink, loggerLink } from '@trpc/client';
import { createTRPCNext } from '@trpc/next';
import { type inferRouterInputs, type inferRouterOutputs } from '@trpc/server';

import superjson from 'superjson';

Expand Down Expand Up @@ -66,11 +65,11 @@ export const api = createTRPCNext<AppRouter>({
*
* @example type HelloInput = RouterInputs['example']['hello']
*/
export type RouterInputs = inferRouterInputs<AppRouter>;
// export type RouterInputs = inferRouterInputs<AppRouter>;

/**
* Inference helper for outputs.
*
* @example type HelloOutput = RouterOutputs['example']['hello']
*/
export type RouterOutputs = inferRouterOutputs<AppRouter>;
// export type RouterOutputs = inferRouterOutputs<AppRouter>;
9 changes: 0 additions & 9 deletions src/utils/number.utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
export function round(value: number | string) {
return Math.ceil(Number(value) * 100) / 100;
}

export function isValidInteger(str: string) {
if (!str.trim()) return false;
return Number.isInteger(Number(str));
}

export function isValidMediumint(str: string) {
if (!str.trim()) return false;
return Number.isInteger(Number(str)) && Number(str) < 8388607;
Expand Down

0 comments on commit af88dad

Please sign in to comment.