110 async saveLogs() {
111 try {
112 if (typeof window !== 'undefined' && window?.fetch) {
113 const response = await fetch('/api/store-logs', {
114 method: 'POST',
115 headers: { 'Content-Type': 'application/json' },
132 async loadLogs() {
133 try {
134 if (typeof window !== 'undefined' && window?.fetch) {
135 const response = await fetch(`/api/load-logs?key=${this.storeKey}`);
136 if (response.ok) {
137 const data = await response.json();
122 // Log to server
123 try {
124 await fetch('./logger', {
125 method: 'POST',
126 headers: { 'Content-Type': 'text/plain' },
61 function clearLogs() {
62 if (confirm('Are you sure you want to clear all logs?')) {
63 fetch('./clear')
64 .then(response => {
65 if (response.ok) {
13The following vals could not be imported:
14
15- [steve/discordWebhook](https://www.val.town/v/steve/discordWebhook) - Failed to fetch val: {"statusCode":404,"error":"Not Found","message":"Could not find that val"}
16
17
19 : Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
20
21 // Fetch and log tweets
22 const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23 console.log("Response from socialDataSearch:", response);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function socialDataSearch(query: string): Promise<SocialDataResponse> {
4 const url = new URL("https://stevekrouse-socialdataproxy.web.val.run/twitter/search");
5 url.searchParams.set("query", query);
6 return await fetchJSON(url.toString(), {
7 bearer: Deno.env.get("valtown"),
8 });
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const discordWebhook = async ({
8 content: string;
9}) => {
10 const res = await fetch(url, {
11 method: "POST",
12 redirect: "follow",
19 : Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
20
21 // Fetch and log tweets
22 const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23 console.log("Response from socialDataSearch:", response);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function socialDataSearch(query: string): Promise<SocialDataResponse> {
4 const url = new URL("https://stevekrouse-socialdataproxy.web.val.run/twitter/search");
5 url.searchParams.set("query", query);
6 return await fetchJSON(url.toString(), {
7 bearer: Deno.env.get("valtown"),
8 });
12
13- `/push` will copy the contents from a list of vals specified in `config.json` and push them to a GitHub repo
14- `/deploy` is a GitHub webhook URL that will fetch contents from GitHub and update the code on Val Town
15
161. Fork this val
271. Add a `VAL_SECRET` env var to the val. Use this secret to sign the webhook POST request to the `/push` endpoint. Use this endpoint to commit vals from Val Town to your GitHub repo.
28
29### Example push to GitHub fetch
30
31You can use this example to POST to the `/push` endpoint to copy vals to GitHub.
46 const signature = await sign(body, secret);
47
48 const res = await fetch(url, {
49 method: "POST",
50 body,
89- [x] Monkey test
90- [x] Add setup instructions to readme
91- [x] Add example code for private webhook fetch
92- [x] Make val and repo public
93- [ ] Check modified date before export to GitHub??