upload de projetos funcional + busca por bpm
This commit is contained in:
1 parent
9a92ba9d10
commit
c74545bd63
282 files changed
+354875
-326895
No files matched your search
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
+8
-5
@@ -9,6 +9,9 @@ const { Server } = require("socket.io");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const pino = require("pino");
|
||||
//import { LOG_SERVER } from "../utils.js"
|
||||
const LOG_SERVER = `/var/www/html/trens/src_mmpSearch/logs/creation_logs/server`
|
||||
const SESSION_JSON = `/var/www/html/trens/src_mmpSearch/logs/creation_logs/sessions`
|
||||
|
||||
const DEFAULT_PROJECT_XML = `<?xml version="1.0"?>
|
||||
<!DOCTYPE lmms-project>
|
||||
@@ -121,12 +124,12 @@ function getActionLoggerForRoom(roomName) {
|
||||
const safeRoomName = roomName.replace(/[^a-z0-9_-]/gi, "_");
|
||||
|
||||
const fileName = `${timestamp}_${safeRoomName}.log`;
|
||||
const filePath = path.join(process.cwd(), "data", fileName);
|
||||
const filePath = path.join(LOG_SERVER, fileName);
|
||||
|
||||
console.log(`[Logger] Novo log de sessão iniciado: ${filePath}`);
|
||||
|
||||
// Garante que a pasta 'data' exista
|
||||
fs.mkdirSync(path.join(process.cwd(), "data"), { recursive: true });
|
||||
// Cria a pasta LOG_SERVER
|
||||
fs.mkdirSync(LOG_SERVER, { recursive: true });
|
||||
|
||||
// Cria a instância do pino para este arquivo específico
|
||||
const newLogger = pino(pino.destination(filePath));
|
||||
@@ -179,7 +182,7 @@ const httpsServer = https.createServer(httpsOptions, app);
|
||||
const roomStates = {}; // compat com V4 (já existia), ampliado para incluir audio/seq
|
||||
|
||||
function dataFile(roomName) {
|
||||
return path.join(process.cwd(), "data", `${roomName}.json`);
|
||||
return path.join(SESSION_JSON, `${roomName}.json`);
|
||||
}
|
||||
|
||||
function ensureRoom(roomName) {
|
||||
@@ -217,7 +220,7 @@ function ensureRoom(roomName) {
|
||||
function saveRoom(roomName) {
|
||||
const r = ensureRoom(roomName);
|
||||
try {
|
||||
fs.mkdirSync(path.join(process.cwd(), "data"), { recursive: true });
|
||||
fs.mkdirSync(SESSION_JSON, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
dataFile(roomName),
|
||||
JSON.stringify({ projectXml: r.projectXml, audio: r.audio, seq: r.seq })
|
||||
|
||||
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
+1
-1
@@ -84,7 +84,7 @@ export const DEFAULT_PROJECT_XML = `<?xml version="1.0"?>
|
||||
|
||||
export const SAMPLE_MANIFEST = `src_mmpSearch/metadata/samples-manifest.json`
|
||||
export const MMP_MANIFEST = `src_mmpSearch/metadata/mmp-manifest.json`
|
||||
export const SAMPLE_SRC = `src_mmpSearch/src/samples`
|
||||
export const SAMPLE_SRC = `src_mmpSearch/samples`
|
||||
|
||||
/**
|
||||
* Helper interna para ler o BPM do input.
|
||||
|
||||
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
@@ -1,31 +0,0 @@
|
||||
const express = require("express");
|
||||
const multer = require("multer");
|
||||
const path = require("path");
|
||||
const app = express();
|
||||
|
||||
// Configura onde salvar (Pasta 'uploads')
|
||||
const storage = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
cb(null, "../../public/projects/"); // <--- PASTA ONDE FICARÃO OS PROJETOS
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
// Mantém o nome original ou cria um novo para evitar duplicatas
|
||||
const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
|
||||
cb(null, uniqueSuffix + "-" + file.originalname);
|
||||
},
|
||||
});
|
||||
|
||||
const upload = multer({ storage: storage });
|
||||
|
||||
// A Rota que o HTML vai chamar
|
||||
app.post(
|
||||
"/api/upload",
|
||||
upload.fields([{ name: "project_file" }, { name: "audio_preview" }]),
|
||||
(req, res) => {
|
||||
// Aqui você pode salvar os dados de Título/BPM em um banco de dados ou arquivo JSON
|
||||
console.log("Projeto recebido:", req.body.project_name);
|
||||
console.log("Arquivo salvo:", req.files["project_file"][0].path);
|
||||
|
||||
res.send("Arquivo recebido com sucesso");
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user