Add disable edit mode environment variable (#730)

This commit is contained in:
Manuel
2023-02-22 21:59:49 +01:00
committed by GitHub
parent f5686fbf2c
commit f56f4b33ce
7 changed files with 103 additions and 18 deletions

View File

@@ -1,13 +1,22 @@
import fs from 'fs';
import path from 'path';
import Consola from 'consola';
import { NextApiRequest, NextApiResponse } from 'next';
import { BackendConfigType, ConfigType } from '../../../types/config';
import { getConfig } from '../../../tools/config/getConfig';
function Put(req: NextApiRequest, res: NextApiResponse) {
if (process.env.DISABLE_EDIT_MODE === 'true') {
return res.status(409).json({ error: 'Edit mode has been disabled by the administrator' });
}
// Get the slug of the request
const { slug } = req.query as { slug: string };
// Get the body of the request
const { body: config }: { body: ConfigType } = req;
if (!slug || !config) {