Corrige caminhos do storage no server e Dockerfile do portal
This commit is contained in:
parent
5ee1524d8a
commit
a3f5b12a07
|
|
@ -12,8 +12,8 @@ FROM node:22-alpine AS production
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
RUN npm install --omit=dev
|
RUN npm install --omit=dev
|
||||||
COPY server.selfhosted.js ./server.js
|
COPY server.selfhosted.js ./server.js
|
||||||
COPY src/services ./src/services
|
COPY services ./services
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
EXPOSE 3001
|
EXPOSE 3001
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import pg from 'pg';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
import { uploadAtestado, s3Client } from './server/services/storage.js';
|
import { uploadAtestado, s3Client } from './services/storage.js';
|
||||||
import { GetObjectCommand } from '@aws-sdk/client-s3';
|
import { GetObjectCommand } from '@aws-sdk/client-s3';
|
||||||
|
|
||||||
const upload = multer({ storage: multer.memoryStorage() });
|
const upload = multer({ storage: multer.memoryStorage() });
|
||||||
|
|
@ -51,7 +51,7 @@ app.get(/^\/storage\/([^\/]+)\/(.+)$/, async (req, res) => {
|
||||||
const key = req.params[1];
|
const key = req.params[1];
|
||||||
const command = new GetObjectCommand({ Bucket: bucket, Key: key });
|
const command = new GetObjectCommand({ Bucket: bucket, Key: key });
|
||||||
const data = await s3Client.send(command);
|
const data = await s3Client.send(command);
|
||||||
|
|
||||||
res.set('Content-Type', data.ContentType || 'image/jpeg');
|
res.set('Content-Type', data.ContentType || 'image/jpeg');
|
||||||
res.set('Cache-Control', 'public, max-age=86400');
|
res.set('Cache-Control', 'public, max-age=86400');
|
||||||
data.Body.pipe(res);
|
data.Body.pipe(res);
|
||||||
|
|
@ -291,7 +291,7 @@ app.post('/api/portal/frequencia/justificar', authMiddleware, upload.single('arq
|
||||||
|
|
||||||
const fullDateStr = date;
|
const fullDateStr = date;
|
||||||
const justificationPayload = JSON.stringify({ motivo: motivo.trim(), arquivo: publicUrl });
|
const justificationPayload = JSON.stringify({ motivo: motivo.trim(), arquivo: publicUrl });
|
||||||
|
|
||||||
let recordIndex = attendance.findIndex(a => a.studentId === req.user.studentId && a.date === fullDateStr);
|
let recordIndex = attendance.findIndex(a => a.studentId === req.user.studentId && a.date === fullDateStr);
|
||||||
|
|
||||||
if (recordIndex !== -1) {
|
if (recordIndex !== -1) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue