Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update function templates to v2 #6939

Merged
merged 8 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = {
},
// Example functions
{
files: ['functions-templates/**/*.js'],
files: ['functions-templates/**/*.mjs', 'functions-templates/**/*.mts'],
rules: {
'require-await': 0,
'import/no-unresolved': 0,
Expand All @@ -80,6 +80,8 @@ module.exports = {
'no-undef': 0,
'no-unused-vars': 0,
'arrow-body-style': 0,
'n/no-unsupported-features/node-builtins': 0,
camelcase: 0,
},
parserOptions: {
sourceType: 'module',
Expand Down
17 changes: 0 additions & 17 deletions functions-templates/javascript/hello-world/{{name}}.js

This file was deleted.

13 changes: 13 additions & 0 deletions functions-templates/javascript/hello-world/{{name}}.mjs
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,
})
}
}

This file was deleted.

29 changes: 0 additions & 29 deletions functions-templates/javascript/identity-signup/{{name}}.js

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions functions-templates/javascript/sanity-create/package.json

This file was deleted.

72 changes: 0 additions & 72 deletions functions-templates/javascript/sanity-create/{{name}}.js

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions functions-templates/javascript/sanity-groq/package.json

This file was deleted.

56 changes: 0 additions & 56 deletions functions-templates/javascript/sanity-groq/{{name}}.js

This file was deleted.

12 changes: 0 additions & 12 deletions functions-templates/javascript/scheduled-function/{{name}}.js

This file was deleted.

11 changes: 11 additions & 0 deletions functions-templates/javascript/scheduled-function/{{name}}.mjs
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',
}

This file was deleted.

19 changes: 0 additions & 19 deletions functions-templates/javascript/submission-created/package.json

This file was deleted.

29 changes: 0 additions & 29 deletions functions-templates/javascript/submission-created/{{name}}.js

This file was deleted.

14 changes: 14 additions & 0 deletions functions-templates/typescript/hello-world/{{name}}.mts
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,
})
}
}
12 changes: 0 additions & 12 deletions functions-templates/typescript/hello-world/{{name}}.ts

This file was deleted.

11 changes: 11 additions & 0 deletions functions-templates/typescript/scheduled-function/{{name}}.mts
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"
}
Loading
Loading