DEV Community

Cover image for a first look at serverless cloud

Posted on • Updated on • Originally published at


a first look at serverless cloud

Serverless Cloud is a new serverless app platform from Serverless, Inc. Unlike the company's initial product, the Serverless Framework, it does not deploy your application directly to AWS. Instead, your apps are instantly deployed and live on a new hosting service in the cloud with a dashboard and real-time logs.



All the code for this project can be found on my GitHub.

Install Cloud CLI

Install @serverless/cloud from npm.

npm i -g @serverless/cloud
Enter fullscreen mode Exit fullscreen mode

Initialize Service

Create a blank folder on your local machine for your service's code and initialize your Serverless Cloud service with the cloud command.

mkdir ajcwebdev-serverless-cloud
cd ajcwebdev-serverless-cloud
Enter fullscreen mode Exit fullscreen mode

Your browser will open automatically and log you in via the CLI or provide a login link in the terminal. Once you are connected you will be given an activation code to enter when prompted.

Deploy to Staging Environment

Give you service a name and deploy it with deploy dev in the interactive terminal.

deploy dev
Enter fullscreen mode Exit fullscreen mode

You can also use cloud deploy dev if you want to clone one of these projects from a repo and immediately deploy it.

cloud deploy dev
Enter fullscreen mode Exit fullscreen mode

You will be given a deployed endpoint with a sample todo app.


Add a few todos.


