Integrate settings UI

This commit is contained in:
Isaac 2022-09-06 20:30:28 +01:00
parent 26b94e3921
commit c101562dcc
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
2 changed files with 39 additions and 14 deletions

View File

@ -41,29 +41,30 @@
"@fastify/cors": "^8.1.0", "@fastify/cors": "^8.1.0",
"@fastify/jwt": "^5.0.1", "@fastify/jwt": "^5.0.1",
"@fastify/oauth2": "^5.1.0", "@fastify/oauth2": "^5.1.0",
"@prisma/client": "^4.1.1", "@prisma/client": "^4.3.1",
"boolean": "^3.2.0", "boolean": "^3.2.0",
"cryptr": "^6.0.3", "cryptr": "^6.0.3",
"discord.js": "^14.1.2", "discord.js": "^14.3.0",
"dotenv": "^16.0.1", "dotenv": "^16.0.2",
"fastify": "^4.3.0", "express": "^4.18.1",
"fastify": "^4.5.3",
"figlet": "^1.5.2", "figlet": "^1.5.2",
"fs-extra": "^10.1.0", "fs-extra": "^10.1.0",
"keyv": "^4.3.3", "keyv": "^4.5.0",
"leeks.js": "^0.2.4", "leeks.js": "^0.2.4",
"leekslazylogger": "^4.1.7", "leekslazylogger": "^4.1.7",
"ms": "^2.1.3", "ms": "^2.1.3",
"node-dir": "^0.1.17", "node-dir": "^0.1.17",
"node-emoji": "^1.11.0", "node-emoji": "^1.11.0",
"object-diffy": "^1.0.4", "object-diffy": "^1.0.4",
"prisma": "^4.1.1", "prisma": "^4.3.1",
"semver": "^7.3.7", "semver": "^7.3.7",
"terminal-link": "^2.1.1", "terminal-link": "^2.1.1",
"yaml": "^1.10.2" "yaml": "^1.10.2"
}, },
"devDependencies": { "devDependencies": {
"all-contributors-cli": "^6.20.0", "all-contributors-cli": "^6.20.0",
"eslint": "^8.21.0", "eslint": "^8.23.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-unused-imports": "^2.0.0",
"nodemon": "^2.0.19" "nodemon": "^2.0.19"
} }

View File

@ -5,7 +5,11 @@ const { short } = require('leeks.js');
const { join } = require('path'); const { join } = require('path');
const { files } = require('node-dir'); const { files } = require('node-dir');
module.exports = client => { process.env.PUBLIC_HOST = process.env.HTTP_EXTERNAL;
async function build(client) {
// await fastify.register(require('@fastify/express'));
// cors plugin // cors plugin
fastify.register(require('@fastify/cors'), { fastify.register(require('@fastify/cors'), {
credentials: true, credentials: true,
@ -125,7 +129,6 @@ module.exports = client => {
// route loading // route loading
const dir = join(__dirname, '/routes'); const dir = join(__dirname, '/routes');
files(dir, { files(dir, {
exclude: /^\./, exclude: /^\./,
match: /.js$/, match: /.js$/,
@ -138,7 +141,6 @@ module.exports = client => {
.replace(/\[(\w+)\]/gi, ':$1') // convert [] to : .replace(/\[(\w+)\]/gi, ':$1') // convert [] to :
.replace('/index', '') || '/'; // remove index .replace('/index', '') || '/'; // remove index
const route = require(file); const route = require(file);
Object.keys(route).forEach(method => fastify.route({ Object.keys(route).forEach(method => fastify.route({
config: { client }, config: { client },
method: method.toUpperCase(), method: method.toUpperCase(),
@ -147,9 +149,31 @@ module.exports = client => {
})); // register route })); // register route
}); });
// const { handler: app } = await import('@discord-tickets/settings/build/handler.js');
// fastify.use('/*', app);
// fastify.use(app);
return fastify;
}
module.exports = async client => {
build(client)
.then(fastify => {
// start server // start server
fastify.listen({ port: process.env.HTTP_BIND }, (err, addr) => { fastify.listen({ port: process.env.HTTP_BIND }, (err, addr) => {
if (err) client.log.error.http(err); if (err) client.log.error.http(err);
else client.log.success.http(`Listening at ${addr}`); else client.log.success.http(`Listening at ${addr}`);
}); });
})
.catch(client.log.error.http);
const express = require('express')();
const { handler } = await import('@discord-tickets/settings/build/handler.js');
express.get('/api/client', (req, res) => {
res.end('ok');
});
express.use(handler);
express.listen(3000, () => {
console.log('listening on port 3000');
});
}; };