- 웹훅 URL을 https://admin.youtooplay.com/webhook로 변경 - Nginx 리버스 프록시 설정 파일 추가 - 배포 가이드 업데이트
This commit is contained in:
72
.output/server/chunks/routes/api/auth/login.post.mjs
Normal file
72
.output/server/chunks/routes/api/auth/login.post.mjs
Normal file
@@ -0,0 +1,72 @@
|
||||
import { d as defineEventHandler, r as readBody, c as createError } from '../../../nitro/nitro.mjs';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:events';
|
||||
import 'node:buffer';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:crypto';
|
||||
import 'node:url';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const login_post = defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
const { user_id, password } = body;
|
||||
console.log("\uB85C\uADF8\uC778 \uC694\uCCAD:", { user_id, password: password ? "***" : "undefined" });
|
||||
if (!user_id || !password) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "\uC544\uC774\uB514\uC640 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694."
|
||||
});
|
||||
}
|
||||
try {
|
||||
const user = await prisma.members.findUnique({
|
||||
where: { user_id }
|
||||
});
|
||||
console.log("\uC0AC\uC6A9\uC790 \uC870\uD68C \uACB0\uACFC:", user);
|
||||
if (!user) {
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uC544\uC774\uB514\uC785\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
if (user.password !== password) {
|
||||
console.log("\uBE44\uBC00\uBC88\uD638 \uBD88\uC77C\uCE58:", {
|
||||
\uC785\uB825\uB41C\uBE44\uBC00\uBC88\uD638: password,
|
||||
\uC800\uC7A5\uB41C\uBE44\uBC00\uBC88\uD638: user.password
|
||||
});
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
console.log("\uB85C\uADF8\uC778 \uC131\uACF5:", { user_id: user.user_id, name: user.name });
|
||||
const token = jwt.sign(
|
||||
{ id: user.id, user_id: user.user_id, name: user.name, role_level: user.role_level },
|
||||
"your-secret-key",
|
||||
// 실제 서비스에서는 환경 변수로 관리
|
||||
{ expiresIn: "24h" }
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "\uB85C\uADF8\uC778 \uC131\uACF5",
|
||||
token,
|
||||
user: {
|
||||
id: user.id,
|
||||
user_id: user.user_id,
|
||||
name: user.name,
|
||||
role_level: user.role_level
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("\uB85C\uADF8\uC778 \uC624\uB958:", error);
|
||||
throw createError({
|
||||
statusCode: error.statusCode || 500,
|
||||
statusMessage: error.statusMessage || "\uB85C\uADF8\uC778 \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export { login_post as default };
|
||||
66
.output/server/chunks/routes/api/auth/register.post.mjs
Normal file
66
.output/server/chunks/routes/api/auth/register.post.mjs
Normal file
@@ -0,0 +1,66 @@
|
||||
import { d as defineEventHandler, r as readBody, c as createError } from '../../../nitro/nitro.mjs';
|
||||
import { Pool } from 'pg';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:events';
|
||||
import 'node:buffer';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:crypto';
|
||||
import 'node:url';
|
||||
|
||||
const pool = new Pool({
|
||||
user: "musicuser",
|
||||
host: "localhost",
|
||||
database: "musicdb",
|
||||
password: "Tjqjqhdks$321",
|
||||
port: 5432
|
||||
});
|
||||
const register_post = defineEventHandler(async (event) => {
|
||||
try {
|
||||
const body = await readBody(event);
|
||||
const { user_id, password, name, role_level } = body;
|
||||
if (!user_id || !password || !name || !role_level) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "\uBAA8\uB4E0 \uD544\uB4DC\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694."
|
||||
});
|
||||
}
|
||||
if (role_level < 1 || role_level > 3) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "\uAD8C\uD55C \uB4F1\uAE09\uC740 1~3 \uC0AC\uC774\uC5EC\uC57C \uD569\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
const existingUser = await pool.query(
|
||||
"SELECT user_id FROM members WHERE user_id = $1",
|
||||
[user_id]
|
||||
);
|
||||
if (existingUser.rows.length > 0) {
|
||||
throw createError({
|
||||
statusCode: 409,
|
||||
statusMessage: "\uC774\uBBF8 \uC874\uC7AC\uD558\uB294 \uC544\uC774\uB514\uC785\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
const result = await pool.query(
|
||||
"INSERT INTO members (user_id, password, name, role_level) VALUES ($1, $2, $3, $4) RETURNING *",
|
||||
[user_id, password, name, role_level]
|
||||
);
|
||||
const newUser = result.rows[0];
|
||||
return {
|
||||
success: true,
|
||||
message: "\uD68C\uC6D0\uAC00\uC785\uC774 \uC644\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",
|
||||
user: {
|
||||
id: newUser.id,
|
||||
user_id: newUser.user_id,
|
||||
name: newUser.name,
|
||||
role_level: newUser.role_level
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Register error:", error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
export { register_post as default };
|
||||
41
.output/server/chunks/routes/api/auth/verify.get.mjs
Normal file
41
.output/server/chunks/routes/api/auth/verify.get.mjs
Normal file
@@ -0,0 +1,41 @@
|
||||
import { d as defineEventHandler, g as getCookie, a as getHeader, c as createError } from '../../../nitro/nitro.mjs';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:events';
|
||||
import 'node:buffer';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:crypto';
|
||||
import 'node:url';
|
||||
|
||||
const verify_get = defineEventHandler(async (event) => {
|
||||
var _a;
|
||||
try {
|
||||
const token = getCookie(event, "auth-token") || ((_a = getHeader(event, "authorization")) == null ? void 0 : _a.replace("Bearer ", ""));
|
||||
if (!token) {
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "\uC778\uC99D \uD1A0\uD070\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
const decoded = jwt.verify(token, "your-secret-key");
|
||||
return {
|
||||
success: true,
|
||||
user: {
|
||||
id: decoded.id,
|
||||
user_id: decoded.user_id,
|
||||
name: decoded.name,
|
||||
role_level: decoded.role_level
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Token verification error:", error);
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uD1A0\uD070\uC785\uB2C8\uB2E4."
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export { verify_get as default };
|
||||
390
.output/server/chunks/routes/renderer.mjs
Normal file
390
.output/server/chunks/routes/renderer.mjs
Normal file
@@ -0,0 +1,390 @@
|
||||
import process from 'node:process';globalThis._importMeta_=globalThis._importMeta_||{url:"file:///_entry.js",env:process.env};import { getRequestDependencies, getPreloadLinks, getPrefetchLinks, createRenderer } from 'vue-bundle-renderer/runtime';
|
||||
import { j as joinRelativeURL, u as useRuntimeConfig, b as defineRenderHandler, e as getQuery, c as createError, f as getRouteRules, h as useNitroApp, i as getResponseStatusText, k as getResponseStatus } from '../nitro/nitro.mjs';
|
||||
import { stringify, uneval } from 'devalue';
|
||||
import { renderToString } from 'vue/server-renderer';
|
||||
import { propsToString, renderSSRHead } from '@unhead/ssr';
|
||||
import { createServerHead as createServerHead$1, CapoPlugin } from 'unhead';
|
||||
import { unref, version } from 'vue';
|
||||
import { defineHeadPlugin } from '@unhead/shared';
|
||||
|
||||
const Vue3 = version[0] === "3";
|
||||
|
||||
function resolveUnref(r) {
|
||||
return typeof r === "function" ? r() : unref(r);
|
||||
}
|
||||
function resolveUnrefHeadInput(ref) {
|
||||
if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
|
||||
return ref;
|
||||
const root = resolveUnref(ref);
|
||||
if (!ref || !root)
|
||||
return root;
|
||||
if (Array.isArray(root))
|
||||
return root.map((r) => resolveUnrefHeadInput(r));
|
||||
if (typeof root === "object") {
|
||||
const resolved = {};
|
||||
for (const k in root) {
|
||||
if (!Object.prototype.hasOwnProperty.call(root, k)) {
|
||||
continue;
|
||||
}
|
||||
if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
|
||||
resolved[k] = unref(root[k]);
|
||||
continue;
|
||||
}
|
||||
resolved[k] = resolveUnrefHeadInput(root[k]);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
const VueReactivityPlugin = defineHeadPlugin({
|
||||
hooks: {
|
||||
"entries:resolve": (ctx) => {
|
||||
for (const entry of ctx.entries)
|
||||
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const headSymbol = "usehead";
|
||||
function vueInstall(head) {
|
||||
const plugin = {
|
||||
install(app) {
|
||||
if (Vue3) {
|
||||
app.config.globalProperties.$unhead = head;
|
||||
app.config.globalProperties.$head = head;
|
||||
app.provide(headSymbol, head);
|
||||
}
|
||||
}
|
||||
};
|
||||
return plugin.install;
|
||||
}
|
||||
function createServerHead(options = {}) {
|
||||
const head = createServerHead$1(options);
|
||||
head.use(VueReactivityPlugin);
|
||||
head.install = vueInstall(head);
|
||||
return head;
|
||||
}
|
||||
|
||||
const unheadPlugins = true ? [CapoPlugin({ track: true })] : [];
|
||||
|
||||
const renderSSRHeadOptions = {"omitLineBreaks":false};
|
||||
|
||||
const appHead = {"meta":[{"name":"viewport","content":"width=device-width, initial-scale=1"},{"charset":"utf-8"}],"link":[{"rel":"icon","type":"image/x-icon","href":"/favicon.ico"}],"style":[],"script":[],"noscript":[],"titleTemplate":"%s - NuxtJS Admin Template","title":"Sneat"};
|
||||
|
||||
const appRootTag = "div";
|
||||
|
||||
const appRootAttrs = {"id":"__nuxt"};
|
||||
|
||||
const appTeleportTag = "div";
|
||||
|
||||
const appTeleportAttrs = {"id":"teleports"};
|
||||
|
||||
const componentIslands = false;
|
||||
|
||||
const appId = "nuxt-app";
|
||||
|
||||
function baseURL() {
|
||||
return useRuntimeConfig().app.baseURL;
|
||||
}
|
||||
function buildAssetsDir() {
|
||||
return useRuntimeConfig().app.buildAssetsDir;
|
||||
}
|
||||
function buildAssetsURL(...path) {
|
||||
return joinRelativeURL(publicAssetsURL(), buildAssetsDir(), ...path);
|
||||
}
|
||||
function publicAssetsURL(...path) {
|
||||
const app = useRuntimeConfig().app;
|
||||
const publicBase = app.cdnURL || app.baseURL;
|
||||
return path.length ? joinRelativeURL(publicBase, ...path) : publicBase;
|
||||
}
|
||||
|
||||
globalThis.__buildAssetsURL = buildAssetsURL;
|
||||
globalThis.__publicAssetsURL = publicAssetsURL;
|
||||
const getClientManifest = () => import('../build/client.manifest.mjs').then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
|
||||
const getEntryIds = () => getClientManifest().then((r) => Object.values(r).filter(
|
||||
(r2) => (
|
||||
// @ts-expect-error internal key set by CSS inlining configuration
|
||||
r2._globalCSS
|
||||
)
|
||||
).map((r2) => r2.src));
|
||||
const getServerEntry = () => import('../build/server.mjs').then((r) => r.default || r);
|
||||
const getSSRStyles = lazyCachedFunction(() => import('../build/styles.mjs').then((r) => r.default || r));
|
||||
const getSSRRenderer = lazyCachedFunction(async () => {
|
||||
const manifest = await getClientManifest();
|
||||
if (!manifest) {
|
||||
throw new Error("client.manifest is not available");
|
||||
}
|
||||
const createSSRApp = await getServerEntry();
|
||||
if (!createSSRApp) {
|
||||
throw new Error("Server bundle is not available");
|
||||
}
|
||||
const options = {
|
||||
manifest,
|
||||
renderToString: renderToString$1,
|
||||
buildAssetsURL
|
||||
};
|
||||
const renderer = createRenderer(createSSRApp, options);
|
||||
async function renderToString$1(input, context) {
|
||||
const html = await renderToString(input, context);
|
||||
return APP_ROOT_OPEN_TAG + html + APP_ROOT_CLOSE_TAG;
|
||||
}
|
||||
return renderer;
|
||||
});
|
||||
const getSPARenderer = lazyCachedFunction(async () => {
|
||||
const manifest = await getClientManifest();
|
||||
const spaTemplate = await import('../virtual/_virtual_spa-template.mjs').then((r) => r.template).catch(() => "").then((r) => APP_ROOT_OPEN_TAG + r + APP_ROOT_CLOSE_TAG);
|
||||
const options = {
|
||||
manifest,
|
||||
renderToString: () => spaTemplate,
|
||||
buildAssetsURL
|
||||
};
|
||||
const renderer = createRenderer(() => () => {
|
||||
}, options);
|
||||
const result = await renderer.renderToString({});
|
||||
const renderToString = (ssrContext) => {
|
||||
const config = useRuntimeConfig(ssrContext.event);
|
||||
ssrContext.modules = ssrContext.modules || /* @__PURE__ */ new Set();
|
||||
ssrContext.payload.serverRendered = false;
|
||||
ssrContext.config = {
|
||||
public: config.public,
|
||||
app: config.app
|
||||
};
|
||||
return Promise.resolve(result);
|
||||
};
|
||||
return {
|
||||
rendererContext: renderer.rendererContext,
|
||||
renderToString
|
||||
};
|
||||
});
|
||||
const HAS_APP_TELEPORTS = !!(appTeleportAttrs.id);
|
||||
const APP_TELEPORT_OPEN_TAG = HAS_APP_TELEPORTS ? `<${appTeleportTag}${propsToString(appTeleportAttrs)}>` : "";
|
||||
const APP_TELEPORT_CLOSE_TAG = HAS_APP_TELEPORTS ? `</${appTeleportTag}>` : "";
|
||||
const APP_ROOT_OPEN_TAG = `<${appRootTag}${propsToString(appRootAttrs)}>`;
|
||||
const APP_ROOT_CLOSE_TAG = `</${appRootTag}>`;
|
||||
const PAYLOAD_URL_RE = /\/_payload.json(\?.*)?$/ ;
|
||||
const renderer = defineRenderHandler(async (event) => {
|
||||
const nitroApp = useNitroApp();
|
||||
const ssrError = event.path.startsWith("/__nuxt_error") ? getQuery(event) : null;
|
||||
if (ssrError && ssrError.statusCode) {
|
||||
ssrError.statusCode = Number.parseInt(ssrError.statusCode);
|
||||
}
|
||||
if (ssrError && !("__unenv__" in event.node.req)) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: "Page Not Found: /__nuxt_error"
|
||||
});
|
||||
}
|
||||
const isRenderingIsland = componentIslands;
|
||||
const islandContext = void 0;
|
||||
let url = ssrError?.url || islandContext?.url || event.path;
|
||||
const isRenderingPayload = PAYLOAD_URL_RE.test(url) && !isRenderingIsland;
|
||||
if (isRenderingPayload) {
|
||||
url = url.substring(0, url.lastIndexOf("/")) || "/";
|
||||
event._path = url;
|
||||
event.node.req.url = url;
|
||||
}
|
||||
const routeOptions = getRouteRules(event);
|
||||
const head = createServerHead({
|
||||
plugins: unheadPlugins
|
||||
});
|
||||
const headEntryOptions = { mode: "server" };
|
||||
{
|
||||
head.push(appHead, headEntryOptions);
|
||||
}
|
||||
const ssrContext = {
|
||||
url,
|
||||
event,
|
||||
runtimeConfig: useRuntimeConfig(event),
|
||||
noSSR: event.context.nuxt?.noSSR || routeOptions.ssr === false && !isRenderingIsland || (false),
|
||||
head,
|
||||
error: !!ssrError,
|
||||
nuxt: void 0,
|
||||
/* NuxtApp */
|
||||
payload: ssrError ? { error: ssrError } : {},
|
||||
_payloadReducers: /* @__PURE__ */ Object.create(null),
|
||||
modules: /* @__PURE__ */ new Set(),
|
||||
islandContext
|
||||
};
|
||||
const renderer = ssrContext.noSSR ? await getSPARenderer() : await getSSRRenderer();
|
||||
{
|
||||
for (const id of await getEntryIds()) {
|
||||
ssrContext.modules.add(id);
|
||||
}
|
||||
}
|
||||
const _rendered = await renderer.renderToString(ssrContext).catch(async (error) => {
|
||||
if (ssrContext._renderResponse && error.message === "skipping render") {
|
||||
return {};
|
||||
}
|
||||
const _err = !ssrError && ssrContext.payload?.error || error;
|
||||
await ssrContext.nuxt?.hooks.callHook("app:error", _err);
|
||||
throw _err;
|
||||
});
|
||||
await ssrContext.nuxt?.hooks.callHook("app:rendered", { ssrContext, renderResult: _rendered });
|
||||
if (ssrContext._renderResponse) {
|
||||
return ssrContext._renderResponse;
|
||||
}
|
||||
if (ssrContext.payload?.error && !ssrError) {
|
||||
throw ssrContext.payload.error;
|
||||
}
|
||||
if (isRenderingPayload) {
|
||||
const response2 = renderPayloadResponse(ssrContext);
|
||||
return response2;
|
||||
}
|
||||
const inlinedStyles = await renderInlineStyles(ssrContext.modules ?? []) ;
|
||||
const NO_SCRIPTS = routeOptions.experimentalNoScripts;
|
||||
const { styles, scripts } = getRequestDependencies(ssrContext, renderer.rendererContext);
|
||||
if (inlinedStyles.length) {
|
||||
head.push({ style: inlinedStyles });
|
||||
}
|
||||
{
|
||||
const link = [];
|
||||
for (const resource of Object.values(styles)) {
|
||||
{
|
||||
link.push({ rel: "stylesheet", href: renderer.rendererContext.buildAssetsURL(resource.file), crossorigin: "" });
|
||||
}
|
||||
}
|
||||
if (link.length) {
|
||||
head.push({ link }, headEntryOptions);
|
||||
}
|
||||
}
|
||||
if (!NO_SCRIPTS && !isRenderingIsland) {
|
||||
head.push({
|
||||
link: getPreloadLinks(ssrContext, renderer.rendererContext)
|
||||
}, headEntryOptions);
|
||||
head.push({
|
||||
link: getPrefetchLinks(ssrContext, renderer.rendererContext)
|
||||
}, headEntryOptions);
|
||||
head.push({
|
||||
script: renderPayloadJsonScript({ ssrContext, data: ssrContext.payload })
|
||||
}, {
|
||||
...headEntryOptions,
|
||||
// this should come before another end of body scripts
|
||||
tagPosition: "bodyClose",
|
||||
tagPriority: "high"
|
||||
});
|
||||
}
|
||||
if (!routeOptions.experimentalNoScripts && !isRenderingIsland) {
|
||||
head.push({
|
||||
script: Object.values(scripts).map((resource) => ({
|
||||
type: resource.module ? "module" : null,
|
||||
src: renderer.rendererContext.buildAssetsURL(resource.file),
|
||||
defer: resource.module ? null : true,
|
||||
// if we are rendering script tag payloads that import an async payload
|
||||
// we need to ensure this resolves before executing the Nuxt entry
|
||||
tagPosition: "head",
|
||||
crossorigin: ""
|
||||
}))
|
||||
}, headEntryOptions);
|
||||
}
|
||||
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(head, renderSSRHeadOptions);
|
||||
const htmlContext = {
|
||||
island: isRenderingIsland,
|
||||
htmlAttrs: htmlAttrs ? [htmlAttrs] : [],
|
||||
head: normalizeChunks([headTags]),
|
||||
bodyAttrs: bodyAttrs ? [bodyAttrs] : [],
|
||||
bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]),
|
||||
body: [
|
||||
_rendered.html,
|
||||
APP_TELEPORT_OPEN_TAG + (HAS_APP_TELEPORTS ? joinTags([ssrContext.teleports?.[`#${appTeleportAttrs.id}`]]) : "") + APP_TELEPORT_CLOSE_TAG
|
||||
],
|
||||
bodyAppend: [bodyTags]
|
||||
};
|
||||
await nitroApp.hooks.callHook("render:html", htmlContext, { event });
|
||||
const response = {
|
||||
body: renderHTMLDocument(htmlContext),
|
||||
statusCode: getResponseStatus(event),
|
||||
statusMessage: getResponseStatusText(event),
|
||||
headers: {
|
||||
"content-type": "text/html;charset=utf-8",
|
||||
"x-powered-by": "Nuxt"
|
||||
}
|
||||
};
|
||||
return response;
|
||||
});
|
||||
function lazyCachedFunction(fn) {
|
||||
let res = null;
|
||||
return () => {
|
||||
if (res === null) {
|
||||
res = fn().catch((err) => {
|
||||
res = null;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
return res;
|
||||
};
|
||||
}
|
||||
function normalizeChunks(chunks) {
|
||||
return chunks.filter(Boolean).map((i) => i.trim());
|
||||
}
|
||||
function joinTags(tags) {
|
||||
return tags.join("");
|
||||
}
|
||||
function joinAttrs(chunks) {
|
||||
if (chunks.length === 0) {
|
||||
return "";
|
||||
}
|
||||
return " " + chunks.join(" ");
|
||||
}
|
||||
function renderHTMLDocument(html) {
|
||||
return `<!DOCTYPE html><html${joinAttrs(html.htmlAttrs)}><head>${joinTags(html.head)}</head><body${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body></html>`;
|
||||
}
|
||||
async function renderInlineStyles(usedModules) {
|
||||
const styleMap = await getSSRStyles();
|
||||
const inlinedStyles = /* @__PURE__ */ new Set();
|
||||
for (const mod of usedModules) {
|
||||
if (mod in styleMap && styleMap[mod]) {
|
||||
for (const style of await styleMap[mod]()) {
|
||||
inlinedStyles.add(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Array.from(inlinedStyles).map((style) => ({ innerHTML: style }));
|
||||
}
|
||||
function renderPayloadResponse(ssrContext) {
|
||||
return {
|
||||
body: stringify(splitPayload(ssrContext).payload, ssrContext._payloadReducers) ,
|
||||
statusCode: getResponseStatus(ssrContext.event),
|
||||
statusMessage: getResponseStatusText(ssrContext.event),
|
||||
headers: {
|
||||
"content-type": "application/json;charset=utf-8" ,
|
||||
"x-powered-by": "Nuxt"
|
||||
}
|
||||
};
|
||||
}
|
||||
function renderPayloadJsonScript(opts) {
|
||||
const contents = opts.data ? stringify(opts.data, opts.ssrContext._payloadReducers) : "";
|
||||
const payload = {
|
||||
"type": "application/json",
|
||||
"innerHTML": contents,
|
||||
"data-nuxt-data": appId,
|
||||
"data-ssr": !(opts.ssrContext.noSSR)
|
||||
};
|
||||
{
|
||||
payload.id = "__NUXT_DATA__";
|
||||
}
|
||||
if (opts.src) {
|
||||
payload["data-src"] = opts.src;
|
||||
}
|
||||
const config = uneval(opts.ssrContext.config);
|
||||
return [
|
||||
payload,
|
||||
{
|
||||
innerHTML: `window.__NUXT__={};window.__NUXT__.config=${config}`
|
||||
}
|
||||
];
|
||||
}
|
||||
function splitPayload(ssrContext) {
|
||||
const { data, prerenderedAt, ...initial } = ssrContext.payload;
|
||||
return {
|
||||
initial: { ...initial, prerenderedAt },
|
||||
payload: { data, prerenderedAt }
|
||||
};
|
||||
}
|
||||
|
||||
const renderer$1 = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
default: renderer
|
||||
});
|
||||
|
||||
export { buildAssetsURL as a, baseURL as b, renderer$1 as r };
|
||||
Reference in New Issue
Block a user