2023-07-09 16:26:19 +02:00
|
|
|
import { FlowModel } from '../models/flow.mjs'
|
|
|
|
|
|
|
|
export function FlowsController() {}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send out an invite for a translator who wants to join the team
|
|
|
|
* See: https://freesewing.dev/reference/backend/api
|
|
|
|
*/
|
|
|
|
FlowsController.prototype.sendTranslatorInvite = async (req, res, tools) => {
|
|
|
|
const Flow = new FlowModel(tools)
|
|
|
|
await Flow.sendTranslatorInvite(req)
|
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|
2023-07-09 18:49:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Send out an email to the maintainer to notify them of a new language suggestion
|
|
|
|
* See: https://freesewing.dev/reference/backend/api
|
|
|
|
*/
|
|
|
|
FlowsController.prototype.sendLanguageSuggestion = async (req, res, tools) => {
|
|
|
|
const Flow = new FlowModel(tools)
|
|
|
|
await Flow.sendLanguageSuggestion(req)
|
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|
2023-08-15 17:32:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Upload an image to Cloudflare
|
|
|
|
* See: https://freesewing.dev/reference/backend/api
|
|
|
|
*/
|
|
|
|
FlowsController.prototype.uploadImage = async (req, res, tools) => {
|
|
|
|
const Flow = new FlowModel(tools)
|
|
|
|
await Flow.uploadImage(req)
|
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove an image from Cloudflare
|
|
|
|
* See: https://freesewing.dev/reference/backend/api
|
|
|
|
*/
|
|
|
|
FlowsController.prototype.removeImage = async (req, res, tools) => {
|
|
|
|
const Flow = new FlowModel(tools)
|
|
|
|
await Flow.removeImage(req)
|
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|
2023-08-17 14:28:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates a pull request for a new showcase post
|
|
|
|
* See: https://freesewing.dev/reference/backend/api
|
|
|
|
*/
|
2023-08-18 17:26:23 +02:00
|
|
|
FlowsController.prototype.createPostPr = async (req, res, tools, type) => {
|
2023-08-17 14:28:36 +02:00
|
|
|
const Flow = new FlowModel(tools)
|
2023-08-18 17:26:23 +02:00
|
|
|
await Flow.createPostPr(req, type)
|
2023-08-17 14:28:36 +02:00
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create Issue
|
|
|
|
*
|
|
|
|
* This is the endpoint that handles creation of Github issues
|
|
|
|
* See: https://freesewing.dev/reference/backend/api/apikey
|
|
|
|
*/
|
|
|
|
FlowsController.prototype.createIssue = async (req, res, tools) => {
|
|
|
|
const Flow = new FlowModel(tools)
|
|
|
|
await Flow.createIssue(req)
|
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|
2023-08-18 13:49:51 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Is a blog or showcase slug available?
|
|
|
|
*
|
|
|
|
* This is the endpoint that verifies whether a blog or showcase slug is available
|
|
|
|
* See: https://freesewing.dev/reference/backend/api/apikey
|
|
|
|
*/
|
|
|
|
FlowsController.prototype.isSlugAvailable = async (req, res, tools, type) => {
|
|
|
|
const Flow = new FlowModel(tools)
|
|
|
|
const available = await Flow.isSlugAvailable(req, type)
|
|
|
|
|
|
|
|
if (!available)
|
|
|
|
Flow.setResponse(200, false, {
|
|
|
|
result: 'success',
|
|
|
|
slug: req.params.slug,
|
|
|
|
available: false,
|
|
|
|
})
|
|
|
|
else Flow.setResponse(404)
|
|
|
|
|
|
|
|
return Flow.sendResponse(res)
|
|
|
|
}
|