Skip to content

Commit

Permalink
♻️ refactor: refactor async api request
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Dec 7, 2024
1 parent e71974d commit 342073a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions next.config.mjs → next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import analyzer from '@next/bundle-analyzer';
import { withSentryConfig } from '@sentry/nextjs';
import withSerwistInit from '@serwist/next';
import type { NextConfig } from 'next';

const isProd = process.env.NODE_ENV === 'production';
const buildWithDocker = process.env.DOCKER === 'true';
Expand All @@ -10,8 +11,7 @@ const API_PROXY_ENDPOINT = process.env.API_PROXY_ENDPOINT || '';

const basePath = process.env.NEXT_PUBLIC_BASE_PATH;

/** @type {import('next').NextConfig} */
const nextConfig = {
const nextConfig: NextConfig = {
basePath,
compress: isProd,
experimental: {
Expand Down Expand Up @@ -192,7 +192,7 @@ const nextConfig = {
},
};

const noWrapper = (config) => config;
const noWrapper = (config: NextConfig) => config;

const withBundleAnalyzer = process.env.ANALYZE === 'true' ? analyzer() : noWrapper;

Expand All @@ -207,7 +207,7 @@ const withPWA = isProd
const hasSentry = !!process.env.NEXT_PUBLIC_SENTRY_DSN;
const withSentry =
isProd && hasSentry
? (c) =>
? (c: NextConfig) =>
withSentryConfig(
c,
{
Expand Down Expand Up @@ -248,4 +248,4 @@ const withSentry =
)
: noWrapper;

export default withBundleAnalyzer(withPWA(withSentry(nextConfig)));
export default withBundleAnalyzer(withPWA(withSentry(nextConfig) as NextConfig));
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"db:push-test": "NODE_ENV=test drizzle-kit push",
"db:studio": "drizzle-kit studio",
"db:z-pull": "drizzle-kit introspect",
"dev": "next dev -p 3010",
"dev": "next dev --turbo -p 3010",
"docs:i18n": "lobe-i18n md && npm run lint:mdx",
"docs:seo": "lobe-seo && npm run lint:mdx",
"i18n": "npm run workflow:i18n && lobe-i18n",
Expand Down Expand Up @@ -128,7 +128,7 @@
"@lobehub/tts": "^1.25.1",
"@lobehub/ui": "^1.152.0",
"@neondatabase/serverless": "^0.10.1",
"@next/third-parties": "^14.2.15",
"@next/third-parties": "^15.0.0",
"@react-spring/web": "^9.7.5",
"@sentry/nextjs": "^7.119.2",
"@serwist/next": "^9.0.9",
Expand Down Expand Up @@ -174,7 +174,7 @@
"mammoth": "^1.8.0",
"modern-screenshot": "^4.4.39",
"nanoid": "^5.0.7",
"next": "14.2.8",
"next": "^15.0.0",
"next-auth": "beta",
"next-mdx-remote": "^4.4.1",
"nextjs-toploader": "^3.7.15",
Expand All @@ -194,9 +194,9 @@
"pwa-install-handler": "^2.6.1",
"query-string": "^9.1.1",
"random-words": "^2.0.1",
"react": "^18.3.1",
"react": "^19.0.0",
"react-confetti": "^6.1.0",
"react-dom": "^18.3.1",
"react-dom": "^19.0.0",
"react-fast-marquee": "^1.6.5",
"react-hotkeys-hook": "^4.5.1",
"react-i18next": "14.0.2",
Expand Down Expand Up @@ -243,8 +243,8 @@
"@lobehub/i18n-cli": "^1.20.0",
"@lobehub/lint": "^1.24.4",
"@lobehub/seo-cli": "^1.4.2",
"@next/bundle-analyzer": "^14.2.15",
"@next/eslint-plugin-next": "^14.2.15",
"@next/bundle-analyzer": "^15.0.0",
"@next/eslint-plugin-next": "^15.0.0",
"@peculiar/webcrypto": "^1.5.0",
"@semantic-release/exec": "^6.0.3",
"@testing-library/jest-dom": "^6.6.2",
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/repos/[id]/evals/evaluation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Params {
id: string;
}

type Props = { params: Params };
type Props = { params: Params & Promise<Params> };

const Evaluation = ({ params }: Props) => {
const knowledgeBaseId = params.id;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/server/responsive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { headers } from 'next/headers';
import { type UnsafeUnwrappedHeaders, headers } from 'next/headers';
import { UAParser } from 'ua-parser-js';

/**
Expand All @@ -9,7 +9,7 @@ export const isMobileDevice = () => {
throw new Error('[Server method] you are importing a server-only module outside of server');
}

const { get } = headers();
const { get } = headers() as unknown as UnsafeUnwrappedHeaders;
const ua = get('user-agent');

// console.debug(ua);
Expand All @@ -26,7 +26,7 @@ export const gerServerDeviceInfo = () => {
throw new Error('[Server method] you are importing a server-only module outside of server');
}

const { get } = headers();
const { get } = headers() as unknown as UnsafeUnwrappedHeaders;
const ua = get('user-agent');

// console.debug(ua);
Expand Down

0 comments on commit 342073a

Please sign in to comment.