Skip to content

Commit 7c7cbe7

Browse files
committed
Convert to arc functions
Signed-off-by: macdonst <[email protected]>
1 parent af481ff commit 7c7cbe7

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

Diff for: src/http/get-robots/index.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import arc from '@architect/functions'
2-
import data from '@begin/data'
32
import { readFileSync } from 'node:fs'
43

4+
const { airobotstxt } = await arc.tables()
5+
56
async function get () {
67
// 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({
99
key: 'agents',
1010
})
1111
let robots = result?.robotsTxt || ''

Diff for: src/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ module.exports = {
2525
},
2626
]
2727
},
28+
tables () {
29+
return {
30+
name: 'airobotstxt',
31+
partitionKey: 'key',
32+
partitionKeyType: 'string',
33+
}
34+
},
2835
},
2936
}

Diff for: src/scheduled/check-robots-txt-feed/index.mjs

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
21
import { parseStringPromise } from 'xml2js'
3-
import data from '@begin/data'
2+
import arc from '@architect/functions'
3+
4+
const { airobotstxt } = await arc.tables()
45

56
export async function handler () {
67
// check the release feed from https://github.com/ai-robots-txt/ai.robots.txt
78
const updated = await getFeedUpdated()
89

910
// get the last time we checked
10-
let result = await data.get({
11-
table: 'ai-robots-txt',
11+
const result = await airobotstxt.get({
1212
key: 'updated',
1313
})
1414

@@ -38,15 +38,13 @@ async function getFeedUpdated () {
3838
}
3939

4040
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
5250
}

0 commit comments

Comments
 (0)