Skip to content

Commit

Permalink
Merge pull request #68 from web3privacy/dw/local-private-key
Browse files Browse the repository at this point in the history
feat: local private key
  • Loading branch information
DeBelg authored Dec 20, 2024
2 parents 3ba9d0f + 8ede25f commit ba986d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules
.env
dist
.DS_Store
private-key.pem
4 changes: 2 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export default defineNuxtConfig({
runtimeConfig: {
app: {
github: {
appId: 0,
appId: 995628,
privateKey: '',
installationId: 0,
installationId: 55212914,
owner: 'web3privacy',
baseBranch: 'main',
repo: 'test-repo',
Expand Down
7 changes: 6 additions & 1 deletion server/api/data.post.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { readFile } from 'fs/promises'
import { join } from 'path'

import { App } from 'octokit'
import yaml from 'yaml'
import type { Project } from '~/types'
Expand All @@ -6,6 +9,8 @@ export default defineEventHandler(async (event) => {
const body = await readBody<{ project: Project, image?: { type: string, data: string } }>(event)
const { appId, privateKey, installationId, baseBranch, owner, repo } = useRuntimeConfig().app.github

const localPrivateKey = await readFile(join(process.cwd(), 'private-key.pem'), 'utf8')

const id = (body.project.id && body.project.id.toLowerCase() === body.project.name.toLowerCase().replace(/\s+/g, '-'))
? body.project.id
: body.project.name.toLowerCase().replace(/\s+/g, '-')
Expand All @@ -17,7 +22,7 @@ export default defineEventHandler(async (event) => {

const app = new App({
appId,
privateKey,
privateKey: privateKey || localPrivateKey,
})
await app.octokit.rest.apps.getAuthenticated()
const octokit = await app.getInstallationOctokit(installationId)
Expand Down

0 comments on commit ba986d6

Please sign in to comment.