netlify-cli 17.37.2 → 17.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +4 -2
- package/dist/commands/addons/addons.d.ts.map +1 -1
- package/dist/commands/addons/addons.js +0 -1
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +2 -1
- package/dist/commands/blobs/blobs-delete.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-delete.js +7 -1
- package/dist/commands/blobs/blobs-set.d.ts +1 -0
- package/dist/commands/blobs/blobs-set.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-set.js +10 -2
- package/dist/commands/deploy/deploy.js +2 -2
- package/dist/commands/deploy/index.d.ts.map +1 -1
- package/dist/commands/deploy/index.js +4 -3
- package/dist/commands/env/env-clone.d.ts.map +1 -1
- package/dist/commands/env/env-clone.js +12 -3
- package/dist/commands/env/env-set.d.ts.map +1 -1
- package/dist/commands/env/env-set.js +8 -3
- package/dist/commands/env/env-unset.d.ts.map +1 -1
- package/dist/commands/env/env-unset.js +7 -3
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +0 -1
- package/dist/commands/integration/deploy.d.ts.map +1 -1
- package/dist/commands/integration/deploy.js +11 -20
- package/dist/commands/main.d.ts +34 -0
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +36 -6
- package/dist/commands/sites/sites-create-template.d.ts +2 -3
- package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
- package/dist/commands/sites/sites-create-template.js +113 -92
- package/dist/commands/sites/sites-create.d.ts.map +1 -1
- package/dist/commands/sites/sites.d.ts.map +1 -1
- package/dist/commands/sites/sites.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/command-helpers.d.ts +16 -0
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +7 -0
- package/dist/utils/framework-server.d.ts.map +1 -1
- package/dist/utils/framework-server.js +2 -2
- package/dist/utils/gh-auth.js +1 -1
- package/dist/utils/headers.js +1 -1
- package/dist/utils/prompts/blob-delete-prompts.d.ts +2 -0
- package/dist/utils/prompts/blob-delete-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/blob-delete-prompts.js +11 -0
- package/dist/utils/prompts/blob-set-prompt.d.ts +2 -0
- package/dist/utils/prompts/blob-set-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/blob-set-prompt.js +11 -0
- package/dist/utils/prompts/confirm-prompt.d.ts +2 -0
- package/dist/utils/prompts/confirm-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/confirm-prompt.js +20 -0
- package/dist/utils/prompts/env-clone-prompt.d.ts +11 -0
- package/dist/utils/prompts/env-clone-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/env-clone-prompt.js +27 -0
- package/dist/utils/prompts/env-set-prompts.d.ts +2 -0
- package/dist/utils/prompts/env-set-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/env-set-prompts.js +11 -0
- package/dist/utils/prompts/env-unset-prompts.d.ts +8 -0
- package/dist/utils/prompts/env-unset-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/env-unset-prompts.js +17 -0
- package/dist/utils/prompts/prompt-messages.d.ts +25 -0
- package/dist/utils/prompts/prompt-messages.d.ts.map +1 -0
- package/dist/utils/prompts/prompt-messages.js +25 -0
- package/dist/utils/redirects.js +1 -1
- package/dist/utils/run-build.d.ts +2 -0
- package/dist/utils/run-build.d.ts.map +1 -1
- package/dist/utils/run-program.d.ts +3 -0
- package/dist/utils/run-program.d.ts.map +1 -0
- package/dist/utils/run-program.js +12 -0
- package/dist/utils/scripted-commands.d.ts +3 -0
- package/dist/utils/scripted-commands.d.ts.map +1 -0
- package/dist/utils/scripted-commands.js +17 -0
- package/dist/utils/sites/create-template.d.ts +14 -0
- package/dist/utils/sites/create-template.d.ts.map +1 -0
- package/dist/utils/sites/create-template.js +46 -0
- package/dist/utils/sites/utils.d.ts +8 -6
- package/dist/utils/sites/utils.d.ts.map +1 -1
- package/dist/utils/sites/utils.js +10 -4
- package/dist/utils/static-server.d.ts +3 -1
- package/dist/utils/static-server.d.ts.map +1 -1
- package/dist/utils/static-server.js +2 -0
- package/dist/utils/types.d.ts +14 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/functions-templates/javascript/hello-world/{{name}}.mjs +13 -0
- package/functions-templates/javascript/scheduled-function/{{name}}.mjs +11 -0
- package/functions-templates/rust/hello-world/Cargo.toml +1 -1
- package/functions-templates/typescript/hello-world/package-lock.json +15 -15
- package/functions-templates/typescript/hello-world/package.json +1 -1
- package/functions-templates/typescript/hello-world/{{name}}.mts +14 -0
- package/functions-templates/typescript/scheduled-function/package.json +1 -1
- package/functions-templates/typescript/scheduled-function/{{name}}.mts +11 -0
- package/npm-shrinkwrap.json +849 -626
- package/package.json +14 -14
- package/functions-templates/javascript/hello-world/{{name}}.js +0 -17
- package/functions-templates/javascript/identity-signup/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/identity-signup/{{name}}.js +0 -29
- package/functions-templates/javascript/sanity-create/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/sanity-create/package.json +0 -20
- package/functions-templates/javascript/sanity-create/{{name}}.js +0 -72
- package/functions-templates/javascript/sanity-groq/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/sanity-groq/package.json +0 -21
- package/functions-templates/javascript/sanity-groq/{{name}}.js +0 -56
- package/functions-templates/javascript/scheduled-function/{{name}}.js +0 -12
- package/functions-templates/javascript/submission-created/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/submission-created/package.json +0 -19
- package/functions-templates/javascript/submission-created/{{name}}.js +0 -29
- package/functions-templates/typescript/hello-world/{{name}}.ts +0 -12
- package/functions-templates/typescript/scheduled-function/{{name}}.ts +0 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.38.1",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -38,13 +38,15 @@
|
|
|
38
38
|
"@bugsnag/js": "7.25.0",
|
|
39
39
|
"@fastify/static": "7.0.4",
|
|
40
40
|
"@netlify/blobs": "8.1.0",
|
|
41
|
-
"@netlify/build": "29.
|
|
42
|
-
"@netlify/build-info": "7.
|
|
43
|
-
"@netlify/config": "20.
|
|
44
|
-
"@netlify/edge-bundler": "12.
|
|
45
|
-
"@netlify/edge-functions": "2.
|
|
41
|
+
"@netlify/build": "29.58.0",
|
|
42
|
+
"@netlify/build-info": "7.17.0",
|
|
43
|
+
"@netlify/config": "20.21.0",
|
|
44
|
+
"@netlify/edge-bundler": "12.3.1",
|
|
45
|
+
"@netlify/edge-functions": "2.11.1",
|
|
46
|
+
"@netlify/headers-parser": "7.3.0",
|
|
46
47
|
"@netlify/local-functions-proxy": "1.1.1",
|
|
47
|
-
"@netlify/
|
|
48
|
+
"@netlify/redirect-parser": "14.5.0",
|
|
49
|
+
"@netlify/zip-it-and-ship-it": "9.42.1",
|
|
48
50
|
"@octokit/rest": "20.1.1",
|
|
49
51
|
"@opentelemetry/api": "1.8.0",
|
|
50
52
|
"ansi-escapes": "7.0.0",
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"boxen": "7.1.1",
|
|
57
59
|
"chalk": "5.3.0",
|
|
58
60
|
"chokidar": "3.6.0",
|
|
59
|
-
"ci-info": "4.
|
|
61
|
+
"ci-info": "4.1.0",
|
|
60
62
|
"clean-deep": "3.4.0",
|
|
61
63
|
"commander": "10.0.1",
|
|
62
64
|
"comment-json": "4.2.5",
|
|
@@ -68,12 +70,12 @@
|
|
|
68
70
|
"debug": "4.3.7",
|
|
69
71
|
"decache": "4.6.2",
|
|
70
72
|
"dot-prop": "9.0.0",
|
|
71
|
-
"dotenv": "16.4.
|
|
73
|
+
"dotenv": "16.4.7",
|
|
72
74
|
"env-paths": "3.0.0",
|
|
73
75
|
"envinfo": "7.14.0",
|
|
74
76
|
"etag": "1.8.1",
|
|
75
77
|
"execa": "5.1.1",
|
|
76
|
-
"express": "4.21.
|
|
78
|
+
"express": "4.21.2",
|
|
77
79
|
"express-logging": "1.1.1",
|
|
78
80
|
"extract-zip": "2.0.1",
|
|
79
81
|
"fastest-levenshtein": "1.0.16",
|
|
@@ -111,13 +113,11 @@
|
|
|
111
113
|
"maxstache": "1.0.7",
|
|
112
114
|
"maxstache-stream": "1.0.4",
|
|
113
115
|
"multiparty": "4.2.3",
|
|
114
|
-
"netlify": "13.
|
|
115
|
-
"netlify-headers-parser": "7.1.4",
|
|
116
|
-
"netlify-redirect-parser": "14.3.0",
|
|
116
|
+
"netlify": "13.2.0",
|
|
117
117
|
"netlify-redirector": "0.5.0",
|
|
118
118
|
"node-fetch": "3.3.2",
|
|
119
119
|
"node-version-alias": "3.4.1",
|
|
120
|
-
"ora": "8.1.
|
|
120
|
+
"ora": "8.1.1",
|
|
121
121
|
"p-filter": "4.1.0",
|
|
122
122
|
"p-map": "7.0.2",
|
|
123
123
|
"p-wait-for": "5.0.2",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Docs on event and context https://docs.netlify.com/functions/build/#code-your-function-2
|
|
2
|
-
const handler = async (event) => {
|
|
3
|
-
try {
|
|
4
|
-
const subject = event.queryStringParameters.name || 'World'
|
|
5
|
-
return {
|
|
6
|
-
statusCode: 200,
|
|
7
|
-
body: JSON.stringify({ message: `Hello ${subject}` }),
|
|
8
|
-
// // more keys you can return:
|
|
9
|
-
// headers: { "headerName": "headerValue", ... },
|
|
10
|
-
// isBase64Encoded: true,
|
|
11
|
-
}
|
|
12
|
-
} catch (error) {
|
|
13
|
-
return { statusCode: 500, body: error.toString() }
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = { handler }
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// note - this function MUST be named `identity-signup` to work
|
|
2
|
-
// we do not yet offer local emulation of this functionality in Netlify Dev
|
|
3
|
-
//
|
|
4
|
-
// more:
|
|
5
|
-
// https://www.netlify.com/blog/2019/02/21/the-role-of-roles-and-how-to-set-them-in-netlify-identity/
|
|
6
|
-
// https://docs.netlify.com/functions/functions-and-identity/
|
|
7
|
-
|
|
8
|
-
const handler = async function (event) {
|
|
9
|
-
const data = JSON.parse(event.body)
|
|
10
|
-
const { user } = data
|
|
11
|
-
|
|
12
|
-
const responseBody = {
|
|
13
|
-
app_metadata: {
|
|
14
|
-
roles: user.email.split('@')[1] === 'trust-this-company.com' ? ['editor'] : ['visitor'],
|
|
15
|
-
my_user_info: 'this is some user info',
|
|
16
|
-
},
|
|
17
|
-
user_metadata: {
|
|
18
|
-
// append current user metadata
|
|
19
|
-
...user.user_metadata,
|
|
20
|
-
custom_data_from_function: 'hurray this is some extra metadata',
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
statusCode: 200,
|
|
25
|
-
body: JSON.stringify(responseBody),
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = { handler }
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sanity-create",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "netlify functions:create - Create documents in Sanity.io",
|
|
5
|
-
"main": "sanity-create.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"netlify",
|
|
11
|
-
"serverless",
|
|
12
|
-
"js",
|
|
13
|
-
"sanity"
|
|
14
|
-
],
|
|
15
|
-
"author": "Sanity.io",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@sanity/client": "^0.147.3"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const process = require('process')
|
|
2
|
-
|
|
3
|
-
const sanityClient = require('@sanity/client')
|
|
4
|
-
|
|
5
|
-
// You will need to configure environment variables for Sanity.io project id,
|
|
6
|
-
// dataset name, and a token with write access. The variables are named
|
|
7
|
-
//
|
|
8
|
-
// SANITY_PROJECTID
|
|
9
|
-
// SANITY_DATASET
|
|
10
|
-
// SANITY_TOKEN
|
|
11
|
-
//
|
|
12
|
-
// Create a Sanity.io token at https://manage.sanity.io by selecting your
|
|
13
|
-
// project, going to Settings -> API and adding a new token with write access.
|
|
14
|
-
//
|
|
15
|
-
// Read more about configuring Netlify environment variables at
|
|
16
|
-
// https://docs.netlify.com/configure-builds/environment-variables/#declare-variables
|
|
17
|
-
const client = sanityClient({
|
|
18
|
-
projectId: process.env.SANITY_PROJECTID,
|
|
19
|
-
dataset: process.env.SANITY_DATASET,
|
|
20
|
-
token: process.env.SANITY_TOKEN,
|
|
21
|
-
useCdn: false,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// A function for writing to a Sanity.io dataset with a write access token.
|
|
25
|
-
//
|
|
26
|
-
// In this example we accept POST requests with the following JSON body
|
|
27
|
-
//
|
|
28
|
-
// {
|
|
29
|
-
// "author": "A name",
|
|
30
|
-
// "message": "What I want to say"
|
|
31
|
-
// }
|
|
32
|
-
//
|
|
33
|
-
// Then we construct an object to save in Sanity.io and return the full saved
|
|
34
|
-
// object back to our caller
|
|
35
|
-
const handler = async (event) => {
|
|
36
|
-
if (!event.httpMethod === 'POST') {
|
|
37
|
-
return {
|
|
38
|
-
statusCode: 400,
|
|
39
|
-
body: 'unrecognized HTTP Method, only POST allowed',
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const payload = JSON.parse(event.body)
|
|
44
|
-
if (!payload.message) {
|
|
45
|
-
return { status: 400, body: "Missing 'message'" }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const document = {
|
|
49
|
-
_type: 'comment',
|
|
50
|
-
// Some workflow state
|
|
51
|
-
status: 'waitingApproval',
|
|
52
|
-
author: payload.author || 'Anonymous',
|
|
53
|
-
message: payload.message,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const result = await client.create(document)
|
|
58
|
-
return {
|
|
59
|
-
statusCode: 200,
|
|
60
|
-
headers: { 'Content-Type': 'application/json' },
|
|
61
|
-
body: JSON.stringify(result),
|
|
62
|
-
}
|
|
63
|
-
} catch (error) {
|
|
64
|
-
return {
|
|
65
|
-
headers: { 'Content-Type': 'application/json' },
|
|
66
|
-
statusCode: 500,
|
|
67
|
-
body: error.responseBody || JSON.stringify({ error: 'An error occurred' }),
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
module.exports = { handler }
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sanity-groq",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "netlify functions:create - Query a Sanity.io dataset with GROQ",
|
|
5
|
-
"main": "sanity-groq.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"netlify",
|
|
11
|
-
"serverless",
|
|
12
|
-
"js",
|
|
13
|
-
"sanity",
|
|
14
|
-
"GROQ"
|
|
15
|
-
],
|
|
16
|
-
"author": "Sanity.io",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@sanity/client": "^0.147.3"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const process = require('process')
|
|
2
|
-
|
|
3
|
-
const sanityClient = require('@sanity/client')
|
|
4
|
-
|
|
5
|
-
// You will need to configure environment variables for Sanity.io project id
|
|
6
|
-
// and dataset name. Optionally you may also configure a token, useful for
|
|
7
|
-
// reading private datasets or mutating data. The variables are named
|
|
8
|
-
//
|
|
9
|
-
// SANITY_PROJECTID
|
|
10
|
-
// SANITY_DATASET
|
|
11
|
-
// SANITY_TOKEN
|
|
12
|
-
//
|
|
13
|
-
// Read more about configuring environment variables at
|
|
14
|
-
// https://docs.netlify.com/configure-builds/environment-variables/#declare-variables
|
|
15
|
-
const client = sanityClient({
|
|
16
|
-
projectId: process.env.SANITY_PROJECTID,
|
|
17
|
-
dataset: process.env.SANITY_DATASET,
|
|
18
|
-
token: process.env.SANITY_TOKEN,
|
|
19
|
-
// CDN will not be used if token is set
|
|
20
|
-
useCdn: true,
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
// A proxy for Sanity.io GROQ queries.
|
|
24
|
-
//
|
|
25
|
-
// Useful for querying private datasets with a token. Usually you will restrict
|
|
26
|
-
// access to this function with for example Netlify Identity.
|
|
27
|
-
//
|
|
28
|
-
// To explore what queries you can do with GROQ, check out the cheat sheet at
|
|
29
|
-
// https://www.sanity.io/docs/query-cheat-sheet
|
|
30
|
-
//
|
|
31
|
-
// Create Sanity.io tokens at https://manage.sanity.io
|
|
32
|
-
//
|
|
33
|
-
// Read more about restricting access to your Netlify functions at
|
|
34
|
-
// https://www.netlify.com/blog/2018/03/29/jamstack-architecture-on-netlify-how-identity-and-functions-work-together/#restricting-access
|
|
35
|
-
const handler = async (event) => {
|
|
36
|
-
const { query = '' } = event.queryStringParameters
|
|
37
|
-
// The rest of the query params are handled as parameters to the query
|
|
38
|
-
const params = { ...event.queryStringParameters, query: null }
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const result = await client.fetch(query, params)
|
|
42
|
-
return {
|
|
43
|
-
statusCode: 200,
|
|
44
|
-
headers: { 'Content-Type': 'application/json' },
|
|
45
|
-
body: JSON.stringify(result),
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return {
|
|
49
|
-
headers: { 'Content-Type': 'application/json' },
|
|
50
|
-
statusCode: error.statusCode || 500,
|
|
51
|
-
body: error.responseBody || JSON.stringify({ error: 'Unknown error occurred' }),
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = { handler }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const { schedule } = require('@netlify/functions')
|
|
2
|
-
|
|
3
|
-
// To learn about scheduled functions and supported cron extensions,
|
|
4
|
-
// see: https://ntl.fyi/sched-func
|
|
5
|
-
module.exports.handler = schedule('* * * * *', async (event) => {
|
|
6
|
-
const eventBody = JSON.parse(event.body)
|
|
7
|
-
console.log(`Next function run at ${eventBody.next_run}.`)
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
statusCode: 200,
|
|
11
|
-
}
|
|
12
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "submission-created",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "netlify functions:create - template for submission-created event triggered function",
|
|
5
|
-
"main": "submission-created.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"netlify",
|
|
11
|
-
"serverless",
|
|
12
|
-
"js"
|
|
13
|
-
],
|
|
14
|
-
"author": "Netlify",
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"node-fetch": "^3.0.0"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// // optionally configure local env vars
|
|
2
|
-
// require('dotenv').config()
|
|
3
|
-
|
|
4
|
-
// // details in https://css-tricks.com/using-netlify-forms-and-netlify-functions-to-build-an-email-sign-up-widget
|
|
5
|
-
const process = require('process')
|
|
6
|
-
|
|
7
|
-
const fetch = require('node-fetch')
|
|
8
|
-
|
|
9
|
-
const { EMAIL_TOKEN } = process.env
|
|
10
|
-
const handler = async (event) => {
|
|
11
|
-
const { email } = JSON.parse(event.body).payload
|
|
12
|
-
console.log(`Received a submission: ${email}`)
|
|
13
|
-
try {
|
|
14
|
-
const response = await fetch('https://api.buttondown.email/v1/subscribers', {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
headers: {
|
|
17
|
-
Authorization: `Token ${EMAIL_TOKEN}`,
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify({ email }),
|
|
21
|
-
})
|
|
22
|
-
const data = await response.json()
|
|
23
|
-
console.log(`Submitted to Buttondown:\n ${data}`)
|
|
24
|
-
} catch (error) {
|
|
25
|
-
return { statusCode: 422, body: String(error) }
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = { handler }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Handler } from '@netlify/functions'
|
|
2
|
-
|
|
3
|
-
export const handler: Handler = async (event, context) => {
|
|
4
|
-
const { name = 'stranger' } = event.queryStringParameters
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
statusCode: 200,
|
|
8
|
-
body: JSON.stringify({
|
|
9
|
-
message: `Hello, ${name}!`,
|
|
10
|
-
}),
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { schedule } from '@netlify/functions'
|
|
2
|
-
|
|
3
|
-
// To learn about scheduled functions and supported cron extensions,
|
|
4
|
-
// see: https://ntl.fyi/sched-func
|
|
5
|
-
export const handler = schedule('@hourly', async (event) => {
|
|
6
|
-
const eventBody = JSON.parse(event.body)
|
|
7
|
-
console.log(`Next function run at ${eventBody.next_run}.`)
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
statusCode: 200,
|
|
11
|
-
}
|
|
12
|
-
})
|