This commit is contained in:
Martin McKeaveney 2020-11-12 10:41:49 +00:00
parent 13311ae680
commit 9e190ac1ec
5 changed files with 7 additions and 38 deletions

View File

@ -141,16 +141,13 @@ exports.performLocalFileProcessing = async function(ctx) {
}
}
exports.serveAppNew = async function(ctx) {
exports.serveApp = async function(ctx) {
const App = require("./templates/BudibaseApp.svelte").default
// Need to get app information here
const db = new CouchDB(ctx.params.appId)
const appInfo = await db.get(ctx.params.appId)
console.log("INFO", appInfo)
const { head, html, css } = App.render({
title: appInfo.name,
pageName:
@ -170,33 +167,6 @@ exports.serveAppNew = async function(ctx) {
})
}
exports.serveApp = async function(ctx) {
const mainOrAuth =
ctx.auth.authenticated === AuthTypes.APP ? "main" : "unauthenticated"
// default to homedir
const appPath = resolve(
budibaseAppsDir(),
ctx.params.appId,
"public",
mainOrAuth
)
const appId = ctx.user.appId
if (env.CLOUD) {
const S3_URL = `https://${appId}.app.budi.live/assets/${appId}/${mainOrAuth}/${ctx.file ||
"index.production.html"}`
const response = await fetch(S3_URL)
const body = await response.text()
ctx.body = body
return
}
await send(ctx, ctx.file || "index.html", { root: ctx.devPath || appPath })
}
exports.serveAttachment = async function(ctx) {
const appId = ctx.user.appId
const attachmentsPath = resolve(budibaseAppsDir(), appId, "attachments")

View File

@ -33,6 +33,6 @@ router
.get("/componentlibrary", controller.serveComponentLibrary)
.get("/assets/:file*", controller.serveAppAsset)
.get("/attachments/:file*", controller.serveAttachment)
.get("/:appId/:path*", controller.serveAppNew)
.get("/:appId/:path*", controller.serveApp)
module.exports = router

View File

@ -38,6 +38,6 @@ function replicateLocal() {
})
}
replicateLocal()
// replicateLocal()
module.exports = Pouch

View File

@ -1,6 +1,5 @@
const { ensureDir, constants, copyFile, writeFile } = require("fs-extra")
const { join } = require("../centralPath")
const { convertCssToBundle } = require("./convertCssToFiles")
const { budibaseAppsDir } = require("../budibaseDir")
/**
@ -19,7 +18,7 @@ module.exports = async (appId, pageName, pkg) => {
await ensureDir(pagePath)
await convertCssToBundle(pagePath, pkg)
await buildPageCssBundle(pagePath, pkg)
await buildFrontendAppDefinition(pagePath, pkg)
@ -33,7 +32,7 @@ module.exports = async (appId, pageName, pkg) => {
* @param {Object} pkg - app package information
* @param {"main" | "unauthenticated"} pageName - the pagename of the page we are compiling CSS for.
*/
module.exports.convertCssToBundle = async (publicPagePath, pkg) => {
const buildPageCssBundle = async (publicPagePath, pkg) => {
let cssString = ""
for (let screen of pkg.screens || []) {

View File

@ -31,8 +31,8 @@ const createDevEnvFile = async opts => {
}
)
opts.cookieKey1 = opts.cookieKey1 || uuid.v4()
const hbTemplate = handlebars.compile(template)
const config = hbTemplate.render(opts)
const envTemplate = handlebars.compile(template)
const config = envTemplate(opts)
await writeFile(destConfigFile, config, { flag: "w+" })
}
}