Can now handle gitea events.

This commit is contained in:
BurnyLlama 2021-08-10 22:03:06 +02:00
parent a22c8a4d2a
commit 73d8228c62

View File

@ -1,11 +1,13 @@
import fs from 'fs'
import express from 'express'
import { exec } from 'child_process'
import express from 'express'
import njk from 'nunjucks'
import { requestHandler } from './libs/requestHandler.js'
import { utils } from './libs/utils/utils.js'
import { nunjacksConfig } from './libs/nunjucksConfig.js'
import { generateSiteMap } from './libs/utils/siteMap.js'
// Load in config
@ -33,6 +35,15 @@ utils.generate()
// Send all requests to the requestHandler.
Server.get('*', (req, res) => requestHandler(req, res, Config))
// Handle events from gitea.
Server.post('/gitea/pushEvent', (req, res) => {
console.log("Received gitea push event; pulling from gitea and regenerating site map...")
exec("git pull")
generateSiteMap(Config)
res.status(200).send('OK!')
console.log("Done!")
})
// Start the server