mirror of
https://github.com/romancm/gamebrary
synced 2025-02-17 11:38:24 +00:00
sparkpost wrapper endpoint
This commit is contained in:
parent
e012933143
commit
0b6eafb878
1 changed files with 46 additions and 11 deletions
|
@ -39,6 +39,41 @@ exports.game = functions.https.onRequest((req, res) => {
|
||||||
.catch(() => { res.send(400) });
|
.catch(() => { res.send(400) });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
exports.email = functions.https.onRequest((req, res) => {
|
||||||
|
res.set('Access-Control-Allow-Origin', "*")
|
||||||
|
|
||||||
|
const { template_id, address } = req.body;
|
||||||
|
|
||||||
|
if (!template_id || !address) {
|
||||||
|
res.send(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
recipients: [
|
||||||
|
{
|
||||||
|
address,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: 'romancm@gmail.com',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
content: { template_id },
|
||||||
|
};
|
||||||
|
|
||||||
|
axios({
|
||||||
|
url: 'https://api.sparkpost.com/api/v1/transmissions',
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Authorization': functions.config().sparkpost.key,
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
.then(({ data }) => { res.status(200).send(data) })
|
||||||
|
.catch(() => { res.send(400) });
|
||||||
|
});
|
||||||
|
|
||||||
exports.platform = functions.https.onRequest((req, res) => {
|
exports.platform = functions.https.onRequest((req, res) => {
|
||||||
res.set('Access-Control-Allow-Origin', "*")
|
res.set('Access-Control-Allow-Origin', "*")
|
||||||
|
|
||||||
|
@ -63,17 +98,17 @@ exports.platform = functions.https.onRequest((req, res) => {
|
||||||
//
|
//
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
//
|
//
|
||||||
// axios({
|
// axios({
|
||||||
// url: igdbV3Url,
|
// url: igdbV3Url,
|
||||||
// method: 'POST',
|
// method: 'POST',
|
||||||
// headers: {
|
// headers: {
|
||||||
// 'Accept': 'application/json',
|
// 'Accept': 'application/json',
|
||||||
// 'user-key': '3b516a46c3af209bb6e287e9090d720c'
|
// 'user-key': '3b516a46c3af209bb6e287e9090d720c'
|
||||||
// },
|
// },
|
||||||
// data,
|
// data,
|
||||||
// })
|
// })
|
||||||
// .then(({ data }) => { res.status(200).send(data) })
|
// .then(({ data }) => { res.status(200).send(data) })
|
||||||
// .catch(() => { res.send(400) });
|
// .catch(() => { res.send(400) });
|
||||||
// // res.send(req.body)
|
// // res.send(req.body)
|
||||||
// // axios.get(`${igdbV3Url}/games/?search=${searchText}&fields=${igdbFields}&filter[platforms][eq]=${platformId}&limit=20&order=popularity:desc`)
|
// // axios.get(`${igdbV3Url}/games/?search=${searchText}&fields=${igdbFields}&filter[platforms][eq]=${platformId}&limit=20&order=popularity:desc`)
|
||||||
// // .then(({ data }) => { res.status(200).send(data) })
|
// // .then(({ data }) => { res.status(200).send(data) })
|
||||||
|
|
Loading…
Add table
Reference in a new issue