The @serverless/cloud package is included by default in the cloud runtime, so it does not need to be included as a dependency in package.json.

  "name": "ajcwebdev-serverless-cloud",
  "version": "1.0.0",
  "description": "Serverless Cloud todo api",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "cloud",
    "test": "cloud test"
  "devDependencies": {
    "@jest/globals": "^27.1.0",
    "@serverless/cloud": "^0.0.22"
  "serverless": {
    "org": "ajcwebdev",
    "service": "ajcwebdev-serverless-cloud"
Enter fullscreen mode Exit fullscreen mode

Index Entry File

We import a handful of modules from @serverless/cloud at the top of our index.js file.

// index.js

import {
  api, data, schedule, params
} from '@serverless/cloud'

api.get('/todos', async (req, res) => {...})'/todos/:id', async (req, res) => {...})
api.delete('/todos/:id', async (req, res) => {...})

api.use((err, req, res, next) => {...})

schedule.every("60 minutes", async () => {...})

const getTodos = async (status, meta) => {...}
Enter fullscreen mode Exit fullscreen mode
  • api is used to build REST APIs.
    • api.get - GET method
    • - POST method
    • api.delete - DELETE method
    • api.use - Middleware
  • data is used to access Serverless Data.
    • data.get - Reads the data
    • data.getByLabel - Reads the data with a specified label
    • data.set - Writes the data to storage
    • data.remove - Deletes the data
  • schedule is used to create scheduled tasks.
    • schedule.every - Runs on a specified interval of time such as every 60 minutes

getTodos Function

This function can be reused in different API paths to get all the todos or to get a specific todo based on its label.

// index.js

const getTodos = async (status, meta) => {
  let result

  if (status === 'all') {
    result = await data.get('todo:*', meta)
  } else if (status === 'complete') {
    result =  await data.getByLabel('label1','complete:*', meta)
  } else {
    result = await data.getByLabel('label1','incomplete:*', meta)

  return {
      item => item.value
Enter fullscreen mode Exit fullscreen mode

GET Todos

This function calls our getTodos function with the status and returns the results.

// index.js

api.get('/todos', async (req, res) => {
  let result = await getTodos(
    req.query.meta ? true : {}


    items: result.items
Enter fullscreen mode Exit fullscreen mode

POST Updates to a Todo

This function takes the body of the request and sets it to data. The body can include a duedate. It also includes an id, createdAt date, and status that can be complete or incomplete. After setting the todo, the getTodos query is run again on all the todos and the updated list is returned.

// index.js'/todos/:id', async (req, res) => {
  console.log(new Date().toISOString())

  let body = req.body
  if (body.duedate) {
    body.duedate = new Date(body.duedate).toISOString()

  await data.set(
      req.body.status ? 
          label1: body.status === 'complete'
            ? `complete:${new Date().toISOString()}` 
            : `incomplete:${body.duedate ? body.duedate : '9999' }` }
        : null

  let result = await getTodos(

    items: result.items
Enter fullscreen mode Exit fullscreen mode

Pay no attention to the ternary soup in Object.assign if it doesn't make any sense. Just try to leave it alone and don't touch it.


This function deletes the todo with data.remove and then queries and returns the remaining todos in the list.

// index.js

api.delete('/todos/:id', async (req, res) => {
  await data.remove(`todo:${}`)

  let result = await getTodos(req.query.status)

    items: result.items
Enter fullscreen mode Exit fullscreen mode

Custom Error Handler Middleware

This function provides middleware for error handling. Errors are also streamed live to your terminal in dev mode.

// index.js

api.use((err, req, res, next) => {

  if (!err.statusCode) {
    err.statusCode = 500

  const error = {
    statusCode: err.statusCode,
    message: err.message,

Enter fullscreen mode Exit fullscreen mode

Check for Overdue Todos Hourly

Sometimes you might want to run code on a schedule, like if you want to send alerts when items are overdue. This function looks for items that are overdue, loops through the overdue items, and sends an alert if necessary.

// index.js

schedule.every("60 minutes", async () => {
  console.log(`Checking for overdue TODOs...`)

  let overdueItems = await data.getByLabel(
    `incomplete:<${new Date().toISOString()}`

  if (overdueItems.items.length === 0) {
    console.log(`Nothing overdue!`)

  for (let item of overdueItems.items) {
      `ALERT: '${}' is overdue!!!`
Enter fullscreen mode Exit fullscreen mode

Sample Todos

Open data.json to see sample todos.

  "key": "todo:1",

  "value": { 
    "id": "1", 
    "name": "Deploy an amazing Serverless Cloud app",
    "status": "complete",
    "completed": "2021-07-01T12:00:00.000Z",
    "createdAt": 1627316142196

  "label1": "complete:2021-07-01T012:00:00.000Z"
Enter fullscreen mode Exit fullscreen mode


There are tests. One day I'll write a test, I promise.

Static Assets

You can serve up static assets from the static folder. The folder currently contains:

  • assets folder for images
  • index.html to serve the main page
  • styles.css for styling
  • todos.js for all the React code so you can scare the backend developers on your team

Modify HTML Index File and Deploy to Production

Change the <header> in index.html.

    <h1 class="text-center">
      ajcwebdev serverless cloud

    <h3 class="grey text-center">
      Seriously, there are so few servers you wouldn't believe it
Enter fullscreen mode Exit fullscreen mode

Deploy to production with cloud deploy prod or deploy prod in the interactive terminal session.

cloud deploy prod
Enter fullscreen mode Exit fullscreen mode

The link will be automatically pasted to your clipboard cause having to copy links is for noobs.



Since this is a cloud that means it has to have a dashboard, right? How else can I perform my ClickOps duties?


Serverless Cloud allows you to build services within your team's organization.


You can create as many services as you want for different use cases or applications.


Each instance is completely separate from all the other instances in a service and store their own copy of the data.


The environments within instances are identical, so you can ensure that your application will behave exactly the same across all of them.


Numbers that tell you information about stuff.



Pretty cool. Nothing blew up, it worked as expected, and I had a deployed application in under 10 seconds.


Top comments (5)

ch3ckmat3 profile image
Sohail Iqbal

Can we deploy @strapijs there?

ajcwebdev profile image
ajcwebdev • Edited

Good question! I'd say first of all that there's only one way to find out (try to deploy it and see if it works). But if I had to make a prediction I would guess that it's going to depend on two things:

  1. Is Serverless Cloud just for serverless functions like AWS Lambda or can you also run containers on it? I don't know and you'd have to ask the team behind the product.
  2. If you can't run containers on it, can Strapi be run in a serverless manner? According to the team, it is not a priority for them at this time. However, it looks like that are at least two implementations. I would start with these and see how far you can get.
ch3ckmat3 profile image
Sohail Iqbal

Thank you for a wholesome reply! Cheking the links at the moment.

Let's see if @strapijs has aything to say, as it is now over a year since the offcial reply to this question.

tonyscruze profile image

So basically Vercel but for Serverless Framework. Cool 😎

ajcwebdev profile image

One thing that I'm very curious about is what exactly is going on with the data. Is it being saved to a DynamoDB instance under the hood? Have they built their own persistence abstraction on some other AWS services?

To me that has always been the biggest weakness of platforms like Netlify and Vercel, they get you almost all the way there but then leave you hanging for the database. Supabase and Railway have done a great job filling this gap, but we still don't have a fully integrated solution with the possible exception of Amplify.

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git