-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update function templates to v2 (#6939)
* feat: hello-world js example to mjs * feat: remove identity example * feat: remove sanity templates * feat: scheduled function to esm * feat: remove submission-create example because 3rd party docs out of date * feat: typescript hello world and make js same * feat: typescript scheduled function * test: update tests
- Loading branch information
1 parent
4e668f2
commit 40dafd5
Showing
21 changed files
with
58 additions
and
326 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Docs on request and context https://docs.netlify.com/functions/build/#code-your-function-2 | ||
export default (request, context) => { | ||
try { | ||
const url = new URL(request.url) | ||
const subject = url.searchParams.get('name') || 'World' | ||
|
||
return new Response(`Hello ${subject}`) | ||
} catch (error) { | ||
return new Response(error.toString(), { | ||
status: 500, | ||
}) | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
functions-templates/javascript/identity-signup/.netlify-function-template.mjs
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
functions-templates/javascript/identity-signup/{{name}}.js
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
functions-templates/javascript/sanity-create/.netlify-function-template.mjs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
functions-templates/javascript/sanity-groq/.netlify-function-template.mjs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
functions-templates/javascript/scheduled-function/{{name}}.js
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
functions-templates/javascript/scheduled-function/{{name}}.mjs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// To learn about scheduled functions and supported cron extensions, | ||
// see: https://ntl.fyi/sched-func | ||
export default async (req) => { | ||
const { next_run } = await req.json() | ||
|
||
console.log('Received event! Next invocation at:', next_run) | ||
} | ||
|
||
export const config = { | ||
schedule: '@hourly', | ||
} |
5 changes: 0 additions & 5 deletions
5
functions-templates/javascript/submission-created/.netlify-function-template.mjs
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
functions-templates/javascript/submission-created/package.json
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
functions-templates/javascript/submission-created/{{name}}.js
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Context } from '@netlify/functions' | ||
|
||
export default (request: Request, context: Context) => { | ||
try { | ||
const url = new URL(request.url) | ||
const subject = url.searchParams.get('name') || 'World' | ||
|
||
return new Response(`Hello ${subject}`) | ||
} catch (error) { | ||
return new Response(error.toString(), { | ||
status: 500, | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
functions-templates/typescript/scheduled-function/{{name}}.mts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Config } from "@netlify/functions" | ||
|
||
export default async (req: Request) => { | ||
const { next_run } = await req.json() | ||
|
||
console.log("Received event! Next invocation at:", next_run) | ||
} | ||
|
||
export const config: Config = { | ||
schedule: "@hourly" | ||
} |
Oops, something went wrong.