-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from NekoNyaDevs/v2
V2
- Loading branch information
Showing
31 changed files
with
1,186 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
{ | ||
"name": "nekonya-storage", | ||
"version": "1.0.5", | ||
"description": "The storage server of NekoNya.", | ||
"main": "lib/index.js", | ||
"version": "2.0.5", | ||
"description": "The static storage server and API of NekoNya.", | ||
"main": "src/index.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "npx tsc && node lib/index.js" | ||
"start": "cross-env NODE_ENV=production npx tsx src/index", | ||
"dev": "cross-env NODE_ENV=development npx tsx src/index" | ||
}, | ||
"keywords": [], | ||
"author": "TheDogHusky", | ||
"license": "ISC", | ||
"license": "GPL-3.0-or-later", | ||
"dependencies": { | ||
"@classycrafter/super-logger": "^2.0.00", | ||
"chalk": "^4.1.2", | ||
"cors": "^2.8.5", | ||
"ejs": "^3.1.8", | ||
"cross-env": "^7.0.3", | ||
"express": "^4.18.2", | ||
"jose": "^4.13.1", | ||
"node-fetch": "^2.6.9" | ||
"express-validator": "^7.1.0", | ||
"tsx": "^4.16.2" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.9.5", | ||
"@types/cors": "^2.8.13", | ||
"@types/express": "^4.17.17", | ||
"@types/node-fetch": "^2.6.2" | ||
"typescript": "^4.9.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Router } from 'express'; | ||
const router = Router(); | ||
|
||
const eightballAnswers = [ | ||
"It is certain", | ||
"It is decidedly so", | ||
"Without a doubt", | ||
"Yes, definitely", | ||
"You may rely on it", | ||
|
||
"As I see it, yes", | ||
"Most likely", | ||
"Outlook good", | ||
"Yes", | ||
"Signs point to yes", | ||
|
||
"Reply hazy try again", | ||
"Ask again later", | ||
"Better not tell you now", | ||
"Cannot predict now", | ||
"Concentrate and ask again", | ||
|
||
"Don't count on it", | ||
"My reply is no", | ||
"My sources say no", | ||
"Outlook not so good", | ||
"Very doubtful" | ||
]; | ||
|
||
const cuteEightballAnswers = [ | ||
"Yes!!", | ||
"Of Cwurse!", | ||
"Yes, definitelwy nya!", | ||
"Without any doubts nya!", | ||
"My tail says yess!", | ||
|
||
"Mhh.. I think so!", | ||
"Most likely!", | ||
"Outwook good!", | ||
"Yesh!", | ||
"Signs point to yes!", | ||
|
||
"I don't know nya..", | ||
"Ask again later, nya!", | ||
"Better not twell you now!", | ||
"Cannot predict now..", | ||
"Concentrate and ask again! :3", | ||
|
||
"Don't count on it! >:c", | ||
">-< My reply is nyo!", | ||
"My sources say nyo!", | ||
"Outlook nyot so good! :c", | ||
"Very doubtfwul!" | ||
]; | ||
|
||
router.get('/', (req, res) => { | ||
const cute = req.query.cute || false; | ||
const answers = cute ? cuteEightballAnswers : eightballAnswers; | ||
const answer = answers[Math.floor(Math.random() * answers.length)]; | ||
|
||
res.status(200).json({ | ||
answer: answer | ||
}); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Router } from 'express'; | ||
const router = Router(); | ||
|
||
router.get("/", (req, res) => { | ||
res.status(200).json([ | ||
{ | ||
"name": "random", | ||
"description": "Get random images", | ||
"path": "/random", | ||
"methods": ["GET"], | ||
"parameters": [ | ||
{ | ||
"name": "type", | ||
"description": "Type of image", | ||
"required": true, | ||
"type": "string", | ||
"values": ["neko", "kitsune", "pat", "kisse", "hug", "lewd", "slap"] | ||
} | ||
], | ||
"queries": [], | ||
"body": [] | ||
}, | ||
{ | ||
"name": "8ball", | ||
"description": "Get a random 8ball response", | ||
"path": "/8ball", | ||
"methods": ["GET"], | ||
"parameters": [], | ||
"queries": [ | ||
{ | ||
"name": "cute", | ||
"description": "If you want the response to be cute", | ||
"required": false, | ||
"type": "boolean" | ||
} | ||
], | ||
"body": [] | ||
}, | ||
{ | ||
"name": "owoify", | ||
"description": "Owoify text (make it cute)", | ||
"path": "/owoify", | ||
"methods": ["GET", "POST"], | ||
"parameters": [], | ||
"queries": [ | ||
{ | ||
"name": "text", | ||
"description": "Text to owoify", | ||
"required": true, | ||
"type": "string" | ||
} | ||
], | ||
"body": [ | ||
{ | ||
"name": "text", | ||
"description": "Text to owoify", | ||
"required": true, | ||
"type": "string", | ||
"max_length": 2000, | ||
"min_length": 1 | ||
} | ||
] | ||
} | ||
]); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,26 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import {Router} from 'express'; | ||
import {isValidToken} from "../../structures/functions"; | ||
import {Logger} from "@classycrafter/super-logger"; | ||
|
||
// Load every file here in this directory except this file, then load the returned route inside a router object which is then exported | ||
const router = Router(); | ||
router.get('/', (req, res) => { | ||
res.status(200).json({ | ||
status: 200, | ||
message: 'OK', | ||
version: 'v1' | ||
version: 'v1', | ||
endpoints: '/endpoints' | ||
}); | ||
}); | ||
|
||
router.use(async (req, res, next) => { | ||
if(req.path === '/token') return next(); | ||
export default (logger: Logger) => { | ||
const files = fs.readdirSync(__dirname).filter(file => file !== path.basename(__filename)); | ||
for (const file of files) { | ||
const route = require('./' + file).default; | ||
const fileName = file.replace('.ts', ''); | ||
router.use(`/${fileName}`, route); | ||
logger.info(`Loaded route /api/v1/${fileName}`, "API"); | ||
} | ||
|
||
await isValidToken(req).then((result) => { | ||
if (result.status !== 200) { | ||
return res.status(result.status).json({ | ||
status: result.status, | ||
error: result.error, | ||
message: result.message | ||
}); | ||
} | ||
|
||
next(); | ||
}).catch((err: Error) => { | ||
next(err); | ||
}); | ||
}); | ||
|
||
const files = fs.readdirSync(__dirname).filter(file => file !== path.basename(__filename) && file.endsWith('.js')); | ||
for (const file of files) { | ||
const route = require('./' + file).default; | ||
const fileName = file.replace('.js', ''); | ||
router.use(`/${fileName}`, route); | ||
} | ||
|
||
export default router; | ||
return router; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.