Skip to content

Commit

Permalink
Merge branch 'fix/deleted-object-v4' of https://github.com/PrestaShop…
Browse files Browse the repository at this point in the history
…Corp/ps_eventbus into fix/deleted-object-v4
  • Loading branch information
fox-john committed Oct 31, 2024
2 parents efbfc7b + 1e4ab59 commit d612cbc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions e2e-env/cloudsync-mock/src/lib/collector-api.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { Server } from "./server";
import {WsServer} from "./ws-server";
import { WsServer } from "./ws-server";
// @ts-expect-error we don't care about packaging here
import multer from "multer";

const storage = multer.memoryStorage()
const upload = multer({ storage })
const storage = multer.memoryStorage();
const upload = multer({ storage });

export class CollectorApiServer extends Server {
public constructor( probe: WsServer) {
super( probe);
public constructor(probe: WsServer) {
super(probe);

this.api.get("/", (_req, res) => {
res.status(200).end();
});

this.api.post("/upload/:jobid", upload.single('file'), (req, res) => {
this.api.post("/upload/:jobid", upload.single("file"), (req, res) => {
const jobId = req.params.jobid;
if (jobId.startsWith("valid-job-")) {
req.body.file = req.file.buffer.toString()
.split('\n')
.map(line => JSON.parse(line.trim()))
req.body.file = req.file.buffer
.toString()
.split("\n")
.map((line) => JSON.parse(line.trim()));
res.status(201).end();
} else {
res.status(500).end();
Expand Down

0 comments on commit d612cbc

Please sign in to comment.