UNPKG

@rsc-labs/medusa-documents

Version:
61 lines (60 loc) 1.73 kB
"use strict"; /* * Copyright 2024 RSC-Labs, https://rsoftcon.com/ * * MIT License * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.POST = exports.GET = void 0; const GET = async (req, res) => { const invoiceService = req.scope.resolve('invoiceService'); try { const logoSource = await invoiceService.getStoreLogo(); res.status(200).json({ logoSource: logoSource }); } catch (e) { res.status(400).json({ message: e.message }); } }; exports.GET = GET; const POST = async (req, res) => { const body = req.body; const invoiceService = req.scope.resolve('invoiceService'); const logoSource = body.logoSource; try { if (logoSource) { const newSettings = await invoiceService.updateStoreLogo(logoSource); if (newSettings !== undefined) { res.status(201).json({ settings: newSettings }); } else { res.status(400).json({ message: 'Cant update logo' }); } } else { res.status(400).json({ message: 'Logo source not passed' }); } } catch (e) { res.status(400).json({ message: e.message }); } }; exports.POST = POST;