Created
April 23, 2018 09:24
-
-
Save notrab/30f204d24b4edf385f46532612a0cc06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { send } = require('micro') | |
const { get, router } = require('microrouter') | |
const cors = require('micro-cors')() | |
const moltinGateway = require('@moltin/sdk').gateway | |
const moltin = moltinGateway({ | |
client_id: process.env.MOLTIN_CLIENT_ID, | |
client_secret: process.env.MOLTIN_CLIENT_SECRET | |
}) | |
module.exports = cors( | |
router( | |
get('/:orderId', async (req, res) => { | |
const { orderId } = req.params | |
try { | |
const { | |
json: { | |
data: { short_id } | |
} | |
} = await moltin.Orders.Get(orderId) | |
send(res, 200, { | |
short_id | |
}) | |
} catch ({ status, json }) { | |
send(res, status, json) | |
} | |
}) | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"private": true, | |
"scripts": { | |
"dev": "micro-dev", | |
"precommit": "pretty-quick --staged", | |
"start": "micro" | |
}, | |
"dependencies": { | |
"@moltin/sdk": "github:ynnoj/js-sdk", | |
"micro": "^9.1.4", | |
"micro-cors": "^0.1.0", | |
"microrouter": "^3.1.2" | |
}, | |
"devDependencies": { | |
"husky": "^0.14.3", | |
"micro-dev": "^2.2.2", | |
"prettier": "^1.12.1", | |
"pretty-quick": "^1.4.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment