mirror of
https://github.com/Zandercraft/TechnicFlux.git
synced 2026-10-30 04:49:20 +00:00
StandardJS Format
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
const express = require('express')
|
||||
const pckg = require('../package.json')
|
||||
const branchName = require('current-git-branch')();
|
||||
const branchName = require('current-git-branch')()
|
||||
const router = express.Router()
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
res.json({
|
||||
"api": pckg.prettyName,
|
||||
"version": pckg.version,
|
||||
"stream": branchName
|
||||
api: pckg.prettyName,
|
||||
version: pckg.version,
|
||||
stream: branchName
|
||||
})
|
||||
})
|
||||
|
||||
router.get('/mod/:modname/:modversion?', (req, res) => {
|
||||
// Found mod
|
||||
res.json({
|
||||
"id": 0,
|
||||
"name": "example",
|
||||
"pretty_name": "Example",
|
||||
"author": "ExampleAuthor",
|
||||
"description": "This is the description",
|
||||
"link": "https://example.com/",
|
||||
"versions": [
|
||||
"1.20.1-0.0.1",
|
||||
"1.20.1-0.0.2"
|
||||
id: 0,
|
||||
name: 'example',
|
||||
pretty_name: 'Example',
|
||||
author: 'ExampleAuthor',
|
||||
description: 'This is the description',
|
||||
link: 'https://example.com/',
|
||||
versions: [
|
||||
'1.20.1-0.0.1',
|
||||
'1.20.1-0.0.2'
|
||||
]
|
||||
})
|
||||
|
||||
// Found mod version
|
||||
res.json({
|
||||
"id": 0,
|
||||
"md5": "51c1305b56249804926e38fcf3e46640",
|
||||
"filesize": 0,
|
||||
"url": "https://example.com/file.zip",
|
||||
id: 0,
|
||||
md5: '51c1305b56249804926e38fcf3e46640',
|
||||
filesize: 0,
|
||||
url: 'https://example.com/file.zip'
|
||||
})
|
||||
|
||||
// Version Not Found
|
||||
@@ -48,39 +48,39 @@ router.get('/mod/:modname/:modversion?', (req, res) => {
|
||||
router.get('/modpack', (req, res) => {
|
||||
// Modpack Index
|
||||
res.json({
|
||||
"modpacks": {
|
||||
"slug": "Example Modpack Pretty Name"
|
||||
modpacks: {
|
||||
slug: 'Example Modpack Pretty Name'
|
||||
},
|
||||
"mirror_url": `http://${process.env.HOST}/mods`
|
||||
mirror_url: `http://${process.env.HOST}/mods`
|
||||
})
|
||||
})
|
||||
|
||||
router.get('/modpack/:slug/:build?', (req, res) => {
|
||||
// With Slug
|
||||
res.json({
|
||||
"name": "examplepack",
|
||||
"display_name": "Example Pack",
|
||||
"recommended": "0.0.1",
|
||||
"latest": "0.0.2",
|
||||
"builds": [
|
||||
"0.0.1",
|
||||
"0.0.2"
|
||||
name: 'examplepack',
|
||||
display_name: 'Example Pack',
|
||||
recommended: '0.0.1',
|
||||
latest: '0.0.2',
|
||||
builds: [
|
||||
'0.0.1',
|
||||
'0.0.2'
|
||||
]
|
||||
})
|
||||
|
||||
// Build found
|
||||
res.json({
|
||||
"minecraft": "1.20.1",
|
||||
"forge": null,
|
||||
"java": 17,
|
||||
"memory": 2048,
|
||||
"mods": [
|
||||
minecraft: '1.20.1',
|
||||
forge: null,
|
||||
java: 17,
|
||||
memory: 2048,
|
||||
mods: [
|
||||
{
|
||||
"name": "examplemod",
|
||||
"version": "0.0.1",
|
||||
"md5": "51c1305b56249804926e38fcf3e46640",
|
||||
"url": "https://example.com/file.zip",
|
||||
"filesize": 0
|
||||
name: 'examplemod',
|
||||
version: '0.0.1',
|
||||
md5: '51c1305b56249804926e38fcf3e46640',
|
||||
url: 'https://example.com/file.zip',
|
||||
filesize: 0
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -99,9 +99,9 @@ router.get('/modpack/:slug/:build?', (req, res) => {
|
||||
router.get('/verify/:key?', (req, res) => {
|
||||
// Key validated
|
||||
res.json({
|
||||
valid: "Key validated.",
|
||||
name: "API KEY",
|
||||
created_at: "A long time ago"
|
||||
valid: 'Key validated.',
|
||||
name: 'API KEY',
|
||||
created_at: 'A long time ago'
|
||||
})
|
||||
|
||||
// Invalid key provided
|
||||
@@ -118,8 +118,8 @@ router.get('/verify/:key?', (req, res) => {
|
||||
/* Invalid API Routes */
|
||||
router.all('*', (req, res) => {
|
||||
res.status(405).json({
|
||||
"code": res.statusCode,
|
||||
"message": "Invalid route."
|
||||
code: res.statusCode,
|
||||
message: 'Invalid route.'
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user