feat: wrote a few more routes
This commit is contained in:
parent
b0ab951a98
commit
beb529e483
|
@ -0,0 +1,10 @@
|
||||||
|
import type { FastifyReply } from 'fastify';
|
||||||
|
import type { RequestWithUser } from '../../../../structures/interfaces';
|
||||||
|
import { getConfig } from '../../../../utils/Util';
|
||||||
|
|
||||||
|
export const middlewares = ['auth', 'admin'];
|
||||||
|
|
||||||
|
export const run = async (req: RequestWithUser, res: FastifyReply) => res.send({
|
||||||
|
message: 'Successfully retrieved config',
|
||||||
|
config: (await getConfig())
|
||||||
|
});
|
|
@ -0,0 +1,27 @@
|
||||||
|
import type { FastifyReply } from 'fastify';
|
||||||
|
import type { RequestWithUser } from '../../../structures/interfaces';
|
||||||
|
import { getConfig } from '../../../utils/Util';
|
||||||
|
|
||||||
|
export const middlewares = ['auth', 'admin'];
|
||||||
|
|
||||||
|
export const run = async (req: RequestWithUser, res: FastifyReply) => {
|
||||||
|
const config = await getConfig();
|
||||||
|
|
||||||
|
return res.send({
|
||||||
|
message: 'Successfully retrieved config',
|
||||||
|
config: {
|
||||||
|
version: process.env.npm_package_version,
|
||||||
|
serviceName: config.serviceName,
|
||||||
|
maxUploadSize: config.maxSize,
|
||||||
|
filenameLength: config.generatedFilenameLength,
|
||||||
|
albumLinkLength: config.generatedAlbumLength,
|
||||||
|
chunkSize: config.chunkSize,
|
||||||
|
publicMode: config.publicMode,
|
||||||
|
userAccounts: config.userAccounts,
|
||||||
|
metaThemeColor: config.metaThemeColor,
|
||||||
|
metaDescription: config.metaDescription,
|
||||||
|
metaKeywords: config.metaKeywords,
|
||||||
|
metaTwitterHandle: config.metaTwitterHandle
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,17 +0,0 @@
|
||||||
const Route = require('../../structures/Route');
|
|
||||||
const Util = require('../../utils/Util');
|
|
||||||
|
|
||||||
class configGET extends Route {
|
|
||||||
constructor() {
|
|
||||||
super('/service/config/all', 'get', { adminOnly: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
run(req, res) {
|
|
||||||
return res.json({
|
|
||||||
message: 'Successfully retrieved config',
|
|
||||||
config: Util.config
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = configGET;
|
|
|
@ -1,30 +0,0 @@
|
||||||
const Route = require('../../structures/Route');
|
|
||||||
const Util = require('../../utils/Util');
|
|
||||||
|
|
||||||
class configGET extends Route {
|
|
||||||
constructor() {
|
|
||||||
super('/service/config', 'get', { bypassAuth: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
run(req, res) {
|
|
||||||
return res.json({
|
|
||||||
message: 'Successfully retrieved config',
|
|
||||||
config: {
|
|
||||||
version: process.env.npm_package_version,
|
|
||||||
serviceName: Util.config.serviceName,
|
|
||||||
maxUploadSize: Util.config.maxSize,
|
|
||||||
filenameLength: Util.config.generatedFilenameLength,
|
|
||||||
albumLinkLength: Util.config.generatedAlbumLength,
|
|
||||||
chunkSize: Util.config.chunkSize,
|
|
||||||
publicMode: Util.config.publicMode,
|
|
||||||
userAccounts: Util.config.userAccounts,
|
|
||||||
metaThemeColor: Util.config.metaThemeColor,
|
|
||||||
metaDescription: Util.config.metaDescription,
|
|
||||||
metaKeywords: Util.config.metaKeywords,
|
|
||||||
metaTwitterHandle: Util.metaTwitterHandle
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = configGET;
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import type { FastifyReply } from 'fastify';
|
||||||
|
import type { RequestWithUser } from '../../../structures/interfaces';
|
||||||
|
|
||||||
|
export const middlewares = ['auth', 'admin'];
|
||||||
|
|
||||||
|
export const run = async (req: RequestWithUser, res: FastifyReply) => {
|
||||||
|
void res.send({
|
||||||
|
message: 'Successfully triggered restart'
|
||||||
|
});
|
||||||
|
process.exit(0);
|
||||||
|
};
|
|
@ -1,14 +0,0 @@
|
||||||
const Route = require('../../structures/Route');
|
|
||||||
|
|
||||||
class restartPOST extends Route {
|
|
||||||
constructor() {
|
|
||||||
super('/service/restart', 'post', { adminOnly: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
run(req, res) {
|
|
||||||
res.json({ message: 'Restarting...' });
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = restartPOST;
|
|
|
@ -1,15 +0,0 @@
|
||||||
const Route = require('../../structures/Route');
|
|
||||||
|
|
||||||
class versionGET extends Route {
|
|
||||||
constructor() {
|
|
||||||
super('/version', 'get', { bypassAuth: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
run(req, res) {
|
|
||||||
return res.json({
|
|
||||||
version: process.env.npm_package_version
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = versionGET;
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
|
|
||||||
|
export const run = async (req: FastifyRequest, res: FastifyReply) => res.send({
|
||||||
|
version: process.env.npm_package_version
|
||||||
|
});
|
Loading…
Reference in New Issue