Skip to content
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

GitHub webhook data and action handling #10

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .sequelizerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')

module.exports = {
"config": path.resolve('./db/config.json'),
"config": path.resolve('./config.json'),
"models-path": path.resolve('./lib/models'),
"migrations-path": path.resolve('./db/migrations')
}
9 changes: 4 additions & 5 deletions db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ if (process.env.DATABASE_URL) {
const Installations = InstallationsModel(sequelize, Sequelize);
const Subscriptions = SubscriptionsModel(sequelize, Sequelize);

Subscriptions.hasOne(Installations, { as: "github_installation_id" });

sequelize.sync({ force: true }).then(() => {
console.log(`Database & tables created!`);
});
sequelize.sync({alter: {alter: true, drop: false } })
.then(() => {
console.log(`Database & tables created!`);
});

export { Installations, Subscriptions };
47 changes: 47 additions & 0 deletions lib/jira/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,51 @@ export const token = async (clientKey, userAccountId) => {
} catch (error) {
return error;
}
};

export const connect = async (req, res, next) => {
const isHttps = req.secure || req.header("x-forwarded-proto") === "https";

return res.status(200).json({
apiMigrations: {
gdpr: true
},
name: "Headlines for Jira",
description:
"This plugin shows the recent updated tickets and branches of all projects a user is working on",
key: "headlines-jira",
baseUrl: `${isHttps ? "https" : "http"}://${req.get("host")}`,
lifecycle: {
installed: "/jira/events/install",
uninstalled: "/jira/events/uninstall",
enabled: "/jira/events/enable",
disabled: "/jira/events/disable"
},
vendor: {
name: "Productbox",
url: "https://www.productbox.dev"
},
authentication: {
type: "jwt"
},
scopes: ["READ", "ACT_AS_USER"],
apiVersion: 1,
modules: {
generalPages: [
{
key: "headlines",
location: "system.top.navigation.bar",
name: {
value: "Headlines"
},
url: "/headlines",
conditions: [
{
condition: "user_is_logged_in"
}
]
}
]
}
});
};
1 change: 1 addition & 0 deletions lib/models/installation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const InstallationsModel = (sequelize, type) => {
data: type.JSONB,
account_id: { type: type.STRING, primaryKey: true },
jira_token: type.JSONB,
github_installation_id: type.INTEGER,
organisation: type.STRING,
enabled: type.BOOLEAN
});
Expand Down
14 changes: 9 additions & 5 deletions lib/models/subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
export const SubscriptionsModel = (sequelize, type) => {
return sequelize.define("subscriptions", {
id: {
type: type.INTEGER,
primaryKey: true,
autoIncrement: true
},
jira_client_key: {
type: type.STRING
},
organisation: type.STRING,
enterprise: type.STRING,
github_installation_id: {
type: type.INTEGER,
primaryKey: true
},
github_installation_id: type.INTEGER,
github_access_token: type.STRING,
github_account: type.JSONB,
repositories: type.JSONB,
action: type.STRING
action: type.STRING,
repository_selection: type.STRING,
account_type: type.STRING
});
};
142 changes: 51 additions & 91 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.4",
"crypto": "^1.0.1",
"errorhandler": "^1.5.1",
"esm": "^3.2.22",
"express": "^4.16.4",
Expand Down
Loading