diff --git a/.env.local.sample b/.env.local.sample index 5798cf9..bb1a700 100644 Binary files a/.env.local.sample and b/.env.local.sample differ diff --git a/.gitignore b/.gitignore index 595639b..1bb549d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,8 +24,8 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -# env files -.env* +# local env files +.env.local # vercel .vercel diff --git a/package-lock.json b/package-lock.json index 4821699..db90e52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "citizen-directory", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "citizen-directory", - "version": "0.2.0", + "version": "0.3.0", "dependencies": { "@heroicons/react": "^2.0.17", "@types/node": "18.15.11", @@ -17,7 +17,6 @@ "eslint": "8.38.0", "eslint-config-next": "13.3.0", "next": "13.3.0", - "next-connect": "^1.0.0", "papaparse": "^5.4.1", "passport": "^0.6.0", "passport-github2": "^0.1.12", @@ -899,11 +898,6 @@ "@tanstack/react-query": "^4.35.3" } }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" - }, "node_modules/@types/connect": { "version": "3.4.36", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.36.tgz", @@ -4597,18 +4591,6 @@ } } }, - "node_modules/next-connect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-connect/-/next-connect-1.0.0.tgz", - "integrity": "sha512-FeLURm9MdvzY1SDUGE74tk66mukSqL6MAzxajW7Gqh6DZKBZLrXmXnGWtHJZXkfvoi+V/DUe9Hhtfkl4+nTlYA==", - "dependencies": { - "@tsconfig/node16": "^1.0.3", - "regexparam": "^2.0.1" - }, - "engines": { - "node": ">=16" - } - }, "node_modules/next/node_modules/postcss": { "version": "8.4.14", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", @@ -5411,14 +5393,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexparam": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.1.tgz", - "integrity": "sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw==", - "engines": { - "node": ">=8" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -7445,11 +7419,6 @@ "@tanstack/query-persist-client-core": "4.35.3" } }, - "@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" - }, "@types/connect": { "version": "3.4.36", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.36.tgz", @@ -10233,15 +10202,6 @@ } } }, - "next-connect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-connect/-/next-connect-1.0.0.tgz", - "integrity": "sha512-FeLURm9MdvzY1SDUGE74tk66mukSqL6MAzxajW7Gqh6DZKBZLrXmXnGWtHJZXkfvoi+V/DUe9Hhtfkl4+nTlYA==", - "requires": { - "@tsconfig/node16": "^1.0.3", - "regexparam": "^2.0.1" - } - }, "node-addon-api": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", @@ -10768,11 +10728,6 @@ "functions-have-names": "^1.2.2" } }, - "regexparam": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.1.tgz", - "integrity": "sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw==" - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", diff --git a/package.json b/package.json index 48abec7..2f364f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "citizen-directory", - "version": "0.2.0", + "version": "0.3.0", "private": true, "scripts": { "dev": "next dev", @@ -18,7 +18,6 @@ "eslint": "8.38.0", "eslint-config-next": "13.3.0", "next": "13.3.0", - "next-connect": "^1.0.0", "papaparse": "^5.4.1", "passport": "^0.6.0", "passport-github2": "^0.1.12", diff --git a/src/components/ProfileDetailsGitHub.tsx b/src/components/ProfileDetailsGitHub.tsx index 3301d99..4ab3c80 100644 --- a/src/components/ProfileDetailsGitHub.tsx +++ b/src/components/ProfileDetailsGitHub.tsx @@ -1,7 +1,7 @@ import { useContractRead } from "wagmi" import LoadingIndicator from "./LoadingIndicator" import GitHub from "../../abis/GitHub.json" -import { useIsMounted } from "../../hooks/useIsMounted" +import { useIsMounted } from "@/hooks/useIsMounted" import Link from "next/link" export default function ProfileDetailsGitHub({ citizen }: any) { diff --git a/src/components/VeNationLockDetails.tsx b/src/components/VeNationLockDetails.tsx index 3b2e965..5fad8b9 100644 --- a/src/components/VeNationLockDetails.tsx +++ b/src/components/VeNationLockDetails.tsx @@ -1,7 +1,7 @@ import { useContractRead } from "wagmi" import LoadingIndicator from "./LoadingIndicator" import VotingEscrow from "../../abis/VotingEscrow.json" -import { useIsMounted } from "../../hooks/useIsMounted" +import { useIsMounted } from "@/hooks/useIsMounted" import { formatEther } from 'viem' export default function VeNationLockDetails({ address }: any) { diff --git a/hooks/useIsMounted.tsx b/src/hooks/useIsMounted.tsx similarity index 100% rename from hooks/useIsMounted.tsx rename to src/hooks/useIsMounted.tsx diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 495fc48..f143763 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -18,6 +18,7 @@ const config = createConfig({ const poppins = Poppins({ subsets: ['latin'], weight: '400' }) export default function App({ Component, pageProps }: AppProps) { + console.info('App') return (
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 54e8bf3..facb362 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,6 +1,7 @@ import { Html, Head, Main, NextScript } from 'next/document' export default function Document() { + console.info('Document') return ( diff --git a/src/pages/api/[passportId]/auth/github.ts b/src/pages/api/[passportId]/auth/github.ts index 1d9dbfb..5ad5393 100644 --- a/src/pages/api/[passportId]/auth/github.ts +++ b/src/pages/api/[passportId]/auth/github.ts @@ -1,4 +1,4 @@ -import nc, { createEdgeRouter } from "next-connect" +// import nc, { createEdgeRouter } from "next-connect" import { NextFetchEvent, NextRequest } from "next/server" const passport = require('passport') const GitHubStrategy = require('passport-github2').Strategy @@ -9,12 +9,12 @@ console.info('callbackBaseUrl:', callbackBaseUrl) const callbackUrl = `${callbackBaseUrl}/api/233/auth/github-callback` // TODO: get [passportId] console.info('callbackUrl:', callbackUrl) -const router = createEdgeRouter() -router.use(async (request, event, next) => { - // logging request example - console.log(`${request.method} ${request.url}`); - return next(); -}); +// const router = createEdgeRouter() +// router.use(async (request, event, next) => { +// // logging request example +// console.log(`${request.method} ${request.url}`); +// return next(); +// }); // Configure strategy passport.use(new GitHubStrategy( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index ce7603a..184fdf3 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -12,6 +12,7 @@ import Papa from 'papaparse' import Menu from '@/components/Menu' import Link from 'next/link' import LoadingIndicator from '@/components/LoadingIndicator' +import { config } from '@/utils/Config' export default function Home({ total_citizens_count, total_expired_passports, active_citizens_count, citizens }: any) { console.log('Home') @@ -128,12 +129,12 @@ export async function getStaticProps() { skipEmptyLines: true, dynamicTyping: true, complete: (result: any) => { - console.info('result:', result) + // console.info('result:', result) result.data.forEach((row: any, i: number) => { - console.info(`row ${i}`, row) + // console.info(`row ${i}`, row) active_citizens_count[i] = Number(row.active_citizens_count) }) - console.info('active_citizen_count:', active_citizens_count) + // console.info('active_citizen_count:', active_citizens_count) } }) @@ -150,23 +151,23 @@ export async function getStaticProps() { skipEmptyLines: true, dynamicTyping: true, complete: (result: any) => { - console.info('result:', result) + // console.info('result:', result) result.data.forEach((row: any, i: number) => { - console.info(`row ${i}`, row) + // console.info(`row ${i}`, row) total_citizens_count[i] = Number(row.total_citizens) total_expired_passports[i] = Number(row.total_expired_passports) }) - console.info('total_citizens_count:', total_citizens_count) - console.info('total_expired_passports:', total_expired_passports) + // console.info('total_citizens_count:', total_citizens_count) + // console.info('total_expired_passports:', total_expired_passports) } }) // Fetch citizen data from datasets repo let citizens = null const citizenDataFileUrl: string = 'https://raw.githubusercontent.com/nation3/nationcred-datasets/main/data-sources/citizens/output/citizens.json' - console.info('Fetching citizen data:', citizenDataFileUrl) + // console.info('Fetching citizen data:', citizenDataFileUrl) const response = await fetch(citizenDataFileUrl) - console.log('response.status:', response.status) + // console.log('response.status:', response.status) citizens = await response.json() return { diff --git a/src/utils/Config.ts b/src/utils/Config.ts new file mode 100644 index 0000000..f6f35e1 --- /dev/null +++ b/src/utils/Config.ts @@ -0,0 +1,16 @@ +const getEnvironmentVariable = (environmentVariable : string): string => { + console.log('getEnvironmentVariable', environmentVariable) + const variable = process.env[environmentVariable] + if (!variable) { + throw new Error(`Missing variable: "${environmentVariable}"`) + } else { + return variable + } +} + +export const config = { + gitHubCallbackBaseUrl: getEnvironmentVariable('GITHUB_CALLBACK_BASE_URL'), + gitHubClientId: getEnvironmentVariable('GITHUB_CLIENT_ID'), + gitHubClientSecret: getEnvironmentVariable('GITHUB_CLIENT_ID') +} +console.log('config:', config)