US Congress Stock Trading API examples & templates
Use these vals as a playground to view and fork US Congress Stock Trading API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
stevekrouse
dm
Script
DM Me! Ever wanted to message someone about their val but you couldn't find their contact info? Want to allow folks on Val Town to contact you without exposing your email address? Boy do I have the over-engineered solution for you! This is a userspace, authenticated protocol for Val Town direct messages. Protocol Expose a dm function on your namespace that that accepts messages and some authentication data (described below). The easiest way to accomplish this is to fork this val. What you choose to do with direct messages is totally up to you. At the moment, I email myself your message and save it to a private array val. You could forward it along to yourself some other way, batch up messages to get a daily summary email if you're Mr. Popular, or send them to /dev/null if you're Mr. Antisocial. Authentication This protocol uses my Val Town public key auth scheme , so you'll need to follow the first two steps of that blog post – (1) generate a keypair and (2) publish your public key – to authenticate to this function. Usage You can call this function via the @stevekrouse.runValAPIAuth helper: @stevekrouse.runValAPIAuth({
val: "@stevekrouse.dm",
args: ["hi steve!"],
keys: @me.exportedKeys,
}); Example: https://www.val.town/v/stevekrouseTest.untitled_tealMinnow
0
std
parse_email
Script
Parse email A small wrapper around email-addresses , an RFC 5322 email address parser. Usage import { parseAddressList } from "https://esm.town/v/std/parse_email";
console.log(parseAddressList('Steve <steve@val.town>, tom@val.town')); Should output: [
{
parts: {
name: {
name: "display-name",
tokens: "'Steve ",
semantic: "'Steve",
children: [ [Object] ]
},
address: {
name: "addr-spec",
tokens: "steve@val.town",
semantic: "steve@val.town",
children: [ [Object] ]
},
local: {
name: "local-part",
tokens: "steve",
semantic: "steve",
children: [ [Object] ]
},
domain: {
name: "domain",
tokens: "val.town",
semantic: "val.town",
children: [ [Object] ]
},
comments: [
{ name: "cfws", tokens: " ", semantic: " ", children: [Array] }
]
},
type: "mailbox",
name: "'Steve",
address: "steve@val.town",
local: "steve",
domain: "val.town",
comments: "",
groupName: null
},
{
parts: {
name: null,
address: {
name: "addr-spec",
tokens: " tom@val.town'",
semantic: "tom@val.town'",
children: [ [Object] ]
},
local: {
name: "local-part",
tokens: " tom",
semantic: "tom",
children: [ [Object] ]
},
domain: {
name: "domain",
tokens: "val.town'",
semantic: "val.town'",
children: [ [Object] ]
},
comments: [
{ name: "cfws", tokens: " ", semantic: "", children: [Array] }
]
},
type: "mailbox",
name: null,
address: "tom@val.town'",
local: "tom",
domain: "val.town'",
comments: "",
groupName: null
}
]
0
rozek
GDI_GoodMorning
Cron
This val is part of a series of examples to introduce "val.town" in my computer science course at
Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their
ideas into practice from the very beginning and implement web apps with
frontend and backend. It contains a simple script that is expected to be run every weekday at 6:00
and simply sends a "Good Morning" email with the current weather in Stuttgart
(Germany), a forecast for the day and (on fridays) a reminder not to forget to
attend the lecture "Grundlagen der Informatik". The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
0
![neverstew avatar](https://secure.gravatar.com/avatar/109fa713caf4e083c57622b7c6dad365.jpg?s=200&d=identicon)
neverstew
safeAssertBearerToken
Script
safeAssertBearerToken A safe version of assertBearerToken that handles errors and presents them as a property on the returned object instead. Example const handler = (req, res) => {
const authorization = req.get('authorization');
const { error, data: token } = @neverstew.safeAssertBearerToken(@me.secrets.superSecret, authorization);
if (error) {
res.status(401).send("Unauthorized");
return;
}
res.json(token);
}
0