mirror of
https://github.com/Zandercraft/TechnicFlux.git
synced 2026-10-29 04:39:20 +00:00
StandardJS Format
This commit is contained in:
126
database.js
126
database.js
@@ -1,4 +1,4 @@
|
|||||||
const debug = require('debug')('technicflux:server');
|
const debug = require('debug')('technicflux:server')
|
||||||
const mongoose = require('mongoose')
|
const mongoose = require('mongoose')
|
||||||
const { SchemaTypes } = require('mongoose')
|
const { SchemaTypes } = require('mongoose')
|
||||||
const bcrypt = require('bcryptjs')
|
const bcrypt = require('bcryptjs')
|
||||||
@@ -13,7 +13,7 @@ const userSchema = new Schema({
|
|||||||
display_name: String,
|
display_name: String,
|
||||||
password: String,
|
password: String,
|
||||||
created_on: Date,
|
created_on: Date,
|
||||||
login_history: [{timestamp: Date, userAgent: String}]
|
login_history: [{ timestamp: Date, userAgent: String }]
|
||||||
})
|
})
|
||||||
|
|
||||||
const modpackSchema = new Schema({
|
const modpackSchema = new Schema({
|
||||||
@@ -23,8 +23,8 @@ const modpackSchema = new Schema({
|
|||||||
recommended: String,
|
recommended: String,
|
||||||
latest: String,
|
latest: String,
|
||||||
builds: [{ type: SchemaTypes.ObjectId, ref: 'technicflux_builds' }],
|
builds: [{ type: SchemaTypes.ObjectId, ref: 'technicflux_builds' }],
|
||||||
owners: [{ type:SchemaTypes.ObjectId, ref: 'technicflux_users' }],
|
owners: [{ type: SchemaTypes.ObjectId, ref: 'technicflux_users' }],
|
||||||
contributors: [{ type:SchemaTypes.ObjectId, ref: 'technicflux_users' }]
|
contributors: [{ type: SchemaTypes.ObjectId, ref: 'technicflux_users' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
const modSchema = new Schema({
|
const modSchema = new Schema({
|
||||||
@@ -57,9 +57,9 @@ const Build = mongoose.model('technicflux_builds', buildSchema)
|
|||||||
// --- Functions ---
|
// --- Functions ---
|
||||||
|
|
||||||
exports.connectToDB = (connectionString) => {
|
exports.connectToDB = (connectionString) => {
|
||||||
debug("Connecting to MongoDB database...")
|
debug('Connecting to MongoDB database...')
|
||||||
mongoose.connect(connectionString)
|
mongoose.connect(connectionString)
|
||||||
debug("Connected to database.")
|
debug('Connected to database.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- User-Related Functions ---
|
// --- User-Related Functions ---
|
||||||
@@ -67,14 +67,14 @@ exports.connectToDB = (connectionString) => {
|
|||||||
/*
|
/*
|
||||||
* Creates a new user with the given information.
|
* Creates a new user with the given information.
|
||||||
*/
|
*/
|
||||||
exports.createUser = (u_username, u_display_name, u_password) => {
|
exports.createUser = (uUsername, uDisplayName, uPassword) => {
|
||||||
// Encrypt the password using bcrypt and save user
|
// Encrypt the password using bcrypt and save user
|
||||||
return bcrypt.genSalt(10).then((Salt) => {
|
return bcrypt.genSalt(10).then((Salt) => {
|
||||||
return bcrypt.hash(u_password, Salt).then((hash) => {
|
return bcrypt.hash(uPassword, Salt).then((hash) => {
|
||||||
// Create a user object
|
// Create a user object
|
||||||
const newUser = new User({
|
const newUser = new User({
|
||||||
username: u_username,
|
username: uUsername,
|
||||||
display_name: u_display_name,
|
display_name: uDisplayName,
|
||||||
password: hash
|
password: hash
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -101,9 +101,9 @@ exports.createUser = (u_username, u_display_name, u_password) => {
|
|||||||
/*
|
/*
|
||||||
* Gets the user with the provided id.
|
* Gets the user with the provided id.
|
||||||
*/
|
*/
|
||||||
exports.getUserById = (u_Id) => {
|
exports.getUserById = (uId) => {
|
||||||
// Fetch information about the user with the given id
|
// Fetch information about the user with the given id
|
||||||
return User.findOne({ _id: u_Id }).exec().then((user) => {
|
return User.findOne({ _id: uId }).exec().then((user) => {
|
||||||
// User found.
|
// User found.
|
||||||
return user
|
return user
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
@@ -116,9 +116,9 @@ exports.getUserById = (u_Id) => {
|
|||||||
/*
|
/*
|
||||||
* Gets the user with the provided email.
|
* Gets the user with the provided email.
|
||||||
*/
|
*/
|
||||||
exports.getUserByUsername = (u_username) => {
|
exports.getUserByUsername = (uUsername) => {
|
||||||
// Fetch information about the user with the given username
|
// Fetch information about the user with the given username
|
||||||
return User.findOne({ username: u_username }).exec().then((user) => {
|
return User.findOne({ username: uUsername }).exec().then((user) => {
|
||||||
// User found.
|
// User found.
|
||||||
return user
|
return user
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
@@ -146,22 +146,22 @@ exports.getAllUsers = () => {
|
|||||||
/*
|
/*
|
||||||
* Checks if the corresponding password matches that of the provided username.
|
* Checks if the corresponding password matches that of the provided username.
|
||||||
*/
|
*/
|
||||||
exports.authUser = (u_username, u_password, log_history = false, u_agent="Unknown") => {
|
exports.authUser = (uUsername, uPassword, logHistory = false, uAgent = 'Unknown') => {
|
||||||
// Fetch information about the user with the given username
|
// Fetch information about the user with the given username
|
||||||
return User.findOne({ username: u_username }).exec().then((user) => {
|
return User.findOne({ username: uUsername }).exec().then((user) => {
|
||||||
// User found. Check password.
|
// User found. Check password.
|
||||||
return bcrypt.compare(u_password, user.password).then((isMatch) => {
|
return bcrypt.compare(uPassword, user.password).then((isMatch) => {
|
||||||
// Check if it is a match
|
// Check if it is a match
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
// Update the user's login history.
|
// Update the user's login history.
|
||||||
if (log_history) {
|
if (logHistory) {
|
||||||
let newLogin = {timestamp: new Date(), userAgent: String(u_agent)}
|
const newLogin = { timestamp: new Date(), userAgent: String(uAgent) }
|
||||||
|
|
||||||
// Add the new login to the user's login history
|
// Add the new login to the user's login history
|
||||||
return User.updateOne(
|
return User.updateOne(
|
||||||
{ username: u_username },
|
{ username: uUsername },
|
||||||
{ $push: {login_history: newLogin} }
|
{ $push: { login_history: newLogin } }
|
||||||
).exec().then(()=>{
|
).exec().then(() => {
|
||||||
// Auth was successful and login history updated.
|
// Auth was successful and login history updated.
|
||||||
user.login_history.push(newLogin)
|
user.login_history.push(newLogin)
|
||||||
return [true, user]
|
return [true, user]
|
||||||
@@ -175,7 +175,6 @@ exports.authUser = (u_username, u_password, log_history = false, u_agent="Unknow
|
|||||||
// Auth was successful. Return user without logging to user's history.
|
// Auth was successful. Return user without logging to user's history.
|
||||||
return [true, user]
|
return [true, user]
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// User's authentication was invalid.
|
// User's authentication was invalid.
|
||||||
return [false, undefined]
|
return [false, undefined]
|
||||||
@@ -191,11 +190,11 @@ exports.authUser = (u_username, u_password, log_history = false, u_agent="Unknow
|
|||||||
/*
|
/*
|
||||||
* Updates the user with the given username.
|
* Updates the user with the given username.
|
||||||
*/
|
*/
|
||||||
exports.updateUser = (u_username, object) => {
|
exports.updateUser = (uUsername, object) => {
|
||||||
return bcrypt.genSalt(10).then((Salt) => {
|
return bcrypt.genSalt(10).then((Salt) => {
|
||||||
return bcrypt.hash(object.password, Salt).then((hash) => {
|
return bcrypt.hash(object.password, Salt).then((hash) => {
|
||||||
if (object.password.length > 0) {
|
if (object.password.length > 0) {
|
||||||
object.password = hash;
|
object.password = hash
|
||||||
} else {
|
} else {
|
||||||
object.password = object.old_password
|
object.password = object.old_password
|
||||||
}
|
}
|
||||||
@@ -203,7 +202,7 @@ exports.updateUser = (u_username, object) => {
|
|||||||
|
|
||||||
// Update User
|
// Update User
|
||||||
return User.updateOne(
|
return User.updateOne(
|
||||||
{ username: u_username },
|
{ username: uUsername },
|
||||||
{ $set: object }
|
{ $set: object }
|
||||||
).exec().then(() => {
|
).exec().then(() => {
|
||||||
// Updated user successfully
|
// Updated user successfully
|
||||||
@@ -226,12 +225,12 @@ exports.updateUser = (u_username, object) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- Modpack-Related Functions ---
|
// --- Modpack-Related Functions ---
|
||||||
exports.createModpack = (m_slug, m_display_name, m_owner) => {
|
exports.createModpack = (mSlug, mDisplayName, mOwner) => {
|
||||||
// Create a modpack object
|
// Create a modpack object
|
||||||
const newModpack = new Modpack({
|
const newModpack = new Modpack({
|
||||||
name: m_slug,
|
name: mSlug,
|
||||||
display_name: m_display_name,
|
display_name: mDisplayName,
|
||||||
owners: [m_owner]
|
owners: [mOwner]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Commit it to the database
|
// Commit it to the database
|
||||||
@@ -246,8 +245,8 @@ exports.createModpack = (m_slug, m_display_name, m_owner) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getModpackBySlug = (m_slug) => {
|
exports.getModpackBySlug = (mSlug) => {
|
||||||
return Modpack.findOne({ name: m_slug }).populate('owners').populate('collaborators').exec().then((modpack) => {
|
return Modpack.findOne({ name: mSlug }).populate('owners').populate('collaborators').exec().then((modpack) => {
|
||||||
// Modpack found
|
// Modpack found
|
||||||
return modpack
|
return modpack
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
@@ -257,8 +256,8 @@ exports.getModpackBySlug = (m_slug) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getModpacksByOwner = (m_owner) => {
|
exports.getModpacksByOwner = (mOwner) => {
|
||||||
return Modpack.find({ owners: m_owner }).populate('owners').populate('collaborators').exec().then((modpacks) => {
|
return Modpack.find({ owners: mOwner }).populate('owners').populate('collaborators').exec().then((modpacks) => {
|
||||||
// Modpacks found.
|
// Modpacks found.
|
||||||
return modpacks
|
return modpacks
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
@@ -268,8 +267,8 @@ exports.getModpacksByOwner = (m_owner) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getModpacksByCollaborator = (m_collaborator) => {
|
exports.getModpacksByCollaborator = (mCollaborator) => {
|
||||||
return Modpack.find({ collaborators: m_collaborator }).populate('owners').populate('collaborators').exec().then((modpacks) => {
|
return Modpack.find({ collaborators: mCollaborator }).populate('owners').populate('collaborators').exec().then((modpacks) => {
|
||||||
// Modpacks found.
|
// Modpacks found.
|
||||||
return modpacks
|
return modpacks
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
@@ -291,72 +290,72 @@ exports.getAllModpacks = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.updateModpack = (m_slug, m_object) => {
|
exports.updateModpack = (mSlug, mObject) => {
|
||||||
return Modpack.updateOne(
|
return Modpack.updateOne(
|
||||||
{ name: m_slug },
|
{ name: mSlug },
|
||||||
{ $set: m_object }
|
{ $set: mObject }
|
||||||
).exec().then(() => {
|
).exec().then(() => {
|
||||||
// Successfully updated the modpack
|
// Successfully updated the modpack
|
||||||
return true
|
return true
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// Failed to update the modpack
|
// Failed to update the modpack
|
||||||
debug(`ERROR (DB): Failed to update modpack '${m_slug}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to update modpack '${mSlug}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.deleteModpack = (m_slug) => {
|
exports.deleteModpack = (mSlug) => {
|
||||||
return Modpack.deleteOne({ name: m_slug }).exec().then(() => {
|
return Modpack.deleteOne({ name: mSlug }).exec().then(() => {
|
||||||
// Successfully deleted this modpack
|
// Successfully deleted this modpack
|
||||||
return true
|
return true
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// Failed to delete the modpack
|
// Failed to delete the modpack
|
||||||
debug(`ERROR (DB): Failed to delete modpack '${m_slug}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to delete modpack '${mSlug}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Mod-Related Functions ---
|
// --- Mod-Related Functions ---
|
||||||
exports.getModBySlug = (m_slug) => {
|
exports.getModBySlug = (mSlug) => {
|
||||||
return Mod.findOne({ name: m_slug }).exec().then((mod) => {
|
return Mod.findOne({ name: mSlug }).exec().then((mod) => {
|
||||||
// Mod found
|
// Mod found
|
||||||
return mod
|
return mod
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// No mod found with this slug
|
// No mod found with this slug
|
||||||
debug(`ERROR (DB): Failed to find a mod with this slug because of: ${reason}`)
|
debug(`ERROR (DB): Failed to find a mod with slug '${mSlug}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getModsByType = (m_type) => {
|
exports.getModsByType = (mType) => {
|
||||||
return Mod.find({ type: m_type }).exec().then((mods) => {
|
return Mod.find({ type: mType }).exec().then((mods) => {
|
||||||
// Mods found
|
// Mods found
|
||||||
return mods
|
return mods
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// No mods found with this modloader
|
// No mods found with this modloader
|
||||||
debug(`ERROR (DB): Failed to find a mod with modloader '${m_type}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to find a mod with modloader '${mType}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getModsByMinecraftVersion = (m_version) => {
|
exports.getModsByMinecraftVersion = (mVersion) => {
|
||||||
return Mod.find({ mc_version: m_version }).exec().then((mods) => {
|
return Mod.find({ mc_version: mVersion }).exec().then((mods) => {
|
||||||
// Mods found
|
// Mods found
|
||||||
return mods
|
return mods
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// No mods found with this Minecraft version.
|
// No mods found with this Minecraft version.
|
||||||
debug(`ERROR (DB): Failed to find a mod with Minecraft version '${m_version}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to find a mod with Minecraft version '${mVersion}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getModsByMinecraftAndLoaderVersion = (m_version, m_type) => {
|
exports.getModsByMinecraftAndLoaderVersion = (mVersion, mType) => {
|
||||||
return Mod.find({ mc_version: m_version, type: m_type }).exec().then((mods) => {
|
return Mod.find({ mc_version: mVersion, type: mType }).exec().then((mods) => {
|
||||||
// Mods found
|
// Mods found
|
||||||
return mods
|
return mods
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// No mods found with this Minecraft and modloader version.
|
// No mods found with this Minecraft and modloader version.
|
||||||
debug(`ERROR (DB): Failed to find a mod with Minecraft version '${m_version}' and modloader version '${m_type}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to find a mod with Minecraft version '${mVersion}' and modloader version '${mType}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -372,34 +371,31 @@ exports.getAllMods = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.updateMod = (m_slug, m_object) => {
|
exports.updateMod = (mSlug, mObject) => {
|
||||||
return Mod.updateOne(
|
return Mod.updateOne(
|
||||||
{ name: m_slug },
|
{ name: mSlug },
|
||||||
{ $set: m_object }
|
{ $set: mObject }
|
||||||
).exec().then(() => {
|
).exec().then(() => {
|
||||||
// Successfully updated the modpack
|
// Successfully updated the modpack
|
||||||
return true
|
return true
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// Failed to update the modpack
|
// Failed to update the modpack
|
||||||
debug(`ERROR (DB): Failed to update modpack '${m_slug}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to update modpack '${mSlug}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.deleteModpack = (m_slug) => {
|
exports.deleteModpack = (mSlug) => {
|
||||||
return Modpack.deleteOne({ name: m_slug }).exec().then(() => {
|
return Modpack.deleteOne({ name: mSlug }).exec().then(() => {
|
||||||
// Successfully deleted this modpack
|
// Successfully deleted this modpack
|
||||||
return true
|
return true
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
// Failed to delete the modpack
|
// Failed to delete the modpack
|
||||||
debug(`ERROR (DB): Failed to delete modpack '${m_slug}' because of: ${reason}`)
|
debug(`ERROR (DB): Failed to delete modpack '${mSlug}' because of: ${reason}`)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- Modloader-Related Functions ---
|
// --- Modloader-Related Functions ---
|
||||||
|
|
||||||
|
|
||||||
// --- Build-Related Functions ---
|
// --- Build-Related Functions ---
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const pckg = require('../package.json')
|
const pckg = require('../package.json')
|
||||||
const branchName = require('current-git-branch')();
|
const branchName = require('current-git-branch')()
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
"api": pckg.prettyName,
|
api: pckg.prettyName,
|
||||||
"version": pckg.version,
|
version: pckg.version,
|
||||||
"stream": branchName
|
stream: branchName
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/mod/:modname/:modversion?', (req, res) => {
|
router.get('/mod/:modname/:modversion?', (req, res) => {
|
||||||
// Found mod
|
// Found mod
|
||||||
res.json({
|
res.json({
|
||||||
"id": 0,
|
id: 0,
|
||||||
"name": "example",
|
name: 'example',
|
||||||
"pretty_name": "Example",
|
pretty_name: 'Example',
|
||||||
"author": "ExampleAuthor",
|
author: 'ExampleAuthor',
|
||||||
"description": "This is the description",
|
description: 'This is the description',
|
||||||
"link": "https://example.com/",
|
link: 'https://example.com/',
|
||||||
"versions": [
|
versions: [
|
||||||
"1.20.1-0.0.1",
|
'1.20.1-0.0.1',
|
||||||
"1.20.1-0.0.2"
|
'1.20.1-0.0.2'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Found mod version
|
// Found mod version
|
||||||
res.json({
|
res.json({
|
||||||
"id": 0,
|
id: 0,
|
||||||
"md5": "51c1305b56249804926e38fcf3e46640",
|
md5: '51c1305b56249804926e38fcf3e46640',
|
||||||
"filesize": 0,
|
filesize: 0,
|
||||||
"url": "https://example.com/file.zip",
|
url: 'https://example.com/file.zip'
|
||||||
})
|
})
|
||||||
|
|
||||||
// Version Not Found
|
// Version Not Found
|
||||||
@@ -48,39 +48,39 @@ router.get('/mod/:modname/:modversion?', (req, res) => {
|
|||||||
router.get('/modpack', (req, res) => {
|
router.get('/modpack', (req, res) => {
|
||||||
// Modpack Index
|
// Modpack Index
|
||||||
res.json({
|
res.json({
|
||||||
"modpacks": {
|
modpacks: {
|
||||||
"slug": "Example Modpack Pretty Name"
|
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) => {
|
router.get('/modpack/:slug/:build?', (req, res) => {
|
||||||
// With Slug
|
// With Slug
|
||||||
res.json({
|
res.json({
|
||||||
"name": "examplepack",
|
name: 'examplepack',
|
||||||
"display_name": "Example Pack",
|
display_name: 'Example Pack',
|
||||||
"recommended": "0.0.1",
|
recommended: '0.0.1',
|
||||||
"latest": "0.0.2",
|
latest: '0.0.2',
|
||||||
"builds": [
|
builds: [
|
||||||
"0.0.1",
|
'0.0.1',
|
||||||
"0.0.2"
|
'0.0.2'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Build found
|
// Build found
|
||||||
res.json({
|
res.json({
|
||||||
"minecraft": "1.20.1",
|
minecraft: '1.20.1',
|
||||||
"forge": null,
|
forge: null,
|
||||||
"java": 17,
|
java: 17,
|
||||||
"memory": 2048,
|
memory: 2048,
|
||||||
"mods": [
|
mods: [
|
||||||
{
|
{
|
||||||
"name": "examplemod",
|
name: 'examplemod',
|
||||||
"version": "0.0.1",
|
version: '0.0.1',
|
||||||
"md5": "51c1305b56249804926e38fcf3e46640",
|
md5: '51c1305b56249804926e38fcf3e46640',
|
||||||
"url": "https://example.com/file.zip",
|
url: 'https://example.com/file.zip',
|
||||||
"filesize": 0
|
filesize: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -99,9 +99,9 @@ router.get('/modpack/:slug/:build?', (req, res) => {
|
|||||||
router.get('/verify/:key?', (req, res) => {
|
router.get('/verify/:key?', (req, res) => {
|
||||||
// Key validated
|
// Key validated
|
||||||
res.json({
|
res.json({
|
||||||
valid: "Key validated.",
|
valid: 'Key validated.',
|
||||||
name: "API KEY",
|
name: 'API KEY',
|
||||||
created_at: "A long time ago"
|
created_at: 'A long time ago'
|
||||||
})
|
})
|
||||||
|
|
||||||
// Invalid key provided
|
// Invalid key provided
|
||||||
@@ -118,8 +118,8 @@ router.get('/verify/:key?', (req, res) => {
|
|||||||
/* Invalid API Routes */
|
/* Invalid API Routes */
|
||||||
router.all('*', (req, res) => {
|
router.all('*', (req, res) => {
|
||||||
res.status(405).json({
|
res.status(405).json({
|
||||||
"code": res.statusCode,
|
code: res.statusCode,
|
||||||
"message": "Invalid route."
|
message: 'Invalid route.'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user