Skip to content

Commit

Permalink
fix: issue routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin authored and Robin committed Dec 15, 2023
1 parent a1ab8a6 commit c9e66b0
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 177 deletions.
74 changes: 38 additions & 36 deletions src/controllers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,47 @@
*/

// Sub APIs
const apiTicketsV1 = require('./api/v1/tickets')
const apiTagsV1 = require('./api/v1/tags')
const apiNoticesV1 = require('./api/v1/notices')
const apiUsersV1 = require('./api/v1/users')
const apiMessagesV1 = require('./api/v1/messages')
const apiGroupsV1 = require('./api/v1/groups')
const apiReportsV1 = require('./api/v1/reports')
const apiSettingsV1 = require('./api/v1/settings')
const apiPluginsV1 = require('./api/v1/plugins')
const apiTicketsV1 = require('./api/v1/tickets');
const apiTagsV1 = require('./api/v1/tags');
const apiNoticesV1 = require('./api/v1/notices');
const apiUsersV1 = require('./api/v1/users');
const apiMessagesV1 = require('./api/v1/messages');
const apiGroupsV1 = require('./api/v1/groups');
const apiIssuesV1 = require('./api/v1/issues');
const apiReportsV1 = require('./api/v1/reports');
const apiSettingsV1 = require('./api/v1/settings');
const apiPluginsV1 = require('./api/v1/plugins');

const apiController = {}
const apiController = {};

apiController.index = function (req, res) {
return res.json({ supported: ['v1', 'v2'] })
}
return res.json({ supported: ['v1', 'v2'] });
};

apiController.v1 = {}
apiController.v1.common = require('./api/v1/common')
apiController.v1.tickets = apiTicketsV1
apiController.v1.tags = apiTagsV1
apiController.v1.notices = apiNoticesV1
apiController.v1.users = apiUsersV1
apiController.v1.messages = apiMessagesV1
apiController.v1.groups = apiGroupsV1
apiController.v1.reports = apiReportsV1
apiController.v1.settings = apiSettingsV1
apiController.v1.plugins = apiPluginsV1
apiController.v1.roles = require('./api/v1/roles')
apiController.v1 = {};
apiController.v1.common = require('./api/v1/common');
apiController.v1.tickets = apiTicketsV1;
apiController.v1.tags = apiTagsV1;
apiController.v1.notices = apiNoticesV1;
apiController.v1.users = apiUsersV1;
apiController.v1.messages = apiMessagesV1;
apiController.v1.groups = apiGroupsV1;
apiController.v1.issues = apiIssuesV1;
apiController.v1.reports = apiReportsV1;
apiController.v1.settings = apiSettingsV1;
apiController.v1.plugins = apiPluginsV1;
apiController.v1.roles = require('./api/v1/roles');

apiController.v2 = {}
apiController.v2.common = require('./api/v2/common')
apiController.v2.accounts = require('./api/v2/accounts')
apiController.v2.tickets = require('./api/v2/tickets')
apiController.v2.groups = require('./api/v2/groups')
apiController.v2.teams = require('./api/v2/teams')
apiController.v2.departments = require('./api/v2/departments')
apiController.v2.notices = require('./api/v2/notices')
apiController.v2.elasticsearch = require('./api/v2/elasticsearch')
apiController.v2.mailer = require('./api/v2/mailer')
apiController.v2.messages = require('./api/v2/messages')
apiController.v2 = {};
apiController.v2.common = require('./api/v2/common');
apiController.v2.accounts = require('./api/v2/accounts');
apiController.v2.tickets = require('./api/v2/tickets');
apiController.v2.groups = require('./api/v2/groups');
apiController.v2.teams = require('./api/v2/teams');
apiController.v2.departments = require('./api/v2/departments');
apiController.v2.notices = require('./api/v2/notices');
apiController.v2.elasticsearch = require('./api/v2/elasticsearch');
apiController.v2.mailer = require('./api/v2/mailer');
apiController.v2.messages = require('./api/v2/messages');

module.exports = apiController
module.exports = apiController;
23 changes: 23 additions & 0 deletions src/controllers/api/v1/issues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var winston = require('../../../logger')

const apiIssues = {}

apiIssues.create = function (req, res) {
const IssueSchema = require('../../../models/issue')
const issueSchema = req.body
winston.warn('Public account creation was attempted while disabled!',issueSchema)

// Issue Creation
const issue = new IssueSchema({
...issueSchema
})

issue.save(function (err, issue) {
if (err) return res.status(400).json({ success: false, error: 'Error: ' + err.message })

res.json({ success: true, error: null, issue: issue })
})

}

module.exports = apiIssues
Loading

0 comments on commit c9e66b0

Please sign in to comment.