aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorKana <[email protected]>2021-01-21 00:51:43 +0900
committerGitHub <[email protected]>2021-01-21 00:51:43 +0900
commite779706ab7bf0ae9f41864ed4ecd34da24fc003e (patch)
tree2b7646a6d18e3d99d55f5ead102a82870e21f54a /src/api
parentchore: remove console logs (diff)
parentfeat: prevent embeds being nsfw (diff)
downloadhost.fuwn.me-e779706ab7bf0ae9f41864ed4ecd34da24fc003e.tar.xz
host.fuwn.me-e779706ab7bf0ae9f41864ed4ecd34da24fc003e.zip
Merge pull request #254 from WeebDev/feature/ssr
Feature/ssr
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/albums/albumGET.js2
-rw-r--r--src/api/structures/Server.js25
2 files changed, 8 insertions, 19 deletions
diff --git a/src/api/routes/albums/albumGET.js b/src/api/routes/albums/albumGET.js
index 3949fc7..4ac7089 100644
--- a/src/api/routes/albums/albumGET.js
+++ b/src/api/routes/albums/albumGET.js
@@ -25,7 +25,7 @@ class albumGET extends Route {
.select('files.name', 'files.id')
.orderBy('files.id', 'desc');
- const { page, limit = 100 } = req.query;
+ const { page, limit = 50 } = req.query;
if (page && page >= 0) {
files = await files.offset((page - 1) * limit).limit(limit);
diff --git a/src/api/structures/Server.js b/src/api/structures/Server.js
index 446c621..268ba68 100644
--- a/src/api/structures/Server.js
+++ b/src/api/structures/Server.js
@@ -5,6 +5,7 @@ if (!process.env.SERVER_PORT) {
process.exit(0);
}
+const { loadNuxt, build } = require('nuxt');
const express = require('express');
const helmet = require('helmet');
const cors = require('cors');
@@ -80,25 +81,13 @@ class Server {
});
}
- serveNuxt() {
- // Serve the frontend if we are in production mode
- if (process.env.NODE_ENV === 'production') {
- this.server.use(express.static(path.join(__dirname, '../../../dist')));
+ async serveNuxt() {
+ const isProd = process.env.NODE_ENV === 'production';
+ const nuxt = await loadNuxt(isProd ? 'start' : 'dev');
+ this.server.use(nuxt.render);
+ if (!isProd) {
+ build(nuxt);
}
-
- /*
- For vue router to work with express we need this fallback.
- After all the routes are loaded and the static files handled and if the
- user is trying to access a non-mapped route we serve the website instead
- since it has routes of it's own that don't work if accessed directly
- */
- this.server.all('*', (_req, res) => {
- try {
- res.sendFile(path.join(__dirname, '../../../dist/index.html'));
- } catch (error) {
- res.json({ success: false, message: 'Something went wrong' });
- }
- });
}
createJobs() {