<commit_before>RocketChat.API.v1.addRoute('integrations.create', { authRequired: true }, {
	post: function() {
		try {
			check(this.bodyParams, Match.ObjectIncluding({
				type: String,
				name: String,
				enabled: Boolean,
				username: String,
				urls: [String],
				channel: Match.Maybe(String),
				triggerWords: Match.Maybe([String]),
				alias: Match.Maybe(String),
				avatar: Match.Maybe(String),
				emoji: Match.Maybe(String),
				token: Match.Maybe(String),
				scriptEnabled: Boolean,
				script: Match.Maybe(String)
			}));

			let integration;

			switch (this.bodyParams.type) {
				case 'webhook-outgoing':
					Meteor.runAsUser(this.userId, () => {
						integration = Meteor.call('addOutgoingIntegration', this.bodyParams);
					});
					break;
				default:
					return RocketChat.API.v1.failure('Invalid integration type.');
			}

			return RocketChat.API.v1.success({ integration });
		} catch (e) {
			return RocketChat.API.v1.failure(e.name + ': ' + e.message);
		}
	}
});

RocketChat.API.v1.addRoute('integrations.list', { authRequired: true }, {
	get: function() {
		if (!RocketChat.authz.hasPermission(this.userId, 'manage-integrations')) {
			return RocketChat.API.v1.unauthorized();
		}

		const { offset, count } = RocketChat.API.v1.getPaginationItems(this);
		const integrations = RocketChat.models.Integrations.find({}, {
			sort: { ts: -1 },
			skip: offset,
			limit: count,
		}).fetch();

		return RocketChat.API.v1.success({
			integrations: integrations,
			offset,
			items: integrations.length,
			total: RocketChat.models.Integrations.find().count()
		});
	}
});<commit_msg>Fix the trailing comma on the integrations.js<commit_after>RocketChat.API.v1.addRoute('integrations.create', { authRequired: true }, {
	post: function() {
		try {
			check(this.bodyParams, Match.ObjectIncluding({
				type: String,
				name: String,
				enabled: Boolean,
				username: String,
				urls: [String],
				channel: Match.Maybe(String),
				triggerWords: Match.Maybe([String]),
				alias: Match.Maybe(String),
				avatar: Match.Maybe(String),
				emoji: Match.Maybe(String),
				token: Match.Maybe(String),
				scriptEnabled: Boolean,
				script: Match.Maybe(String)
			}));

			let integration;

			switch (this.bodyParams.type) {
				case 'webhook-outgoing':
					Meteor.runAsUser(this.userId, () => {
						integration = Meteor.call('addOutgoingIntegration', this.bodyParams);
					});
					break;
				default:
					return RocketChat.API.v1.failure('Invalid integration type.');
			}

			return RocketChat.API.v1.success({ integration });
		} catch (e) {
			return RocketChat.API.v1.failure(e.name + ': ' + e.message);
		}
	}
});

RocketChat.API.v1.addRoute('integrations.list', { authRequired: true }, {
	get: function() {
		if (!RocketChat.authz.hasPermission(this.userId, 'manage-integrations')) {
			return RocketChat.API.v1.unauthorized();
		}

		const { offset, count } = RocketChat.API.v1.getPaginationItems(this);
		const integrations = RocketChat.models.Integrations.find({}, {
			sort: { ts: -1 },
			skip: offset,
			limit: count
		}).fetch();

		return RocketChat.API.v1.success({
			integrations: integrations,
			offset,
			items: integrations.length,
			total: RocketChat.models.Integrations.find().count()
		});
	}
});
{'fraction_non_alphanumeric': 0.15507201961385228, 'fraction_numerical': 0.0055163959546429666, 'mean_word_length': 3.610169491525424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6195717', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1082, 'n_words': 190}