From 9265ea2a9d9e5354b3a6f873d698e170288acc1d Mon Sep 17 00:00:00 2001 From: olivermrbl Date: Tue, 7 Jul 2020 21:24:35 +0200 Subject: [PATCH] Adds get and list routes for customers --- .../src/api/routes/store/customers/get-customer.js | 10 ++++++++++ .../src/api/routes/store/customers/list-customers.js | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 packages/medusa/src/api/routes/store/customers/get-customer.js create mode 100644 packages/medusa/src/api/routes/store/customers/list-customers.js diff --git a/packages/medusa/src/api/routes/store/customers/get-customer.js b/packages/medusa/src/api/routes/store/customers/get-customer.js new file mode 100644 index 0000000000..e8dc947e22 --- /dev/null +++ b/packages/medusa/src/api/routes/store/customers/get-customer.js @@ -0,0 +1,10 @@ +export default async (req, res) => { + const { id } = req.params + try { + const customerService = req.scope.resolve("customerService") + let customer = await customerService.retrieve(id) + res.json({ customer }) + } catch (err) { + throw err + } +} diff --git a/packages/medusa/src/api/routes/store/customers/list-customers.js b/packages/medusa/src/api/routes/store/customers/list-customers.js new file mode 100644 index 0000000000..c64cc20aa9 --- /dev/null +++ b/packages/medusa/src/api/routes/store/customers/list-customers.js @@ -0,0 +1,12 @@ +export default async (req, res) => { + const selector = {} + + try { + const customerService = req.scope.resolve("customerService") + const customers = await customerService.list(selector) + + res.json({ customers }) + } catch (error) { + throw error + } +}