New at Begin: add and manage routes via manifest file
by Brian Leroux
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:
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 /todosuses your handler code in
src/http/get-todos/index.jsto service GETs
post /todosuses your handler code in
src/http/post-todos/index.jsto service POSTs to
post /todos/deleteuses your handler code in
src/http/post-todos-delete/index.jsto service POSTS to
Create a new route in five easy steps
Ready to give it a go?
- Head to your app’s repo folder
- Open the
app.arcfile in your root
- Find (or add) the
@httppragma, and on a new line, add a route (such as
- Start the local dev environment (
npm start) to generate any new HTTP Function handlers
- 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.arcfile has a commented warning about not editing it, go ahead and remove that – it’s time to start editing that file!
- Deploy an AVA example app to Begin in 15 seconds:
- Try out another Begin tutorial, like a full CRUD app with Begin Data!
- 🌟 Check out (and star!) Begin’s open core OpenJS Architect on GitHub