File tree 3 files changed +23
-18
lines changed
scheduled/check-robots-txt-feed
3 files changed +23
-18
lines changed Original file line number Diff line number Diff line change 1
1
import arc from '@architect/functions'
2
- import data from '@begin/data'
3
2
import { readFileSync } from 'node:fs'
4
3
4
+ const { airobotstxt } = await arc . tables ( )
5
+
5
6
async function get ( ) {
6
7
// Do we have an updated robots.txt in the DB?
7
- let result = await data . get ( {
8
- table : 'ai-robots-txt' ,
8
+ let result = await airobotstxt . get ( {
9
9
key : 'agents' ,
10
10
} )
11
11
let robots = result ?. robotsTxt || ''
Original file line number Diff line number Diff line change @@ -25,5 +25,12 @@ module.exports = {
25
25
} ,
26
26
]
27
27
} ,
28
+ tables ( ) {
29
+ return {
30
+ name : 'airobotstxt' ,
31
+ partitionKey : 'key' ,
32
+ partitionKeyType : 'string' ,
33
+ }
34
+ } ,
28
35
} ,
29
36
}
Original file line number Diff line number Diff line change 1
-
2
1
import { parseStringPromise } from 'xml2js'
3
- import data from '@begin/data'
2
+ import arc from '@architect/functions'
3
+
4
+ const { airobotstxt } = await arc . tables ( )
4
5
5
6
export async function handler ( ) {
6
7
// check the release feed from https://github.com/ai-robots-txt/ai.robots.txt
7
8
const updated = await getFeedUpdated ( )
8
9
9
10
// get the last time we checked
10
- let result = await data . get ( {
11
- table : 'ai-robots-txt' ,
11
+ const result = await airobotstxt . get ( {
12
12
key : 'updated' ,
13
13
} )
14
14
@@ -38,15 +38,13 @@ async function getFeedUpdated () {
38
38
}
39
39
40
40
async function updateDB ( { lastUpdated, robotsTxt } ) {
41
- return await data . set ( [
42
- {
43
- table : 'ai-robots-txt' ,
44
- key : 'updated' ,
45
- lastUpdated,
46
- } , {
47
- table : 'ai-robots-txt' ,
48
- key : 'agents' ,
49
- robotsTxt,
50
- } ,
51
- ] )
41
+ await airobotstxt . put ( {
42
+ key : 'updated' ,
43
+ lastUpdated,
44
+ } )
45
+ await airobotstxt . put ( {
46
+ key : 'agents' ,
47
+ robotsTxt,
48
+ } )
49
+ return
52
50
}
You can’t perform that action at this time.
0 commit comments