diff --git a/.gitignore b/.gitignore index a76709f6..8cc161bf 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,8 @@ public .env.production # firebase -service-account.json \ No newline at end of file +service-account.json +serviceAccountKey.json + +# netlify funcs +functions-build \ No newline at end of file diff --git a/functions/hello.js b/functions/hello.js deleted file mode 100644 index 4fb25ed1..00000000 --- a/functions/hello.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,r){for(var t in r)e[t]=r[t]}(exports,function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";function n(e,r,t){console.log("queryStringParameters",e.queryStringParameters),t(null,{statusCode:200,body:JSON.stringify({msg:"Hello, World! "+Math.round(10*Math.random())})})}t.r(r),t.d(r,"handler",(function(){return n}))}])); \ No newline at end of file diff --git a/functions/page-views.js b/functions/page-views.js new file mode 100644 index 00000000..c843ef0f --- /dev/null +++ b/functions/page-views.js @@ -0,0 +1,8 @@ +exports.handler = async (event, context) => { + return { + statusCode: 200, + body: JSON.stringify({ + data: `Test data added successfully`, + }), + } +} diff --git a/netlify.toml b/netlify.toml index 83fe98b4..73e0334f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,5 +1,5 @@ [build] - functions = "functions" + functions = "functions-build" publish = "public" [[plugins]] diff --git a/package.json b/package.json index ed3646ee..74f995bc 100644 --- a/package.json +++ b/package.json @@ -80,13 +80,13 @@ "license": "MIT", "main": "n/a", "scripts": { - "build": "GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages && netlify-lambda build src/functions", - "build:lambda": "netlify-lambda build src/functions", + "build": "GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages && netlify-lambda build functions", + "build:lambda": "netlify-lambda build functions", "build:local": "gatsby build", "g:post": "hygen post new", "dev": "gatsby develop", "start": "run-p start:**", "start:app": "npm run dev", - "start:lambda": "netlify-lambda serve src/functions" + "start:lambda": "netlify-lambda serve functions" } } diff --git a/src/functions/hello.js b/src/functions/hello.js deleted file mode 100644 index 7fcef2f8..00000000 --- a/src/functions/hello.js +++ /dev/null @@ -1,11 +0,0 @@ -// For more info, check https://www.netlify.com/docs/functions/#javascript-lambda-functions -export function handler(event, context, callback) { - console.log('queryStringParameters', event.queryStringParameters) - callback(null, { - // return null to show no errors - statusCode: 200, // http status code - body: JSON.stringify({ - msg: 'Hello, World! ' + Math.round(Math.random() * 10), - }), - }) -}