mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Use memory for saving files on production.
This commit is contained in:
parent
e881a383b3
commit
58be6ab56d
1 changed files with 40 additions and 51 deletions
|
@ -3,7 +3,6 @@
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
const eejs = require('../../eejs')
|
const eejs = require('../../eejs')
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import os from 'node:os';
|
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
const toolbar = require('../../utils/toolbar');
|
const toolbar = require('../../utils/toolbar');
|
||||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||||
|
@ -90,7 +89,7 @@ const convertTypescript = (content: string) => {
|
||||||
const outputRaw = buildSync({
|
const outputRaw = buildSync({
|
||||||
stdin: {
|
stdin: {
|
||||||
contents: content,
|
contents: content,
|
||||||
resolveDir: settings.root,
|
resolveDir: path.join(settings.root, 'var','js'),
|
||||||
loader: 'js'
|
loader: 'js'
|
||||||
},
|
},
|
||||||
alias:{
|
alias:{
|
||||||
|
@ -223,7 +222,7 @@ const convertTypescriptWatched = (content: string, cb: (output:string, hash: str
|
||||||
build({
|
build({
|
||||||
stdin: {
|
stdin: {
|
||||||
contents: content,
|
contents: content,
|
||||||
resolveDir: settings.root,
|
resolveDir: path.join(settings.root, 'var','js'),
|
||||||
loader: 'js'
|
loader: 'js'
|
||||||
},
|
},
|
||||||
alias:{
|
alias:{
|
||||||
|
@ -245,7 +244,7 @@ const convertTypescriptWatched = (content: string, cb: (output:string, hash: str
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.expressCreateServer = async (hookName: string, args: ArgsExpressType, cb: Function) => {
|
exports.expressCreateServer = async (_hookName: string, args: ArgsExpressType, cb: Function) => {
|
||||||
const padString = eejs.require('ep_etherpad-lite/templates/padBootstrap.js', {
|
const padString = eejs.require('ep_etherpad-lite/templates/padBootstrap.js', {
|
||||||
pluginModules: (() => {
|
pluginModules: (() => {
|
||||||
const pluginModules = new Set();
|
const pluginModules = new Set();
|
||||||
|
@ -277,8 +276,10 @@ exports.expressCreateServer = async (hookName: string, args: ArgsExpressType, cb
|
||||||
settings,
|
settings,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Create a temporary directory to store runtime-built JS files
|
|
||||||
const outdir = path.join(os.tmpdir(), 'js');
|
|
||||||
|
const outdir = path.join(settings.root, 'var','js')
|
||||||
|
// Create the outdir if it doesn't exist
|
||||||
if (!fs.existsSync(outdir)) {
|
if (!fs.existsSync(outdir)) {
|
||||||
fs.mkdirSync(outdir);
|
fs.mkdirSync(outdir);
|
||||||
}
|
}
|
||||||
|
@ -294,32 +295,20 @@ exports.expressCreateServer = async (hookName: string, args: ArgsExpressType, cb
|
||||||
fileNamePad = `padbootstrap-${padSliderWrite.hash}.min.js`
|
fileNamePad = `padbootstrap-${padSliderWrite.hash}.min.js`
|
||||||
fileNameTimeSlider = `timeSliderBootstrap-${timeSliderWrite.hash}.min.js`
|
fileNameTimeSlider = `timeSliderBootstrap-${timeSliderWrite.hash}.min.js`
|
||||||
fileNameIndex = `indexBootstrap-${indexWrite.hash}.min.js`
|
fileNameIndex = `indexBootstrap-${indexWrite.hash}.min.js`
|
||||||
const pathNamePad = path.join(outdir, fileNamePad)
|
|
||||||
const pathNameTimeSlider = path.join(outdir, fileNameTimeSlider)
|
|
||||||
const pathNameIndex = path.join(outdir, 'index.js')
|
|
||||||
|
|
||||||
if (!fs.existsSync(pathNamePad)) {
|
args.app.get("/"+fileNamePad, (_req, res) => {
|
||||||
fs.writeFileSync(pathNamePad, padSliderWrite.output);
|
res.header('Content-Type', 'application/javascript');
|
||||||
}
|
res.send(padSliderWrite.output)
|
||||||
|
|
||||||
if (!fs.existsSync(pathNameIndex)) {
|
|
||||||
fs.writeFileSync(pathNameIndex, indexWrite.output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fs.existsSync(pathNameTimeSlider)) {
|
|
||||||
fs.writeFileSync(pathNameTimeSlider,timeSliderWrite.output)
|
|
||||||
}
|
|
||||||
|
|
||||||
args.app.get("/"+fileNamePad, (req: any, res: any) => {
|
|
||||||
res.sendFile(pathNamePad)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
args.app.get("/"+fileNameIndex, (req: any, res: any) => {
|
args.app.get("/"+fileNameIndex, (_req, res) => {
|
||||||
res.sendFile(pathNameIndex)
|
res.header('Content-Type', 'application/javascript');
|
||||||
|
res.send(indexWrite.output)
|
||||||
})
|
})
|
||||||
|
|
||||||
args.app.get("/"+fileNameTimeSlider, (req: any, res: any) => {
|
args.app.get("/"+fileNameTimeSlider, (_req, res) => {
|
||||||
res.sendFile(pathNameTimeSlider)
|
res.header('Content-Type', 'application/javascript');
|
||||||
|
res.send(timeSliderWrite.output)
|
||||||
})
|
})
|
||||||
|
|
||||||
// serve index.html under /
|
// serve index.html under /
|
||||||
|
|
Loading…
Reference in a new issue