File tree 6 files changed +76
-0
lines changed
javascript/scheduled-function
typescript/scheduled-function
6 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ name : 'scheduled-function' ,
3
+ priority : 1 ,
4
+ description : 'Basic implementation of a scheduled function in JavaScript.' ,
5
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " {{name}}" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " netlify functions:create - scheduled function in JavaScript" ,
5
+ "main" : " {{name}}.js" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords" : [
10
+ " netlify" ,
11
+ " serverless" ,
12
+ " javascript" ,
13
+ " schedule"
14
+ ],
15
+ "author" : " Netlify" ,
16
+ "license" : " MIT" ,
17
+ "dependencies" : {
18
+ "@netlify/functions" : " ^0.11.0"
19
+ }
20
+ }
Original file line number Diff line number Diff line change
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
+ } )
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ name : 'scheduled-function' ,
3
+ priority : 1 ,
4
+ description : 'Basic implementation of a scheduled function in TypeScript.' ,
5
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " {{name}}" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " netlify functions:create - scheduled function in TypeScript" ,
5
+ "main" : " {{name}}.ts" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords" : [
10
+ " netlify" ,
11
+ " serverless" ,
12
+ " typescript" ,
13
+ " schedule"
14
+ ],
15
+ "author" : " Netlify" ,
16
+ "license" : " MIT" ,
17
+ "dependencies" : {
18
+ "@netlify/functions" : " ^0.11.0" ,
19
+ "@types/node" : " ^14.18.9" ,
20
+ "typescript" : " ^4.5.5"
21
+ }
22
+ }
Original file line number Diff line number Diff line change
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" , ( 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
+ } ) ;
You can’t perform that action at this time.
1 commit comments
github-actions[bot] commentedon Feb 4, 2022
📊 Benchmark results
Package size: 363 MB