enzostvs HF staff commited on
Commit
525dc77
β€’
1 Parent(s): 9d95d3f

try vite plugin

Browse files
Dockerfile CHANGED
@@ -20,7 +20,7 @@ RUN chmod +x entrypoint.sh
20
  EXPOSE 3000
21
 
22
  # Create symlink
23
- RUN mkdir -p ./static/data && ln -s /data/uploads ./static/data/uploads
24
 
25
  # Start the application
26
  ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
 
20
  EXPOSE 3000
21
 
22
  # Create symlink
23
+ # RUN mkdir -p ./static/data && ln -s /data/uploads ./static/data/uploads
24
 
25
  # Start the application
26
  ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
plugin.js DELETED
@@ -1,10 +0,0 @@
1
- import express from 'express';
2
- const assets = express.static(process.env.PUBLIC_FILE_UPLOAD_DIR || 'public');
3
- const configureServer = (server) => {
4
- server.middlewares.use(assets);
5
- };
6
- export const myVitePlugin = () => ({
7
- name: 'my-vite-plugin',
8
- configureServer,
9
- configurePreviewServer: configureServer
10
- });
 
 
 
 
 
 
 
 
 
 
 
src/routes/api/generate/+server.ts CHANGED
@@ -76,12 +76,14 @@ export async function POST({ request, cookies } : RequestEvent) {
76
  const user = await tokenIsAvailable(token)
77
  if (user?.sub) {
78
  const dir = await promises.opendir(publicEnv.PUBLIC_FILE_UPLOAD_DIR).catch(() => null)
79
- if (!dir) {
80
- await promises.mkdir(publicEnv.PUBLIC_FILE_UPLOAD_DIR)
81
- }
82
  const file_name_formatted = randomUUID() + "_" + generation?.inputs?.replaceAll(/[^a-zA-Z0-9]/g, "-") + ".png"
83
  await promises.writeFile(`${publicEnv.PUBLIC_FILE_UPLOAD_DIR}/${file_name_formatted}`, response)
84
 
 
 
 
 
85
  gallery = await prisma.gallery.create({
86
  data: {
87
  image: file_name_formatted,
 
76
  const user = await tokenIsAvailable(token)
77
  if (user?.sub) {
78
  const dir = await promises.opendir(publicEnv.PUBLIC_FILE_UPLOAD_DIR).catch(() => null)
79
+ if (!dir) await promises.mkdir(publicEnv.PUBLIC_FILE_UPLOAD_DIR)
 
 
80
  const file_name_formatted = randomUUID() + "_" + generation?.inputs?.replaceAll(/[^a-zA-Z0-9]/g, "-") + ".png"
81
  await promises.writeFile(`${publicEnv.PUBLIC_FILE_UPLOAD_DIR}/${file_name_formatted}`, response)
82
 
83
+ const dir2 = await promises.opendir("./static/data").catch(() => null)
84
+ if (!dir2) await promises.mkdir("./static/data")
85
+ await promises.symlink("/data/uploads", "./static/data/uploads")
86
+
87
  gallery = await prisma.gallery.create({
88
  data: {
89
  image: file_name_formatted,
static/data/uploads ADDED
@@ -0,0 +1 @@
 
 
1
+ /data/uploads
vite.config.ts CHANGED
@@ -1,13 +1,11 @@
1
  import { sveltekit } from '@sveltejs/kit/vite';
2
  import { enhancedImages } from '@sveltejs/enhanced-img';
3
  import { defineConfig } from 'vite';
4
- import { myVitePlugin } from './plugin';
5
 
6
  export default defineConfig({
7
  plugins: [
8
  enhancedImages(),
9
  sveltekit(),
10
- myVitePlugin(),
11
  ],
12
  server: {
13
  fs: {
 
1
  import { sveltekit } from '@sveltejs/kit/vite';
2
  import { enhancedImages } from '@sveltejs/enhanced-img';
3
  import { defineConfig } from 'vite';
 
4
 
5
  export default defineConfig({
6
  plugins: [
7
  enhancedImages(),
8
  sveltekit(),
 
9
  ],
10
  server: {
11
  fs: {