Skip to content

Commit 0546e90

Browse files
refactor: consolidate validateParams and remove unused config
- Import validateParams from shared utility in discussions.js, locations.js, and organization.js - Remove duplicate validateParams implementations (DRY principle) - Remove unused ghClientSecret export from config.js - Reduces code by 28 lines while maintaining 100% test coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b21381d commit 0546e90

File tree

4 files changed

+3
-31
lines changed

4 files changed

+3
-31
lines changed

src/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// OAuth App Credentials
22
export const ghAppId = process.env.GH_APP_ID
33
export const ghPrivateKey = process.env.GH_PRIVATE_KEY
4-
export const ghClientSecret = process.env.GH_CLIENT_SECRET
54
export const ghAppInstallationId = process.env.GH_APP_INSTALLATION_ID
65
export const ghPAT = process.env.GH_PAT
76

src/discussions.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { parseGql } from './lib/parseGql.js'
2-
3-
function validateParams(params) {
4-
const missing = []
5-
for (const [key, value] of Object.entries(params)) {
6-
if (!value) missing.push(key)
7-
}
8-
if (missing.length > 0) {
9-
throw new Error(`Missing required parameters: ${missing.join(', ')}`)
10-
}
11-
}
2+
import { validateParams } from './lib/validateParams.js'
123

134
function processDiscussionsPayload(edges) {
145
if (!edges || edges.length === 0) {

src/locations.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { getFile } from './files.js'
2-
3-
function validateParams(params) {
4-
const missing = []
5-
for (const [key, value] of Object.entries(params)) {
6-
if (!value) missing.push(key)
7-
}
8-
if (missing.length > 0) {
9-
throw new Error(`Missing required parameters: ${missing.join(', ')}`)
10-
}
11-
}
2+
import { validateParams } from './lib/validateParams.js'
123

134
function validateLocationSchema(location) {
145
// Basic schema validation for location objects

src/organization.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { parseGql } from './lib/parseGql.js'
2-
3-
function validateParams(params) {
4-
const missing = []
5-
for (const [key, value] of Object.entries(params)) {
6-
if (!value) missing.push(key)
7-
}
8-
if (missing.length > 0) {
9-
throw new Error(`Missing required parameters: ${missing.join(', ')}`)
10-
}
11-
}
2+
import { validateParams } from './lib/validateParams.js'
123

134
export async function getOrganization(graphql, org) {
145
validateParams({ graphql, org })

0 commit comments

Comments
 (0)