fullLocalhostUpdateDateNotNetDownload

This commit is contained in:
kankys committed 2026-09-14 23:09:56 +02:00
1 parent abbba340c1
commit c8118d2154
4 files changed
+85 -9

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
info:
name: Add new sprll
type: http
seq: 5
http:
method: POST
url: http://localhost:3000/spells
body:
type: json
data: |-
{
"spell":"Fire speed",
"effect":"fire speed forever",
"type":"Curse",
"isUnforgivable":"false"
}
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
forwardAuthorizationHeader: false
+38 -8
View File
@@ -1,6 +1,11 @@
const fs = require('fs');
const path = require('path');
const spellsFilePath = path.join(__dirname, '../spells.json');
var spells = require('../spells.json');
const joi = require('joi');
const initialSpells = require('../spells.json');
const initialSpells = JSON.parse(JSON.stringify(require('../spells.json')));
const schema = joi.object().keys({
spell: joi.string().min(3).max(30).required().regex(/^\w+(?:\s+\w+)*$/),
type: joi.string().valid('Charm', 'Enchantment', 'Curse', 'Spell', 'Hex', 'Jinx'),
@@ -11,6 +16,10 @@ const schema = joi.object().keys({
const randomId = require('random-id');
function saveSpellsToFile() {
fs.writeFileSync(spellsFilePath, JSON.stringify(spells, null, 2));
}
exports.spells_list = function (req, res) {
let result = spells;
if (typeof req.query.type !== 'undefined') {
@@ -29,11 +38,13 @@ exports.spells_list = function (req, res) {
}
exports.delete_all = function (req, res) {
spells = [];
saveSpellsToFile();
res.send({ message: 'Mischief managed' })
}
exports.reset = function (req, res) {
spells = initialSpells.slice(0);
spells = JSON.parse(JSON.stringify(initialSpells));
saveSpellsToFile();
res.send({ message: 'Aparecium', spells: spells })
}
exports.specific_spell = function (req, res) {
@@ -50,6 +61,7 @@ exports.delete_spell = function (req, res) {
return res.status(404).send({ message: "Spell not found" });
}
spells = spells.filter(spell => spell.id != req.params.spellId);
saveSpellsToFile();
return res.send({
message: 'spell deleted'
});
@@ -81,12 +93,21 @@ exports.update_spell = function (req, res) {
})
}
const formattedSpell = {
id: value.id,
spell: value.spell,
type: value.type,
effect: value.effect,
isUnforgivable: value.isUnforgivable
};
spells = spells.filter(spell => spell.id != req.params.spellId);
spells.push(newSpell);
spells.push(formattedSpell);
saveSpellsToFile();
return res.status(201).json({
message: "Spell updated",
spell: {
id: newSpell.id
id: formattedSpell.id
}
});
}
@@ -96,11 +117,11 @@ exports.new_spell = function (req, res) {
var pattern = 'aA0'
var newSpell = {
id: randomId(len, pattern),
spell: req.body.spell,
type: req.body.type,
effect: req.body.effect,
isUnforgivable: req.body.isUnforgivable,
id: randomId(len, pattern)
isUnforgivable: req.body.isUnforgivable
}
let result = spells.find((spell) => spell.spell === newSpell.spell);
@@ -121,11 +142,20 @@ exports.new_spell = function (req, res) {
})
}
spells.push(newSpell);
const formattedSpell = {
id: value.id,
spell: value.spell,
type: value.type,
effect: value.effect,
isUnforgivable: value.isUnforgivable
};
spells.push(formattedSpell);
saveSpellsToFile();
return res.status(201).json({
message: "Spell created",
spell: {
id: newSpell.id
id: formattedSpell.id
}
});
}
+21
View File
@@ -1055,5 +1055,26 @@
"type": "Charm",
"effect": "makes an object fly",
"isUnforgivable": false
},
{
"id": "PtAvMpywOZ18uWGsKbKXz6G6FjFoYy",
"spell": "Corona",
"type": "Curse",
"effect": "sneezing forever",
"isUnforgivable": false
},
{
"id": "nuiR7cUzgBPfi1hj6Qj2YZZPYxGj04",
"spell": "Fire Corona",
"type": "Curse",
"effect": "fire sneezing forever",
"isUnforgivable": false
},
{
"id": "L9Df6eGhsDvzpV3EexUajlXCsDBKJ5",
"spell": "Fire speed",
"type": "Curse",
"effect": "fire speed forever",
"isUnforgivable": false
}
]
+1 -1
View File
@@ -9,7 +9,7 @@ import QuoteGenerator from "../src/components/QuoteGenerator";
import GringottsBank from "../src/components/GringottsBank";
const axiosconfig = {
baseURL: "https://potterapi-tgq2.onrender.com",
baseURL: process.env.VUE_APP_API_URL || "http://localhost:3000",
timeout: 30000,
};
Vue.prototype.$http = axios.create(axiosconfig);