101 <pre><code class="language-typescript">import { ValSession } from "${rawUrl}";
102
103// Generate a token from your valtown api key.
104const token = await ValSession.new(Deno.env.get("valtown"));
105
127});
128
129type valSessionApi = typeof routes;
130
131const client = hc<valSessionApi>(httpEndpoint);
132
133export class ValSession {
97 const { access_token } = await tokenResponse.json();
98
99 const userResponse = await fetch("https://api.github.com/user", {
100 headers: {
101 "Authorization": `token ${access_token}`,
14and the `excludes` for what you don't want to get notified for.
15
16You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
17
18## 2. Notification
22## Twitter Data & Limitations
23
24The Twitter API has become unusable. This val gets Twitter data via [SocialData](https://socialdata.tools),
25an affordable Twitter scraping API. In order to make this val easy for
26you to fork & use without signing up for another API, I am proxying
27SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy
28100 times per day, so be sure not to set this cron to run more than once every 15 min.
29
30If you want to run it more, get your own [SocialData](https://socialdata.tools)
31API token and pay for it directly.
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type ResultSet, type Row, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
78
79/* Val Town's Turso Proxy returns rows as an array of values
80 * Yet the LibSQL API has a Row type which behave as an array or object,
81 * ie you can access it via numerical index or string
82 */
17 <p>
18 We've recently made improvements to Val Town's security by
19 <a href="https://blog.val.town/blog/api-token-scopes" target="_blank" rel="noopener noreferrer">
20 providing granular control over val permissions</a>.
21 As part of the rollout, we updated all vals to a safer set of default permissions.
32```
33
34Refer to [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to fine-tune your query.
35
36### 3. Test API call
37Set `isProd = false` in the code if you are testing, to ensure there are enough tweets to display. <br>
38Toggle it back to `true` when you're ready to run this cron job in production.
52
53### 5. NOTE: Usage Limits
54This val uses the SocialData API for Twitter data:
55- **Proxies via Val Town's SocialDataProxy**: Limited to 100 calls/day for [**Val Town Pro users**](https://www.val.town/pricing).
56- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
8
9const stripe = new Stripe(Deno.env.get("stripe_sk_customer_readonly") as string, {
10 apiVersion: "2020-08-27",
11});
12
6const stripe = new Stripe(
7 Deno.env.get("TEST_STRIPE_SECRET") as string,
8 { apiVersion: "2023-10-16" },
9);
10
8
9const stripe = new Stripe(Deno.env.get("stripe_sk_customer_readonly") as string, {
10 apiVersion: "2020-08-27",
11});
12
8
9const stripe = new Stripe(Deno.env.get("stripe_sk_customer_readonly") as string, {
10 apiVersion: "2020-08-27",
11});
12