mirror of
https://github.com/LukasKanka/api_test.git
synced 2026-11-11 14:34:36 +01:00
cicd
This commit is contained in:
1 parent
207c50f51d
commit
e5c6276bab
55 files changed
+28732
No files matched your search
@@ -0,0 +1,122 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/node,visualstudiocode
|
||||
# Edit at https://www.gitignore.io/?templates=node,visualstudiocode
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# rollup.js default build output
|
||||
dist/
|
||||
|
||||
# Uncomment the public line if your project uses Gatsby
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
|
||||
# public
|
||||
|
||||
# Storybook build outputs
|
||||
.out
|
||||
.storybook-out
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Temporary folders
|
||||
tmp/
|
||||
temp/
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
|
||||
# End of https://www.gitignore.io/api/node,visualstudiocode
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM node:18
|
||||
WORKDIR /usr/src/app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
CMD [ "node", "app.js" ]
|
||||
@@ -0,0 +1,41 @@
|
||||
# PotterAPI
|
||||
|
||||
### Prerequisites
|
||||
1. Installed [NodeJS](https://nodejs.org/en/)
|
||||
|
||||
### Installation
|
||||
|
||||
1. Open terminal and run following commands
|
||||
```
|
||||
git clone https://github.com/skarbala/PotterAPI.git
|
||||
cd PotterAPI
|
||||
npm install
|
||||
```
|
||||
|
||||
2. Run the API using
|
||||
```
|
||||
npm start
|
||||
```
|
||||
|
||||
#### ✅ You should see following message
|
||||
> Harry Potter App listening on port 3000!
|
||||
|
||||
## Documentation
|
||||
|
||||
#### Base url
|
||||
All routes needs to be send to base url `http://localhost:3000`
|
||||
|
||||
#### Response type
|
||||
Default response format is `application/json`
|
||||
|
||||
### Spells service
|
||||
#### Authentication
|
||||
No authentication needed
|
||||
#### Available endpoints
|
||||
``` GET /spells ``` returns list spells
|
||||
|
||||
``` GET /spells/{id} ``` returns specific spell.
|
||||
|
||||
``` DELETE /spells/{id} ``` deletes spell
|
||||
|
||||
```POST /spells``` adds new spell
|
||||
@@ -0,0 +1,66 @@
|
||||
var express = require('express');
|
||||
var basicAuth = require('express-basic-auth');
|
||||
let jwt = require('jsonwebtoken');
|
||||
var boolParser = require('express-query-boolean');
|
||||
var cors = require('cors');
|
||||
|
||||
module.exports = verifyToken;
|
||||
var app = express();
|
||||
const port = 3000
|
||||
|
||||
app.use(express.json())
|
||||
app.use(boolParser());
|
||||
app.use(cors());
|
||||
|
||||
|
||||
const spellRoute = require('./routes/spells.js');
|
||||
app.use('/spells', spellRoute);
|
||||
|
||||
const houseRoute = require('./routes/houses.js');
|
||||
app.use('/houses', houseRoute);
|
||||
|
||||
const characterRoute = require('./routes/characters.js');
|
||||
app.use('/characters', characterRoute)
|
||||
|
||||
const sortingHatRoute = require('./routes/sortinghat.js');
|
||||
app.use('/sortingHat', sortingHatRoute);
|
||||
|
||||
const quote = require('./routes/quote.js');
|
||||
app.use('/quote', quote);
|
||||
|
||||
app.get('/login', basicAuth({
|
||||
users: { 'admin': 'supersecret' },
|
||||
}), (req, res) => {
|
||||
const user = {
|
||||
username: 'furboslav',
|
||||
id: 5,
|
||||
}
|
||||
generateToken(user, res);
|
||||
});
|
||||
|
||||
generateToken = function (user, res) {
|
||||
jwt.sign({ user: user }, 'secretkey', (err, token) => {
|
||||
res.json({
|
||||
token: token
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function verifyToken(req, res, next) {
|
||||
const bearerHeader = req.header('Authorization');
|
||||
if (typeof bearerHeader !== 'undefined') {
|
||||
const bearer = bearerHeader.split(' ');
|
||||
const bearerToken = bearer[1];
|
||||
req.token = bearerToken;
|
||||
next();
|
||||
}
|
||||
else {
|
||||
res.status(403)
|
||||
res.json({
|
||||
message: "Sorry Wizard you dont have TOKEN"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
app.listen(port, () => console.log(`Harry Potter App listening on port ${port}!`))
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,14 @@
|
||||
const houses = require('../houses.json');
|
||||
|
||||
exports.houses_list = function (req, res) {
|
||||
res.json(houses);
|
||||
}
|
||||
|
||||
exports.specific_house = function (req, res) {
|
||||
let result = houses.find(house => house.id == req.params.houseId);
|
||||
if (typeof result == 'undefined') {
|
||||
res.status(404)
|
||||
res.send({ message: "House not found" });
|
||||
}
|
||||
res.send(result);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
var spells = require('../spells.json');
|
||||
const joi = require('joi');
|
||||
const initialSpells = 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'),
|
||||
effect: joi.string().min(4),
|
||||
isUnforgivable: joi.boolean().required(),
|
||||
id: joi.any()
|
||||
});
|
||||
|
||||
const randomId = require('random-id');
|
||||
|
||||
exports.spells_list = function (req, res) {
|
||||
let result = spells;
|
||||
if (typeof req.query.type !== 'undefined') {
|
||||
result = spells.filter(spell => spell.type == req.query.type)
|
||||
}
|
||||
if (typeof req.query.isUnforgivable !== 'undefined') {
|
||||
result = result.filter(spell => spell.isUnforgivable == req.query.isUnforgivable)
|
||||
}
|
||||
if (typeof req.query.limit !== 'undefined') {
|
||||
result = result.slice(0, req.query.limit);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
return res.json(result);
|
||||
}, 100)
|
||||
}
|
||||
exports.delete_all = function (req, res) {
|
||||
spells = [];
|
||||
res.send({ message: 'Mischief managed' })
|
||||
}
|
||||
|
||||
exports.reset = function (req, res) {
|
||||
spells = initialSpells.slice(0);
|
||||
res.send({ message: 'Aparecium', spells: spells })
|
||||
}
|
||||
exports.specific_spell = function (req, res) {
|
||||
let result = spells.find(spell => spell.id == req.params.spellId);
|
||||
if (typeof result !== 'undefined') {
|
||||
return res.send(result);
|
||||
}
|
||||
return res.status(404).send({ message: "Spell not found" });
|
||||
}
|
||||
|
||||
exports.delete_spell = function (req, res) {
|
||||
let result = spells.find(spell => spell.id == req.params.spellId);
|
||||
if (typeof result == 'undefined') {
|
||||
return res.status(404).send({ message: "Spell not found" });
|
||||
}
|
||||
spells = spells.filter(spell => spell.id != req.params.spellId);
|
||||
return res.send({
|
||||
message: 'spell deleted'
|
||||
});
|
||||
}
|
||||
|
||||
exports.update_spell = function (req, res) {
|
||||
let result = spells.find(spell => spell.id == req.params.spellId);
|
||||
if (typeof result == 'undefined') {
|
||||
return res.status(404).send({ message: "Spell not found" });
|
||||
}
|
||||
|
||||
var newSpell = {
|
||||
spell: req.body.spell,
|
||||
type: req.body.type,
|
||||
effect: req.body.effect,
|
||||
isUnforgivable: req.body.isUnforgivable,
|
||||
id: result.id
|
||||
}
|
||||
const validation = schema.validate(newSpell);
|
||||
|
||||
|
||||
const { value, error } = validation;
|
||||
const valid = error == null;
|
||||
|
||||
if (!valid) {
|
||||
return res.status(422).json({
|
||||
message: 'Wizard, I\'m sory but your request is invalid',
|
||||
data: error
|
||||
})
|
||||
}
|
||||
|
||||
spells = spells.filter(spell => spell.id != req.params.spellId);
|
||||
spells.push(newSpell);
|
||||
return res.status(201).json({
|
||||
message: "Spell updated",
|
||||
spell: {
|
||||
id: newSpell.id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.new_spell = function (req, res) {
|
||||
var len = 30;
|
||||
var pattern = 'aA0'
|
||||
|
||||
var newSpell = {
|
||||
spell: req.body.spell,
|
||||
type: req.body.type,
|
||||
effect: req.body.effect,
|
||||
isUnforgivable: req.body.isUnforgivable,
|
||||
id: randomId(len, pattern)
|
||||
}
|
||||
|
||||
let result = spells.find((spell) => spell.spell === newSpell.spell);
|
||||
if (typeof result !== 'undefined') {
|
||||
return res.status(400).send({
|
||||
message: 'Spell ' + newSpell.spell + ' already exists'
|
||||
})
|
||||
}
|
||||
|
||||
const validation = schema.validate(newSpell);
|
||||
|
||||
const { value, error } = validation;
|
||||
const valid = error == null;
|
||||
if (!valid) {
|
||||
return res.status(422).json({
|
||||
message: 'Invalid request',
|
||||
data: error
|
||||
})
|
||||
}
|
||||
|
||||
spells.push(newSpell);
|
||||
return res.status(201).json({
|
||||
message: "Spell created",
|
||||
spell: {
|
||||
id: newSpell.id
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
[
|
||||
{
|
||||
"id": "5a05e2b252f721a3cf2ea33f",
|
||||
"name": "Gryffindor",
|
||||
"mascot": "lion",
|
||||
"headOfHouse": "Minerva McGonagall",
|
||||
"houseGhost": "Nearly Headless Nick",
|
||||
"founder": "Goderic Gryffindor",
|
||||
"school": "Hogwarts School of Witchcraft and Wizardry",
|
||||
"members": [
|
||||
"5a0fa648ae5bc100213c2332",
|
||||
"5a0fa67dae5bc100213c2333",
|
||||
"5a0fa7dcae5bc100213c2338",
|
||||
"5a107e1ae0686c0021283b19",
|
||||
"5a10944f3dc2080021cd8755",
|
||||
"5a10947c3dc2080021cd8756",
|
||||
"5a1096b33dc2080021cd8762",
|
||||
"5a1097653dc2080021cd8763",
|
||||
"5a1098fd3dc2080021cd876e",
|
||||
"5a109af13dc2080021cd877a",
|
||||
"5a109bfc3dc2080021cd877f",
|
||||
"5a109c3d3dc2080021cd8780",
|
||||
"5a109cb83dc2080021cd8784",
|
||||
"5a109cd33dc2080021cd8785",
|
||||
"5a109e143dc2080021cd878d",
|
||||
"5a109e1e3dc2080021cd878e",
|
||||
"5a109e253dc2080021cd878f",
|
||||
"5a109e543dc2080021cd8790",
|
||||
"5a109f053dc2080021cd8793",
|
||||
"5a1226520f5ae10021650d76",
|
||||
"5a1226d70f5ae10021650d77",
|
||||
"5a12292a0f5ae10021650d7e",
|
||||
"5a12298d0f5ae10021650d7f",
|
||||
"5a1229e10f5ae10021650d80",
|
||||
"5a122cbe0f5ae10021650d89",
|
||||
"5a1233ff0f5ae10021650d98",
|
||||
"5a1234cb0f5ae10021650d9b",
|
||||
"5a1237480f5ae10021650da3",
|
||||
"5a1237c00f5ae10021650da5",
|
||||
"5a1238070f5ae10021650da6",
|
||||
"5a1238350f5ae10021650da7",
|
||||
"5a12387a0f5ae10021650da8",
|
||||
"5a1238b20f5ae10021650da9",
|
||||
"5a1239130f5ae10021650daa",
|
||||
"5a12393d0f5ae10021650dab",
|
||||
"5a12395f0f5ae10021650dac",
|
||||
"5a1239c80f5ae10021650dad",
|
||||
"5a1239f10f5ae10021650dae",
|
||||
"5a123b450f5ae10021650db7",
|
||||
"5a123f130f5ae10021650dcc"
|
||||
],
|
||||
"values": [
|
||||
"courage",
|
||||
"bravery",
|
||||
"nerve",
|
||||
"chivalry"
|
||||
],
|
||||
"colors": [
|
||||
"scarlet",
|
||||
"gold"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "5a05da69d45bd0a11bd5e06f",
|
||||
"name": "Ravenclaw",
|
||||
"mascot": "eagle",
|
||||
"headOfHouse": "Fillius Flitwick",
|
||||
"houseGhost": "The Grey Lady",
|
||||
"founder": "Rowena Ravenclaw",
|
||||
"school": "Hogwarts School of Witchcraft and Wizardry",
|
||||
"members": [
|
||||
"5a0fa8a6ae5bc100213c233b",
|
||||
"5a107ffee0686c0021283b21",
|
||||
"5a108023e0686c0021283b22",
|
||||
"5a108047e0686c0021283b23",
|
||||
"5a1097d53dc2080021cd8769",
|
||||
"5a1099cf3dc2080021cd8772",
|
||||
"5a109a553dc2080021cd8777",
|
||||
"5a109de83dc2080021cd878c",
|
||||
"5a109e943dc2080021cd8791",
|
||||
"5a109ebd3dc2080021cd8792",
|
||||
"5a1225a20f5ae10021650d73",
|
||||
"5a12260f0f5ae10021650d75",
|
||||
"5a122a880f5ae10021650d82",
|
||||
"5a122ac40f5ae10021650d83",
|
||||
"5a122aef0f5ae10021650d84",
|
||||
"5a12368a0f5ae10021650da0",
|
||||
"5a123e450f5ae10021650dc8"
|
||||
],
|
||||
"values": [
|
||||
"intelligence",
|
||||
"creativity",
|
||||
"learning",
|
||||
"wit"
|
||||
],
|
||||
"colors": [
|
||||
"blue",
|
||||
" bronze"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "5a05dc8cd45bd0a11bd5e071",
|
||||
"name": "Slytherin",
|
||||
"mascot": "serpent",
|
||||
"headOfHouse": "Severus Snape",
|
||||
"houseGhost": "The Bloody Baron",
|
||||
"founder": "Salazar Slytherin",
|
||||
"members": [
|
||||
"5a0fa6bbae5bc100213c2334",
|
||||
"5a0fa6e8ae5bc100213c2335",
|
||||
"5a0fa74eae5bc100213c2336",
|
||||
"5a0fa772ae5bc100213c2337",
|
||||
"5a107e4ae0686c0021283b1a",
|
||||
"5a1093eb3dc2080021cd8753",
|
||||
"5a10942a3dc2080021cd8754",
|
||||
"5a1099353dc2080021cd876f",
|
||||
"5a109aa03dc2080021cd8779",
|
||||
"5a109d893dc2080021cd8789",
|
||||
"5a109d9f3dc2080021cd878a",
|
||||
"5a109dab3dc2080021cd878b",
|
||||
"5a109f8b3dc2080021cd8795",
|
||||
"5a109fa83dc2080021cd8796",
|
||||
"5a109fde3dc2080021cd8797",
|
||||
"5a1225640f5ae10021650d72",
|
||||
"5a1225e30f5ae10021650d74",
|
||||
"5a122c200f5ae10021650d88",
|
||||
"5a1232600f5ae10021650d93",
|
||||
"5a12327c0f5ae10021650d94",
|
||||
"5a1233bc0f5ae10021650d97",
|
||||
"5a1235060f5ae10021650d9c",
|
||||
"5a1236eb0f5ae10021650da1",
|
||||
"5a123a710f5ae10021650db1",
|
||||
"5a123af40f5ae10021650db5"
|
||||
],
|
||||
"values": [
|
||||
"ambition",
|
||||
"cunning",
|
||||
"leadership",
|
||||
"resourcefulness"
|
||||
],
|
||||
"colors": [
|
||||
"green",
|
||||
"silver"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "5a05dc58d45bd0a11bd5e070",
|
||||
"name": "Hufflepuff",
|
||||
"mascot": "badger",
|
||||
"headOfHouse": "Pomona Sprout",
|
||||
"houseGhost": "The Fat Friar",
|
||||
"founder": "Helga Hufflepuff",
|
||||
"school": "Hogwarts School of Witchcraft and Wizardry",
|
||||
"members": [
|
||||
"5a0fa11a4d153d00212c47cc",
|
||||
"5a0fa360ae5bc100213c232c",
|
||||
"5a0fa365ae5bc100213c232d",
|
||||
"5a0fa4daae5bc100213c232e",
|
||||
"5a0fa842ae5bc100213c2339",
|
||||
"5a0fa86dae5bc100213c233a",
|
||||
"5a1096253dc2080021cd875f",
|
||||
"5a1098bd3dc2080021cd876d",
|
||||
"5a109c993dc2080021cd8783",
|
||||
"5a1223720f5ae10021650d6f",
|
||||
"5a1223ed0f5ae10021650d70",
|
||||
"5a122f3d0f5ae10021650d8d",
|
||||
"5a1232b10f5ae10021650d95",
|
||||
"5a12333f0f5ae10021650d96",
|
||||
"5a1234500f5ae10021650d99",
|
||||
"5a1235790f5ae10021650d9d",
|
||||
"5a123cb40f5ae10021650dbc"
|
||||
],
|
||||
"values": [
|
||||
"hard work",
|
||||
"patience",
|
||||
"justice",
|
||||
"loyalty"
|
||||
],
|
||||
"colors": [
|
||||
"yellow",
|
||||
"black"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
let jwt = require('jsonwebtoken');
|
||||
module.exports = checkToken;
|
||||
|
||||
function checkToken(req, res, next) {
|
||||
jwt.verify(req.token, 'secretkey', (err, authData) => {
|
||||
if (err) {
|
||||
res.status(403);
|
||||
res.send(err);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
exports.checkHeader = (req, res, next) => {
|
||||
if (!req.is('application/json')) {
|
||||
res.status(400).send({ message: "Sorry Nick you dont have HEADer" });
|
||||
}
|
||||
next();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
let spells = require('../controllers/spellsController.js')
|
||||
|
||||
exports.spell_not_found = function (req, res, next) {
|
||||
let result = spells.find(spell => spell._id == req.params.spellId);
|
||||
if (typeof result == 'undefined') {
|
||||
return res.status(404).send({ message: "Spell not found" });
|
||||
}
|
||||
next();
|
||||
}
|
||||
Generated
+3263
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "PotterApi",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"start": "nodemon app.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18.x"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"express-basic-auth": "^1.2.0",
|
||||
"express-query-boolean": "^2.0.0",
|
||||
"joi": "^17.6.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"nodemon": "^2.0.2",
|
||||
"random-id": "^1.0.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
[
|
||||
{
|
||||
"quote": "Mr. and Mrs. Dursley of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much.",
|
||||
"author": "unknown"
|
||||
},
|
||||
{
|
||||
"quote": "I hope you're pleased with yourselves. We could all have been killed — or worse, expelled. Now if you don't mind, I'm going to bed.",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "It does not do well to dwell on dreams and forget to live.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "To the well-organized mind, death is but the next great adventure.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "You're a little scary sometimes, you know that? Brilliant ... but scary.",
|
||||
"author": "Ron Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "There will be no foolish wand-waving or silly incantations in this class. As such, I don't expect many of you to appreciate the subtle science and exact art that is potion-making. However, for those select few who possess the predisposition, I can teach you how to bewitch the mind and ensnare the senses. I can tell you how to bottle fame, brew glory, and even put a stopper in death. Then again, maybe some of you have come to Hogwarts in possession of abilities so formidable that you feel confident enough to not pay attention!",
|
||||
"author": "Severus Snape"
|
||||
},
|
||||
{
|
||||
"quote": "It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Yer a wizard Harry.",
|
||||
"author": "Rubeus Hagrid"
|
||||
},
|
||||
{
|
||||
"quote": "There are all kinds of courage. It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "The truth. It is a beautiful and terrible thing, and should therefore be treated with great caution.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "There are some things you can’t share without ending up liking each other, and knocking out a twelve-foot mountain troll is one of them.",
|
||||
"author": "unknown"
|
||||
},
|
||||
{
|
||||
"quote": "Fear of a name only increases fear of the thing itself.",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "Dobby is free.",
|
||||
"author": "Dobby"
|
||||
},
|
||||
{
|
||||
"quote": "Training for the ballet, Potter?",
|
||||
"author": "Draco Malfoy"
|
||||
},
|
||||
{
|
||||
"quote": "I’ll be in my bedroom, making no noise and pretending I’m not there.",
|
||||
"author": "Harry Potter"
|
||||
},
|
||||
{
|
||||
"quote": "Hearing voices no one else can hear isn’t a good sign, even in the wizarding world.",
|
||||
"author": "Ron Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "When in doubt, go to the library.",
|
||||
"author": "Ron Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "Fawkes is a phoenix, Harry. Phoenixes burst into flame when it is time for them to die and are reborn from the ashes.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Fame is a fickle friend, Harry. Celebrity is as celebrity does. Remember that.",
|
||||
"author": "Gilderoy Lockhart"
|
||||
},
|
||||
{
|
||||
"quote": "Honestly, if you were any slower, you’d be going backward.",
|
||||
"author": "Draco Malfoy"
|
||||
},
|
||||
{
|
||||
"quote": "I solemnly swear I am up to no good.",
|
||||
"author": "Harry Potter"
|
||||
},
|
||||
{
|
||||
"quote": "Honestly, am I the only person who's ever bothered to read 'Hogwarts: A History?",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "But you know, happiness can be found even in the darkest of times, if one only remembers to turn on the light.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Don’t let the muggles get you down.",
|
||||
"author": "Ron Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "I want to commit the murder I was imprisoned for.",
|
||||
"author": "Sirius Black"
|
||||
},
|
||||
{
|
||||
"quote": "Why, dear boy, we don’t send wizards to Azkaban just for blowing up their aunts.",
|
||||
"author": "Cornelius Fudge"
|
||||
},
|
||||
{
|
||||
"quote": "You think the dead we loved truly ever leave us? You think that we don’t recall them more clearly in times of great trouble?",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Mischief Managed!",
|
||||
"author": "Harry Potter"
|
||||
},
|
||||
{
|
||||
"quote": "If you want to know what a man’s like, take a good look at how he treats his inferiors, not his equals.",
|
||||
"author": "Sirius Black"
|
||||
},
|
||||
{
|
||||
"quote": "I am what I am, an' I'm not ashamed. 'Never be ashamed,' my ol' dad used ter say, 'there's some who'll hold it against you, but they're not worth botherin' with.'",
|
||||
"author": "Rubeus Hagrid"
|
||||
},
|
||||
{
|
||||
"quote": "It matters not what someone is born, but what they grow to be.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "We are only as strong as we are united, as weak as we are divided.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Your devotion is nothing more than cowardice. You would not be here if you had anywhere else to go.",
|
||||
"author": "Voldemort"
|
||||
},
|
||||
{
|
||||
"quote": "Numbing the pain for a while will make it worse when you finally feel it.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Anyone can speak Troll. All you have to do is point and grunt.",
|
||||
"author": "Fred Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "Curiosity is not a sin…. But we should exercise caution with our curiosity… yes, indeed.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Twitchy little ferret, aren’t you, Malfoy?",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "Just because it’s taken you three years to notice, Ron, doesn’t mean no one else has spotted I’m a girl!",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "Differences of habit and language are nothing at all if our aims are identical and our hearts are open.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Give her hell from us, Peeves.' And Peeves, whom Harry had never seen take an order from a student before, swept his belled hat from his head and sprang to a salute as Fred and George wheeled about to tumultuous applause from the students below and sped out of the open front doors into the glorious sunset.",
|
||||
"author": "Harry Potter"
|
||||
},
|
||||
{
|
||||
"quote": "I think we've outgrown full-time education ... Time to test our talents in the real world, d'you reckon?,",
|
||||
"author": "Fred Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "I think I'll just go down and have some pudding and wait for it all to turn up — it always does in the end.",
|
||||
"author": "Luna Lovegood"
|
||||
},
|
||||
{
|
||||
"quote": "Just because you have the emotional range of a teaspoon doesn't mean we all have.",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "You can laugh, but people used to believe there were no such things as the Blibbering Humdinger or the Crumple-Horned Snorkack!",
|
||||
"author": "Luna Lovegood"
|
||||
},
|
||||
{
|
||||
"quote": "I mean, it's sort of exciting, isn't it, breaking the rules?",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "We’ve all got both light and dark inside us. What matters is the part we choose to act on. That’s who we really are.",
|
||||
"author": "Sirius Black"
|
||||
},
|
||||
{
|
||||
"quote": "Indifference and neglect often do much more damage than outright dislike.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Youth can not know how age thinks and feels. But old men are guilty if they forget what it was to be young.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Things we lose have a way of coming back to us in the end, if not always in the way we expect.",
|
||||
"author": "Luna Lovegood"
|
||||
},
|
||||
{
|
||||
"quote": "Wit beyond measure is man’s greatest treasure.",
|
||||
"author": "Luna Lovegood"
|
||||
},
|
||||
{
|
||||
"quote": "'The thing about growing up with Fred and George is that you sort of start thinking anything's possible if you've got enough nerve.'",
|
||||
"author": "Ginny Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "And now, Harry, let us step out into the night and pursue that flighty temptress, adventure.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Dumbledore says people find it far easier to forgive others for being wrong than being right.",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "There is no need to call me ‘sir,’ Professor.",
|
||||
"author": "Harry Potter"
|
||||
},
|
||||
{
|
||||
"quote": "You’re just as sane as I am.",
|
||||
"author": "Luna Lovegood"
|
||||
},
|
||||
{
|
||||
"quote": "I am a wizard, not a baboon brandishing a stick.",
|
||||
"author": "unknown"
|
||||
},
|
||||
{
|
||||
"quote": "Age is foolish and forgetful when it underestimates youth.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Once again, you show all the sensitivity of a blunt axe.",
|
||||
"author": "Nearly Headless Nick"
|
||||
},
|
||||
{
|
||||
"quote": "It is the unknown we fear when we look upon death and darkness, nothing more.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "It is the quality of one’s convictions that determines success, not the number of followers.",
|
||||
"author": "Remus Lupin"
|
||||
},
|
||||
{
|
||||
"quote": "Every human life is worth the same, and worth saving.",
|
||||
"author": "Kingsley Shacklebolt"
|
||||
},
|
||||
{
|
||||
"quote": "After all this time? Always.",
|
||||
"author": "Severus Snape"
|
||||
},
|
||||
{
|
||||
"quote": "Words are, in my not-so-humble opinion, our most inexhaustible source of magic. Capable of both inflicting injury, and remedying it.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "Not my daughter, you b*tch!",
|
||||
"author": "Molly Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "It is a curious thing, Harry, but perhaps those who are best suited to power are those who have never sought it. Those who, like you, have leadership thrust upon them, and take up the mantle because they must, and find to their own surprise that they wear it well.",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "He can run faster than Severus Snape confronted with shampoo.",
|
||||
"author": "Fred Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "Of course it is happening inside your head, Harry, but why on earth should that mean that it is not real?",
|
||||
"author": "Albus Dumbledore"
|
||||
},
|
||||
{
|
||||
"quote": "I've always wanted to use that spell.",
|
||||
"author": "Minerva McGonagall"
|
||||
},
|
||||
{
|
||||
"quote": "No post on Sundays.",
|
||||
"author": "Vernon Dursley"
|
||||
},
|
||||
{
|
||||
"quote": "We could all have been killed—or worse, expelled.",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "Never trust anything that can think for itself if you can’t see where it keeps its brain.",
|
||||
"author": "Arthur Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "Why couldn’t it be ‘follow the butterflies’?",
|
||||
"author": "Ron Weasley"
|
||||
},
|
||||
{
|
||||
"quote": "Riddikulus",
|
||||
"author": "Remus Lupin"
|
||||
},
|
||||
{
|
||||
"quote": "The ones that love us never really leave us.",
|
||||
"author": "Sirius Black"
|
||||
},
|
||||
{
|
||||
"quote": "Have a biscuit, Potter.",
|
||||
"author": "Minerva McGonagall"
|
||||
},
|
||||
{
|
||||
"quote": "Just because you have the emotional range of a teaspoon doesn’t mean we all have.",
|
||||
"author": "Hermione Granger"
|
||||
},
|
||||
{
|
||||
"quote": "Život je ako rebrík do kurína - krátky a osratý",
|
||||
"author": "Furbyho babka"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,24 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
var characters = require('../characters.json');
|
||||
var basicAuth = require('express-basic-auth');
|
||||
|
||||
router.use(basicAuth({
|
||||
users: { 'admin': 'supersecret' },
|
||||
unauthorizedResponse: {
|
||||
message: "Sorry Wizard, can't let you in."
|
||||
}
|
||||
|
||||
}))
|
||||
|
||||
router.get('/',
|
||||
function (req, res) {
|
||||
res.json(characters);
|
||||
});
|
||||
|
||||
router.get('/:characterId', function (req, res) {
|
||||
let result = characters.find(character => character.id == req.params.characterId);
|
||||
res.send(result);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,13 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const houseController = require('../controllers/housesController.js')
|
||||
module.exports = router;
|
||||
const verifyToken = require('../app.js');
|
||||
const checkToken = require('../middleware/auth.js');
|
||||
|
||||
router.use(verifyToken, checkToken);
|
||||
|
||||
router.get('/', houseController.houses_list);
|
||||
|
||||
router.get('/:houseId', houseController.specific_house)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
module.exports = router;
|
||||
const quotes = require('../quotes.json')
|
||||
|
||||
function getRandomQuote() {
|
||||
return quotes[Math.floor(Math.random() * quotes.length)];
|
||||
}
|
||||
|
||||
router.get('/', function (req, res) {
|
||||
res.json(getRandomQuote())
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
module.exports = router;
|
||||
const houses = require('../houses.json')
|
||||
const sortingHatQuotes = require('../sortinghatquotes.json')
|
||||
|
||||
function getRandomHouseName() {
|
||||
let houseNames = houses.map(house => house.name);
|
||||
return houseNames[Math.floor(Math.random() * houseNames.length)];
|
||||
}
|
||||
|
||||
function getRandomQuote() {
|
||||
return sortingHatQuotes[Math.floor(Math.random() * sortingHatQuotes.length)];
|
||||
}
|
||||
|
||||
router.get('/', function (req, res) {
|
||||
let house = getRandomHouseName();
|
||||
setTimeout(() => {
|
||||
return res.json({
|
||||
sortingHatSays: getRandomQuote() + ' ' + house,
|
||||
house: house
|
||||
})
|
||||
}, 500)
|
||||
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const spells = require('../spells.json');
|
||||
const spellController = require('../controllers/spellsController.js')
|
||||
module.exports = router;
|
||||
const authChecker = require('../middleware/header.js')
|
||||
|
||||
router.get('/', spellController.spells_list);
|
||||
|
||||
router.post('/', authChecker.checkHeader, spellController.new_spell);
|
||||
|
||||
router.get('/:spellId', spellController.specific_spell)
|
||||
|
||||
router.delete('/:spellId', spellController.delete_spell)
|
||||
|
||||
router.delete('/actions/deleteAll', spellController.delete_all)
|
||||
|
||||
router.get('/actions/reset', spellController.reset)
|
||||
|
||||
router.put('/:spellId', authChecker.checkHeader, spellController.update_spell)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[
|
||||
"Move your ass to",
|
||||
"You are a coward without future, your house is",
|
||||
"Your broom is too magnificent, you should study at",
|
||||
"Oh shit, that's right I'm a hat. And your house is",
|
||||
"Stick your wand into",
|
||||
"Hmm, difficult. VERY difficult. Plenty of courage, I see. But where to put you? All right it's",
|
||||
"I'm just a hat. My only task is to pick random house..Like this one."
|
||||
]
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user