<commit_before>path = require 'path'
fs = require 'fs'
bodyParser = require 'body-parser'

githubWebhookMiddleware = require './github-endpoints'
bitbucketWebhookMiddleware = require './bitbucket-endpoints'
simpleProcessSpawner = require('./process-spawner').simpleProcessSpawner

module.exports = (app, requestsEndpoint) =>
	app.locals.githubRepositoryNameHooks = []
	app.locals.bitbucketRepositoryNameHooks = []
	app.locals.urlIncludesHooks = []

	app.use bodyParser.json
		type: 'application/json'
	
	app.use path.join(requestsEndpoint, process.env.GITHUB_ROOT), githubWebhookMiddleware
	app.use path.join(requestsEndpoint, process.env.BITBUCKET_ROOT), bitbucketWebhookMiddleware

	app.use requestsEndpoint, (req, res, next) ->
		console.log 'Webhook Request:', req.url
		n = 0
		for hook in req.app.locals.urlIncludesHooks
			if req.url.includes(process.env.URL_WEBHOOK_PREFIX + hook.string)
				n += 1
				simpleProcessSpawner
					exec: 'bash'
					script: 'example-lytedev-hugo-site.bash'
		if n != 0
			res.status(200).send('Success')
		else
			return next()<commit_msg>Fix url hooks not spawning the configured script<commit_after>path = require 'path'
fs = require 'fs'
bodyParser = require 'body-parser'

githubWebhookMiddleware = require './github-endpoints'
bitbucketWebhookMiddleware = require './bitbucket-endpoints'
simpleProcessSpawner = require('./process-spawner').simpleProcessSpawner

module.exports = (app, requestsEndpoint) =>
	app.locals.githubRepositoryNameHooks = []
	app.locals.bitbucketRepositoryNameHooks = []
	app.locals.urlIncludesHooks = []

	app.use bodyParser.json
		type: 'application/json'
	
	app.use path.join(requestsEndpoint, process.env.GITHUB_ROOT), githubWebhookMiddleware
	app.use path.join(requestsEndpoint, process.env.BITBUCKET_ROOT), bitbucketWebhookMiddleware

	app.use requestsEndpoint, (req, res, next) ->
		console.log 'Webhook Request:', req.url
		n = 0
		for hook in req.app.locals.urlIncludesHooks
			if req.url.includes(process.env.URL_WEBHOOK_PREFIX + hook.string)
				n += 1
				simpleProcessSpawner hook
		if n != 0
			res.status(200).send('Success')
		else
			return next()
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.005628517823639775, 'mean_word_length': 4.9415041782729805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4852478', 'n_tokens_mistral': 752, 'n_tokens_neox': 695, 'n_words': 137}