Skip to content

Commit

Permalink
chore: script에 dotenv 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kangju2000 committed Nov 25, 2024
1 parent 11396a7 commit 4deb9b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions scripts/generateSnapshot.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import dotenv from 'dotenv'
import fs from 'fs/promises'
import path from 'path'
import { dirname } from 'path'
import { fileURLToPath } from 'url'

import { getSnapshots } from '@/apis/snapshots'

// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = dirname(fileURLToPath(import.meta.url))
dotenv.config({ path: path.resolve(__dirname, '../.env') })

const GENERATED_DIR = path.join(process.cwd(), 'src/__generated__')
const SNAPSHOTS_DIR = path.join(GENERATED_DIR, 'snapshots')

Expand Down
2 changes: 1 addition & 1 deletion src/__generated__/snapshots/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/apis/configs/api.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import dotenv from 'dotenv'

dotenv.config()

const API_BASE_URL = process.env.VITE_API_URL
const getApiUrl = () => {
if (typeof process !== 'undefined' && process.env) {
return process.env.VITE_API_URL
}
return import.meta.env.VITE_API_URL
}

type RequestOptions = RequestInit & {
params?: Record<string, string | number | undefined>
}

export async function api<T>(endpoint: string, options: RequestOptions = {}): Promise<T> {
const API_BASE_URL = getApiUrl()

if (!API_BASE_URL) {
throw new Error('API_BASE_URL is not defined')
}
Expand Down
1 change: 0 additions & 1 deletion src/services/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export function parseAssignmentSubmitted(
const assignmentTitle = getText($el.find(title))
const endAt = getText($el.find(period)) + ':00'
const hasSubmitted = SUBMISSION_STATUS_REGEX.test(getText($el.find(status)))
console.log({ id, assignmentTitle, endAt, hasSubmitted })

return { id, title: assignmentTitle, endAt, hasSubmitted }
})
Expand Down

0 comments on commit 4deb9b3

Please sign in to comment.