Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Suggested code simplifications #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: workshop-checkpoint-5
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions 18 lib/server.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// External dependencies
const fs = require("fs")
const path = require("path")
const yaml = require("js-yaml")
const express = require("express")
const { createWebhooksApi } = require("@octokit/webhooks")
const { createAppAuth } = require("@octokit/auth-app")
const { graphql } = require("@octokit/graphql")

// Local dependencies
const smeeClient = require(path.join(__dirname, "smee.js"))
const emojify = require(path.join(__dirname, "emojify.js"))
const hasCommand = require(path.join(__dirname, "command.js"))
const updateBodyMutationFor = require(path.join(__dirname, "mutations.js"))
const smeeClient = require("./smee")
const emojify = require("./emojify")
const hasCommand = require("./command")
const updateBodyMutationFor = require("./mutations")

// Setup
const port = 64897
const app = express()
const privateKey = fs.readFileSync("gh-app.pem", "utf8")
const config = JSON.parse(fs.readFileSync("config.json", "utf8"))
const config = require('../config.json')
var emojifierConfig = yaml.safeLoad(fs.readFileSync("emojifier-default.yml", "utf8"))

const smee = smeeClient(config.webproxy_url, port)
Expand All @@ -30,15 +29,16 @@ app.use(webhooks.middleware)

webhooks.on(["issue_comment.created", "issues.opened", "pull_request.opened"], async (event) => {
const { payload } = event
const auth = await createAppAuth({
const auth = createAppAuth({
id: config.github_app_id,
privateKey: privateKey,
installationId: payload.installation.id
})

const { token } = await auth({ type: "installation" });
const graphqlWithAuth = graphql.defaults({
request: {
hook: auth.hook
headers: {
authorization: `token ${token}`
}
})

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.