1import { createRestAPIClient } from "npm:masto";
2
3const masto = createRestAPIClient({
4 url: Deno.env.get("MASTO_INSTANCE_URL"),
5 accessToken: Deno.env.get("MASTO_ACCESS_TOKEN"),
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// Helper function to format the date for GitHub API query
4function formatDate(daysAgo: number): string {
5 const date = new Date();
13 const query = `stars:>${stars} created:>${date}`;
14 const response = await fetch(
15 `https://api.github.com/search/repositories?q=${query}&sort=stars&order=desc&per_page=10`,
16 )
17 .then((res) => res.json());
5 commit = false,
6): Promise<void> {
7 const resp = await fetch(`https://api.val.town/v1/vals/${val_id}`, {
8 headers: {
9 Authorization: "Bearer " + Deno.env.get("valtown"),
31 console.log(`Deleting Version ${v}`);
32 const resp = await fetch(
33 `https://api.val.town/v1/vals/${val_id}/versions/${v}`,
34 {
35 headers: {
42 if (commit) {
43 const resp = await fetch(
44 `https://api.val.town/v1/vals/${val_id}/versions/${v}`,
45 {
46 method: "DELETE",
1export default async function() {
2 const res = await fetch("https://api.manifold.markets/request-loan", {
3 headers: {
4 Authorization: `Key ${Deno.env.get("manifoldApiKey")}`,
5 },
6 });
1import { swaggerUI } from "npm:@hono/swagger-ui";
2import { z } from "npm:@hono/zod-openapi";
3import { createRoute, OpenAPIHono } from "npm:@hono/zod-openapi";
4import { html } from "npm:hono/html";
5
8 .string()
9 .min(3)
10 .openapi({
11 param: {
12 name: "id",
19const UserSchema = z
20 .object({
21 id: z.string().openapi({
22 example: "123",
23 }),
24 name: z.string().openapi({
25 example: "John Doe",
26 }),
27 age: z.number().openapi({
28 example: 42,
29 }),
30 })
31 .openapi("User");
32
33const route = createRoute({
49});
50
51const app = new OpenAPIHono();
52
53app.get("/", c => c.html(html`Try going to <a href="/ui">/ui</a>`));
54
55app.openapi(route, (c) => {
56 const { id } = c.req.valid("param");
57 return c.json({
62});
63
64// The OpenAPI documentation will be available at /doc
65app.doc("/doc", {
66 openapi: "3.0.0",
67 info: {
68 version: "1.0.0",
69 title: "My API",
70 },
71});
3Instructions:
41. Fork this Val.
52. Get your Manifold API key [from your profile](https://manifold.markets/profile).
63. Add `manifoldApiKey` with your key to the [Val Environment Variables](https://www.val.town/settings/environment-variables).
74. Hit run! It will run daily to collect your loans.
8
10 <style>
11 {`
12 @import url(https://fonts.googleapis.com/css?family=Droid+Serif);
13 @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
14 @import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
15
16 body {
35}
36
37export const apis = {
38 twemoji: (code: string) =>
39 `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${
56const emojiCache: Record<string, Promise<string>> = {};
57
58export async function loadEmoji (type: keyof typeof apis, code: string) {
59 const key = `${type}:${code}`;
60
63 }
64
65 if (!type || !apis[type]) {
66 type = "twemoji";
67 }
68
69 const api = apis[type];
70
71 if (typeof api === "function") {
72 return (emojiCache[key] = fetch(api(code)).then(async r => r.text()));
73 }
74 return (emojiCache[key] = fetch(`${api}${code.toUpperCase()}.svg`).then(async r =>
75 r.text()));
76}
2import process from "node:process";
3
4/** Must set process.env.WEATHER_API_KEY for weatherapi.com **/
5export async function getWeather(
6 query: string,
7 days = 10,
8): Promise<WeatherApiResponse> {
9 const weatherApiKey = process.env.WEATHER_API_KEY;
10 const q = encodeURIComponent(query);
11 const apiUrl = `https://api.weatherapi.com/v1/forecast.json?key=${weatherApiKey}&q=${q}&days=${days}`;
12 const response = await fetch(apiUrl);
13 const data: any = await response.json();
14 return data;
15}
16
17type WeatherApiResponse = {
18 location: {
19 name: string;
1API:`https://nishui-MusicAPI2.web.val.run?id=xxx`
2
3id 是网易云的音乐 id 值,使用此 API 将会访问网页的两个 API 去获取音乐信息和歌词信息
4
5我们用 req.url 获取 API 的url,然后再获取 url 的参数 id,这样就获取到对应的参数 id 了
6
72024年03月25日 不知道什么原因,获取 song 的 detail 失败,说是 `querystring/url must match format \"uri\`
8
9Migrated from folder: MusicPlatform/MusicAPI2