Back to APIs list![nbbaier avatar](https://secure.gravatar.com/avatar/0129a541b7b3574e92c4afd06c5e32da&d=identicon)
![nbbaier avatar](https://secure.gravatar.com/avatar/0129a541b7b3574e92c4afd06c5e32da&d=identicon)
![maas avatar](https://images.clerk.dev/uploaded/img_2QI1hYAv3xBAoZuqXD47rSFsQbZ.png)
![tr3ntg avatar](https://images.clerk.dev/oauth_github/img_2QyNgFrADFv8JHEaWwU4PAWF9zG.png)
![iamseeley avatar](https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvdXBsb2FkZWQvaW1nXzJsaWQ1T0xmZ2dwbk5kMWNOWW1yR2dIZDdHeCJ9)
![pomdtr avatar](https://images.clerk.dev/oauth_github/img_2RCoAITJZH1QencEgtVjh4Qirj4.jpeg)
![tmcw avatar](https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvdXBsb2FkZWQvaW1nXzJUbmdsaHJKczVGSDdSS1R5MGtjVVczVFRtTi5qcGVnIn0)
Github API examples & templates
Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
paginatedResponse
@nbbaier
Script
Return a paginated response A helper function to take an array and return a paginated response. This is useful when defining one's own folders for pomdtr's vscode extension . Usage: const data = [...]
export default async function(req: Request): Promise<Response> {
return paginatedResponse(req, data);
} For demo usage in the context of the vscode extension see this val .
saveToTana
@nbbaier
Script
Save To Tana This val provides a function saveToTana allows the creation of nodes in Tana via their Input API . The parameters are as follows: Token: to access the Tana Input API, you must pass an API token to the function. Obtain an API token from the Tana app and save it as a secret in Val Town. Node: the node that is created within Tana is passed as the second argument and must conform to the shape of an Input API node (see the documentation on github for details. Target node: optionally, you can specify a specific target node by passing a node ID to the function as it's third argument. Example Usage One way to use this val is with a web endpoint that you can send data to to have parsed and submitted to Tana as a specific type of node. For example, this val import { saveToTana } from "https://esm.town/v/nbbaier/saveToTana";
import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
import { Hono } from "npm:hono";
const token = Deno.env.get("tanaInputAPI");
export const honoTanaEndpoint = async (req: Request) => {
const app = new Hono();
app.get("/", async c => {
let { text, url } = c.req.query();
const payload: APIPlainNode = {
name: text,
children: [
{
type: "field",
attributeId: "cwi23sOzRSh8",
children: [
{
dataType: "url",
name: url,
},
],
},
],
supertags: [],
};
const newNode = await saveToTana(token, payload);
return c.json({ newNode });
});
return app.fetch(req);
}; Combined with a Chrome extension like Rich URL , the above val allows one to send selected text on a page along with that pages URL to Tana via the val's public GET endpoint.
![maas avatar](https://images.clerk.dev/uploaded/img_2QI1hYAv3xBAoZuqXD47rSFsQbZ.png)
forwarder
@maas
Script
Unlimited Anonymous Emails All code can be triggered via email ( docs ), i.e. maas.forwarder@valtown.email . You can generate as many emails as you want to avoid giving away your personal email address and reduce spam. Getting started Log in to Val Town Fork this Val Publish the Val via 🔒 > Unlisted Copy the email endpoint via ⋮ > Endpoints > Copy email address Sign up for newsletters or services using this email ( maas.forwarder@valtown.email ). To remove their ability to email you, simply delete the val (or send it to /dev/null ).
![tr3ntg avatar](https://images.clerk.dev/oauth_github/img_2QyNgFrADFv8JHEaWwU4PAWF9zG.png)
replaceEmojisWithImages
@tr3ntg
Express
Accepts an HTML string ( body.html ) and returns an emoji-escaped replacement. The purpose of this is due to official PDF spec's lack of support for emojis. This can be seen in the Anvil PDF Generation service as well - emojis are not rendered. node-emoji github here - replaces all emojis with spans emoji images for replacement are hosted at netlify (sourced from private repo)
resumeConfig
@iamseeley
Script
⚙️ configuration for hello, resume this guide will help you configure and use the resume builder to create your resume page. Ensure that your resume is formatted according to the JSON Resume standard . This is crucial for the resume builder to interpret and render your resume correctly. If you don't want to take the time to manually format your resume content and set up hosting, try using this: Resume to JSON 1. Configure the Resume JSON You have two options to provide your resume data: Resume JSON URL : Point this to your raw resume JSON hosted online. Recommended setups include using Val Town or a GitHub Gist. Example: resumeJsonUrl: 'https://example.com/resume.json' Paste Resume JSON : Provide the resume JSON directly within the configuration. Example: resumeJson: {
"basics": { "name": "John Doe" },
"work": [ ... ]
} 2. Choose a Theme Select a theme for your resume. You can use the predefined themes or create your own: Predefined Themes : starterTheme oceanTheme Custom Theme : Customize the styles in the starterTheme or create a new one and import it. 3. Custom Styles (Optional) If you want to add additional styles, provide a URL to a custom stylesheet: Example: customStyleUrl: 'https://example.com/styles.css' 4. Set the Section Order Customize the order of the sections in your resume: Default order: sectionOrder: ['header', 'summary', 'education', 'work', 'projects', 'volunteer', 'awards', 'certificates', 'publications', 'skills', 'languages', 'interests', 'references'] Example custom order: sectionOrder: ['header', 'summary', 'projects', 'education', 'work'] 5. Add Custom Sections (Optional) Override any default sections with custom sections: Example: customSections: {
header: customHeader
} 6. Show/Hide "Save as PDF" Button Control the visibility of the "Save asPDF" button: Example: savePDFIsVisible: true 7. View Your Resume Copy this resumeConfig's module URL and import it in your resumeHandler . Visit the resumeHandler HTTP endpoint to view your resume!
![pomdtr avatar](https://images.clerk.dev/oauth_github/img_2RCoAITJZH1QencEgtVjh4Qirj4.jpeg)
sunbeamValTownFn
@pomdtr
HTTP
Sunbeam integration for Val Town Installation First, install sunbeam . Then create a new val referencing this val. const sunbeamValtown = @pomdtr.sunbeamValTownFn(@me.secrets.valtown) then switch it's visibility to unlisted. You can then install your val in sunbeam # install the extension
sunbeam extension install --alias valtown val:<username>/sunbeamValtown Usage sunbeam valtown # list your vals
sunbeam valtown --help # list available commands Demo
dominoDomExample
@tmcw
Script
domino example Domino is an implementation of the document object model that you can use to build "webpages" without requiring a browser or a heavy browser-like abstraction. If you need even less DOM-compatibility and just want to parse some HTML, cheerio is an even more lightweight abstraction that works great.