Skip to content

Commit

Permalink
adds debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
scefali committed Jun 9, 2024
1 parent e9c2092 commit 2c52d84
Show file tree
Hide file tree
Showing 3 changed files with 721 additions and 44 deletions.
53 changes: 41 additions & 12 deletions app/routes/github.oauth.callback.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type DataFunctionArgs, redirect } from '@remix-run/node'
import sqlite3 from 'sqlite3'
import { GITHUB_LOGIN_URL } from '#app/utils/constants'
import { prisma } from '#app/utils/db.server.ts'
import { getMyUser } from '#app/utils/github.ts'
Expand All @@ -14,20 +15,48 @@ export async function loader({ request }: DataFunctionArgs) {

// TODO: better typing
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const tokenResponse: any = await fetch(`https://github.com/login/oauth/access_token`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
const tokenResponse: any = await fetch(
`https://github.com/login/oauth/access_token`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
client_id: process.env.GITHUB_CLIENT_ID,
client_secret: process.env.GITHUB_CLIENT_SECRET,
code: code,
}),
},
body: JSON.stringify({
client_id: process.env.GITHUB_CLIENT_ID,
client_secret: process.env.GITHUB_CLIENT_SECRET,
code: code,
}),
}).then(res => res.json());
const { access_token: token, refresh_token: refreshToken, expires_in: expiresIn } = tokenResponse
).then(res => res.json())
const {
access_token: token,
refresh_token: refreshToken,
expires_in: expiresIn,
} = tokenResponse
const data: any = await getMyUser({ githubCookie: token })

console.log('Database URL:', process.env.DATABASE_URL)

const dbPath = process.env.DATABASE_URL.split(':')[1].split('?')[0]
console.log('Database Path:', dbPath)

// Use sqlite3 to list all tables in the database
const db = new sqlite3.Database(dbPath)
db.serialize(() => {
db.all(
"SELECT name FROM sqlite_master WHERE type='table';",
(err, tables) => {
if (err) {
console.error('Error fetching tables:', err)
} else {
console.log('Tables:', tables)
}
},
)
})

const gitHubUserId = data.id

const baseGitHubParams = {
Expand Down
Loading

0 comments on commit 2c52d84

Please sign in to comment.