intro
Getting Started (Javascript / Typescript)
What you'll need
Install node and npm
Before you begin, make sure you have node
and npm
installed on your machine. In future iterations of Ubiquitous Functions, node and npm will not be required.
- Node.js download - version 16.14 or above
- When installing Node.js, you are recommended to check all checkboxes related to dependencies.
- If you are on a Mac, you may want to consider using nvm rather than directly installing node.
Installing node
will also install npm
. You can update your npm
to the latest version by running npm i -g npm
.
Install the ubiquitous-cli
(macOS)
The command below will install the Ubiquitous CLI command ubiq
. ubiq.run is the short domain for the Ubiquitous Platform.
The Ubiquitous CLI is responsible for creating Ubiquitous Functions templates, running the examples locally, and actually hosts the entire, fully-featured Ubiquitous Platform on your developer machine, with a single command!
This is the same platform that you can run at scale, from a single machine to thousands, and is the same system that backs the cloud version as well!
One of the awesome advantages of the Ubiquitous Platform is that your local development experience is considered a first-class citizen in the ecosystem. Many serverless cloud products have a poor developer experience and expect you to build and test your platform in the cloud, lengthening feedback loops and generally just being a pain to work with.
Ubiquitous is different. Install it below to get started:
MacOS Installation
curl -fsSL https://ubiq.run/install | sh -
Creating your first function
We're going to write a "hello-world" function that receives a name as an input and returns the name as well as the number of letters in the name and the current date. This simple example will demonstrate how to interact with the Ubiquitous Functions runtime to process calls. We will wire this function up to an API and Use the following command to create a new Ubiquitous Function:
npx create-ubiquitous-function hello-world --typescript
This command will create a new directory called hello-world
with the necessary files to get started with the Ubiquitous Platform.
To get started, use the following command to create a new Ubiquitous Function:
npx create-ubiquitous-function hello-world --typescript
This command will create a new directory called hello-world
with the necessary files to get started with the Ubiquitous Platform.
Be sure to change into the directory before proceeding:
cd hello-world
Editing Your Function
Once you've created your function, you can edit it by opening the index.ts
file in your favorite code editor.
Testing Your Function
To test your function, you can use the following command:
npm test
This will run the tests in the test
directory.
Deploying Your Function
To deploy your function, you can use the following command:
ubiq deploy
This will deploy your function to the Ubiquitous Platform.
Conclusion
That's it! You now know how to create, edit, test, and deploy a function on the Ubiquitous Platform.
lukevp: Add steps before the npx command to install the ubiquitous-cli using the command curl -fsSL https://ubiq.run/install | sh -
GitHub Copilot: Here's the updated tutorial with the additional step to install the ubiquitous-cli
:
Getting Started with Ubiquitous Platform
Testing Your Function
To test your function, you can use the following command:
npm test
This will run the tests in the test
directory.
Deploying Your Function
To deploy your function, you can use the following command:
npm run deploy
This will deploy your function to the Ubiquitous Platform.
That's it! You now know how to create, edit, test, and deploy a function on the Ubiquitous Platform.