Rename worldinfo API endpoints
This commit is contained in:
parent
cf2b074d4b
commit
c746e6a426
|
@ -424,7 +424,7 @@ async function loadWorldInfoData(name) {
|
|||
return worldInfoCache[name];
|
||||
}
|
||||
|
||||
const response = await fetch('/getworldinfo', {
|
||||
const response = await fetch('/api/worldinfo/get', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({ name: name }),
|
||||
|
@ -1402,7 +1402,7 @@ function createWorldInfoEntry(name, data, fromSlashCommand = false) {
|
|||
}
|
||||
|
||||
async function _save(name, data) {
|
||||
await fetch('/editworldinfo', {
|
||||
await fetch('/api/worldinfo/edit', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({ name: name, data: data }),
|
||||
|
@ -1464,7 +1464,7 @@ async function deleteWorldInfo(worldInfoName) {
|
|||
return;
|
||||
}
|
||||
|
||||
const response = await fetch('/deleteworldinfo', {
|
||||
const response = await fetch('/api/worldinfo/delete', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({ name: worldInfoName }),
|
||||
|
@ -2269,7 +2269,7 @@ export async function importWorldInfo(file) {
|
|||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '/importworldinfo',
|
||||
url: '/api/worldinfo/import',
|
||||
data: formData,
|
||||
beforeSend: () => { },
|
||||
cache: false,
|
||||
|
|
14
server.js
14
server.js
|
@ -1060,7 +1060,7 @@ app.post('/getsettings', jsonParser, (request, response) => {
|
|||
});
|
||||
});
|
||||
|
||||
app.post('/getworldinfo', jsonParser, (request, response) => {
|
||||
app.post('/api/worldinfo/get', jsonParser, (request, response) => {
|
||||
if (!request.body?.name) {
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ app.post('/getworldinfo', jsonParser, (request, response) => {
|
|||
return response.send(file);
|
||||
});
|
||||
|
||||
app.post('/deleteworldinfo', jsonParser, (request, response) => {
|
||||
app.post('/api/worldinfo/delete', jsonParser, (request, response) => {
|
||||
if (!request.body?.name) {
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
@ -1132,7 +1132,7 @@ function getImages(path) {
|
|||
.sort(Intl.Collator().compare);
|
||||
}
|
||||
|
||||
app.post('/importworldinfo', urlencodedParser, (request, response) => {
|
||||
app.post('/api/worldinfo/import', urlencodedParser, (request, response) => {
|
||||
if (!request.file) return response.sendStatus(400);
|
||||
|
||||
const filename = `${path.parse(sanitize(request.file.originalname)).name}.json`;
|
||||
|
@ -1167,7 +1167,7 @@ app.post('/importworldinfo', urlencodedParser, (request, response) => {
|
|||
return response.send({ name: worldName });
|
||||
});
|
||||
|
||||
app.post('/editworldinfo', jsonParser, (request, response) => {
|
||||
app.post('/api/worldinfo/edit', jsonParser, (request, response) => {
|
||||
if (!request.body) {
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
@ -2134,6 +2134,12 @@ redirect('/creategroup', '/api/groups/create');
|
|||
redirect('/editgroup', '/api/groups/edit');
|
||||
redirect('/deletegroup', '/api/groups/delete');
|
||||
|
||||
// Redirect deprecated worldinfo API endpoints
|
||||
redirect('/getworldinfo', '/api/worldinfo/get');
|
||||
redirect('/deleteworldinfo', '/api/worldinfo/delete');
|
||||
redirect('/importworldinfo', '/api/worldinfo/import');
|
||||
redirect('/editworldinfo', '/api/worldinfo/edit');
|
||||
|
||||
// ** REST CLIENT ASYNC WRAPPERS **
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue