Skip to content

Commit

Permalink
Fix imports and types (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
daeisbae committed Jan 1, 2025
1 parent 5d9b500 commit 1cda7d6
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
["@babel/preset-react", {"runtime": "automatic"}],
"@babel/preset-typescript"
]
}
1 change: 1 addition & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
"paths": {
"@/*": ["./src/*"]
}
Expand Down
21 changes: 18 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['next-mdx-remote'],
}
transpilePackages: ["next-mdx-remote"],
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false,
dns: false,
net: false,
tls: false,
};
}
return config;
},
// Need to remove this later
typescript: {
ignoreBuildErrors: true,
},
};

export default nextConfig
export default nextConfig;
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"dependencies": {
"@google/generative-ai": "^0.21.0",
"@langchain/core": "^0.3.26",
"@radix-ui/react-navigation-menu": "^1.2.3",
"@radix-ui/react-separator": "^1.1.1",
"@radix-ui/react-slot": "^1.1.1",
"axios": "^1.7.9",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand All @@ -38,6 +41,7 @@
"@eslint/eslintrc": "^3",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/pg": "^8.11.10",
"babel-jest": "^29.7.0",
"eslint": "^9",
"eslint-config-next": "15.1.0",
Expand Down
2 changes: 0 additions & 2 deletions src/app/add/repositories/insert-repo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use server'

import InsertQueue from '@/service/insert-queue'

export async function insertRepository(owner: string, repo: string) {
Expand Down
81 changes: 46 additions & 35 deletions src/app/get/repositories/ListAvailableWiki.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,53 @@ import { Repository } from '@/db/models/repository'
import React from 'react'

export default async function ListAvailableWiki() {
const repositories = await new Repository().selectAll()
try {
const repositories = await new Repository().selectAll() || [];

return (
<div>
{repositories ? (
repositories.map((repo) => (
<div key={repo.url} className='p-1'>
<Link href={`/${repo.owner}/${repo.repo}`}>
<Card>
<CardHeader>
<CardTitle>
{repo.owner}/{repo.repo}
</CardTitle>
<CardDescription>
{repo.descriptions}
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex items-center gap-4 mb-4">
<div className="flex items-center">
<Star className="w-4 h-4 mr-1" />
<span>{repo.stars}</span>
return (
<div>
{repositories.length > 0 ? (
repositories.map((repo) => (
<div key={repo.url} className='p-1'>
<Link href={`/${repo.owner}/${repo.repo}`}>
<Card>
<CardHeader>
<CardTitle>
{repo.owner}/{repo.repo}
</CardTitle>
<CardDescription>
{repo.descriptions}
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex items-center gap-4 mb-4">
<div className="flex items-center">
<Star className="w-4 h-4 mr-1" />
<span>{repo.stars}</span>
</div>
<div className="flex items-center">
<GitFork className="w-4 h-4 mr-1" />
<span>{repo.forks}</span>
</div>
</div>
<div className="flex items-center">
<GitFork className="w-4 h-4 mr-1" />
<span>{repo.forks}</span>
</div>
</div>
</CardContent>
</Card>
</Link>
</CardContent>
</Card>
</Link>
</div>
))
) : (
<p>No repositories found</p>
)}
</div>
)
))
) : (
<div className="p-4 text-center">
<p>No repositories available at the moment</p>
</div>
)}
</div>
)
} catch (error) {
console.error('Error fetching repositories:', error);
return (
<div className="p-4 text-center">
<p>Unable to load repositories. Please try again later.</p>
</div>
);
}
}
17 changes: 17 additions & 0 deletions src/app/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Skeleton } from '@/components/ui/skeleton'
import * as React from 'react'

export default function Loading() {
return (
<div className="space-y-4">
<Skeleton className="h-8 w-[250px]" />
<Skeleton className="h-4 w-[200px]" />
<Skeleton className="h-4 w-[150px]" />
<div className="space-y-2">
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-2/3" />
</div>
</div>
)
}
2 changes: 2 additions & 0 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as React from 'react'

export default function NotFound() {
return (
<div>
Expand Down
8 changes: 6 additions & 2 deletions src/db/models/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export interface RepositoryData {
topics: string[]
}

interface TopicResultOutput {
rows?: { topic_name: string }[]
}

export class Repository {
async select(owner: string, repo: string): Promise<RepositoryData | null> {
const queryRepo =
Expand All @@ -24,11 +28,11 @@ export class Repository {
if (!repoResult) {
return null
}
const topicsResult = await dbConn.query(queryTopics, [repoResult.url])
const topicsResult: TopicResultOutput = await dbConn.query(queryTopics, [repoResult.url])

return {
...repoResult,
topics: topicsResult.rows.map((row) => row.topic_name),
topics: topicsResult.rows!.map((row) => row.topic_name),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/db/utils/connector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pg, { QueryResult } from 'pg'
import pg, { QueryResult, QueryResultRow } from 'pg'
import { DBConfig } from '@/db/config/config'
import { promises as fs } from 'fs'

Expand Down Expand Up @@ -53,7 +53,7 @@ class DBConnector {
* @returns Results from database query
* @throws Database query errors
*/
async query<T = any>(
async query<T extends QueryResultRow = any>(
text: string,
params?: any[]
): Promise<QueryResult<T>> {
Expand Down

0 comments on commit 1cda7d6

Please sign in to comment.