Val Town

Published

I found out about Val Town from a Lobsters thread and it’s pretty neat.

In their own words:

If GitHub Gists could run
And AWS Lambda was fun

Val Town is a social website to write and deploy TypeScript. Build APIs and schedule functions from your browser.

Man, I’m a sucker for a rhyme.

On Val Town you create vals (lowercased unless the start of a sentence).

There are (4) types of vals:

Additionally, they provide a standard library for blob storage, SQLite, and the ability to send emails.

They have a generous free tier and the single paid subscription is $10/month. I have not tried that out.

My motivation for trying out Val Town is 1) it’s a shiny new thing and shiny new things are cool and 2) I’ve been looking for a replacement to Webtask after they officially went dark. If you never used Webtask, it was a serverless JavaScript-y platform operated by (or maybe acquired by?) Auth0.

In fact, years ago I wrote a post on compiling SCSS to CSS on the fly. That’s the first thing I did with my freshly branded Val Town account. Behold: https://www.val.town/v/pinjasaur/sassy

And come on, under 30 lines of code to boot:

import sass from "npm:sass";

export default async function(req: Request): Promise<Response> {
  if (req.method !== "POST") {
    return Response.json({ error: "This val responds to POST requests." }, {
      status: 400,
    });
  }

  const body = await req.json();
  if (!body.sass) {
    return Response.json({ error: "No Sass" }, {
      status: 400,
    });
  }

  try {
    return Response.json({
      css: sass.compileString(body.sass).css.toString(),
    });
  } catch (err) {
    return Response.json({ error: err.message }, {
      status: 400,
    });
  }
}

After I got this working, I expanded that core business logic to fix one of my personal projects, cuetip. Since Webtask has been dead, so has one of the features I built into cuetip: custom builds. Essentially, taking in custom SCSS and compiling it to CSS on the fly. Go ahead and give it a try live on the docs site: https://pinjasaur.github.io/cuetip/customize

Once again, behold the val: https://www.val.town/v/pinjasaur/cuetip

The solution is imperfect, but works good enough for me. Interestingly enough, it was also the first time that I can recall needing to apply some custom logic to a HTTP OPTIONS request to make CORS play nice. I’m usually either blindly trying different header configurations or doing some debugging on the client side to see why my request is triggering CORS.

It’d be fun to play around with more of Val Town’s features, especially the cron and email triggers.

By the way, I noticed they’re hiring too. It’s a DevRel role with meaningful equity. Unfortunately I’m not in a position to relocate to NYC at this time, but maybe you (yes reader, you) could be a good fit. I’ll definitely be keeping my eyes peeled for the future: it seems like a tight-knit team working on a cool product.


I love hearing from readers so please feel free to reach out.

Reply via emailSubscribe via RSS or email

Last modified  #js   #sass   #programming 

🔗 Backlinks

← Newer post  •  Older post →