Skip to content

Commit

Permalink
fix: Instantiate the SqueezeService
Browse files Browse the repository at this point in the history
  • Loading branch information
Nainah23 committed Aug 8, 2024
1 parent 1ce23b8 commit 630b344
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/controllers/SqueezeController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Request, Response } from "express";
import { SqueezeService } from "../services";


class SqueezeController {
private squeezeService: SqueezeService;

constructor() {
this.squeezeService = new SqueezeService();
}

/**
* @openapi
* /api/v1/squeeze-pages:
Expand Down Expand Up @@ -62,22 +67,22 @@ class SqueezeController {
* description: Conflict
*/
public createSqueeze = async (req: Request, res: Response) => {
try {
const squeezeData = req.body;
const squeeze = await SqueezeService.createSqueeze(squeezeData);
res.status(201).json({
status: "success",
message: "Squeeze record created successfully.",
data: squeeze,
});
} catch (error) {
res.status(500).json({
status: "error",
message: "An error occurred while creating the squeeze record.",
error: error.message,
});
}
};
try {
const squeezeData = req.body;
const squeeze = await this.squeezeService.createSqueeze(squeezeData); // Use the instance method
res.status(201).json({
status: "success",
message: "Squeeze record created successfully.",
data: squeeze,
});
} catch (error) {
res.status(500).json({
status: "error",
message: "An error occurred while creating the squeeze record.",
error: error.message,
});
}
};
}

export { SqueezeController };
export { SqueezeController };

0 comments on commit 630b344

Please sign in to comment.