New at Begin: add and manage routes via manifest file

Brian Leroux’s avatar

by Brian Leroux
@brianleroux
on

Route to code diagram

We’ve got some pretty big news for how you build apps on Begin: it’s finally possible to add and remove your app’s routes entirely via manifest file.

This crucial best practice for building modern applications is commonly known as infrastructure-as-code, and it’s a key enabler of iteration speed.

Our goal at Begin is to make you — and your apps — massively faster. A key ingredient in maximizing developer velocity is minimizing any friction related to iteration speed. Faster iteration equals faster developers.

Try it out right now

Hit this button to deploy a new CRUD app to Begin in 15 seconds. From there you’ll be able to add to its three existing routes:

deploy-to-begin

How it works

Infrastructure-as-code is the practice of provisioning and maintaining cloud infrastructure using a declarative manifest file. It’s like package.json, except for cloud resources like API Gateway, Lambda, and DynamoDB (all of which Begin apps use).

By checking in your Begin app’s project manifest (app.arc) file with your code, you can ensure you have exactly the cloud resources your code depends on. This is crucial for ensuring reproducibility and improving iteration speed.

Let’s take a look at it in practice. Here’s the app.arc file from the example CRUD app mentioned above:

@app
begin-app
@http
get  /todos
post /todos
post /todos/delete

In addition to serving a static index.html file at the root of your app, this manifest creates the cloud infrastructure for the above three defined routes as follows:

  • get /todos uses your handler code in src/http/get-todos/index.js to service GETs {your}.begin.app/todos
  • post /todos uses your handler code in src/http/post-todos/index.js to service POSTs to {your}.begin.app/todos
  • post /todos/delete uses your handler code in src/http/post-todos-delete/index.js to service POSTS to {your}.begin.app/todos/delete

Create a new route in five easy steps

Ready to give it a go?

  1. Head to your app’s repo folder
  2. Open the app.arc file in your root
  3. Find (or add) the @http pragma, and on a new line, add a route (such as get /foo or post /api/:itemID)
  4. Start the local dev environment (npm start) to generate any new HTTP Function handlers
  5. Push your changes!

Your new route(s) will instantly activate in staging. Then deploy to production to see them there, too.

If your app’s existing app.arc file has a commented warning about not editing it, go ahead and remove that – it’s time to start editing that file!

Next Steps

  • Deploy an AVA example app to Begin in 15 seconds:

deploy-to-begin