Skip to content

Commit

Permalink
update (#2955)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoonz authored Aug 15, 2022
2 parents 738a92f + 6e2860e commit 4b3458f
Show file tree
Hide file tree
Showing 481 changed files with 934,753 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
54 changes: 54 additions & 0 deletions functions/ExampleQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const NetlifyGraph = require('./netlifyGraph');

exports.handler = async (event) => {
// By default, all API calls use no authentication
let accessToken;

//// If you want to use the client's accessToken when making API calls on the user's behalf:
// accessToken = event.headers["authorization"]?.split(" ")[1]

//// If you want to use the API with your own access token:
// accessToken = event.authlifyToken

const eventBodyJson = JSON.parse(event.body || '{}');

const { errors: ExampleQueryErrors, data: ExampleQueryData } = await NetlifyGraph.fetchExampleQuery({}, { accessToken: accessToken });

if (ExampleQueryErrors) {
console.error(JSON.stringify(ExampleQueryErrors, null, 2));
}

console.log(JSON.stringify(ExampleQueryData, null, 2));

return {
statusCode: 200,
body: JSON.stringify({
success: true,
ExampleQueryErrors: ExampleQueryErrors,
ExampleQueryData: ExampleQueryData
}),
headers: {
'content-type': 'application/json'
}
};
};

/**
* Client-side invocations:
* Call your Netlify function from the browser (after saving
* the code to `ExampleQuery.js`) with these helpers:
*/


async function fetchExampleQuery(params) {
const {} = params || {};
const resp = await fetch(`/.netlify/functions/ExampleQuery?`,
{
method: "GET"
});

const text = await resp.text();

return JSON.parse(text);
}

30 changes: 30 additions & 0 deletions functions/functions/deploy-succeeded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const contextCondition = "production";
const stateCondition = "ready";
const sitemapUrl = process.env.SITEMAP_URL;
const axios = require("axios");
exports.handler = async (event) => {
try {
const { payload } = JSON.parse(event.body);
const { state, context } = payload;
if (
sitemapUrl &&
state === stateCondition &&
context === contextCondition
) {
console.log(`Sending sitemap ping to google for ${sitemapUrl}`);
await axios.get(`http://www.google.com/ping?sitemap=${sitemapUrl}`);
return {
statusCode: 200,
body: `Submitted Successfully`,
};
}
console.log("Conditions not met, not submitting");
return {
statusCode: 200,
body: `Conditions not met, not submitting`,
};
} catch (err) {
console.log(err);
throw err;
}
};
33 changes: 33 additions & 0 deletions functions/functions/netlify-graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
fetchExampleQuery
} from '../netlifyGraph' // make sure this is the path to your netlify/functions dir

exports.handler = async function(event, context) {
const {
errors,
data
} = await fetchExampleQuery({
/* variables */
}, {
accessToken: event.netlifyGraphToken
})

return {
statusCode: errors ? 500 : 200,
body: JSON.stringify(errors || data),
headers: {
"Content-Type": "application/json"
}
}
}
accessToken: event.netlifyGraphToken
})

return {
statusCode: errors ? 500 : 200,
body: JSON.stringify(errors || data),
headers: {
"Content-Type": "application/json"
}
}
}
Loading

0 comments on commit 4b3458f

Please sign in to comment.