Serverless logo
Products
FRAMEWORK
Overview
CI/CD
Secrets
Plugins
Pricing
Signup
CONSOLE
Overview
Pricing
Signup
CLOUD
Overview
Pricing
FAQ
Signup
Company
ABOUT US
About
Careers
Contact Us
SUPPORT
Get Support
COMMUNITY
Slack
Forum
Partners
Meetups
LEARN
Blog
Examples
Guides
Serverless Cloud logoDocsPricingFAQ
Serverless Cloud Dashboard
Serverless Cloud logo
Serverless Cloud Dashboard
DocumentationPricingFAQ
Serverless logo
Serverless Cloud - Docs

Serverless Cloud – Documentation

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Item title

Item description

X
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Item title

Item description

Serverless logo
Product
Expand
Option 1Option 2Option 3
DocsPricing
Company
Expand

Feature 1

Lorem ipsum dolor emet sin dor lorem ipsum

Feature 2

Lorem ipsum dolor emet sin dor lorem ipsum

Feature 3

Lorem ipsum dolor emet sin dor lorem ipsum

Feature 4

Lorem ipsum dolor emet sin dor lorem ipsum
Search
Sales & Support
LoginSign Up
Open MenuClose Menu
Login / Sign Up
Go to GitHub
Serverless Cloud - Build full stack apps better and faster than everyone else | Product Hunt
Home
How it Works
Development Workflows
Building Applications
Link 1Link 1Link 1
Building Applications
Link 1Link 1Link 1
Building Applications
Link 1Link 1Link 1
Automated Testing
CLI Reference

Bring your own framework (BYOF)

Serverless Cloud provides a modern API framework that makes it easy to build and deploy cloud native APIs. However, if you're migrating an application that already uses a different HTTP framework, Serverless Cloud will support your framework's API routing capabilities while still allowing you to take advantage of our other features.

Supported frameworks

  • Connect
  • Express
  • Koa
  • Restana

Experimental support is also available for:

  • Sails
  • Hapi
  • Fastify
  • Restify
  • Polka

Importing your framework

HTTP frameworks like Connect and Express were designed to function as Node.js HTTP servers using ports and sockets to respond to requests. In modern distributed systems, each request is isolated and responds to events rather than HTTP requests. Serverless Cloud provides an http interface function that will import your existing HTTP framework and make it compatible with our platform.

// Import and initialize your framework
import express from "express"; // or any supported framework
const app = new express();

// Enable express body parsing middleware
app.use(express.json());

// Import the http interface and wrap your initialized app
import { http } from "@serverless/cloud";
http.use(app);

Then you can create routes and use middleware as usual.

  app.get("/", (req, res) => {
    ... do something here ...
  })

Using with GraphQL

GraphQL apis are supported with some additional boilerplate.

express-graphql

import { api } from "@serverless/cloud";
import { graphqlHTTP } from "express-graphql";
import { buildSchema, GraphQLSchema } from "graphql";

api.use("/graphql", graphqlHTTP({
  schema: schma,
  rootValue: rslvrs,
  graphiql: true,
}));

apollo-server-express

import { api } from "@serverless/cloud";
import { ApolloServer } from "apollo-server-express";

class ServerlessCloudApollo extends ApolloServer {
  serverlessFramework() {
    return true;
  }

  async ensureStarted(){
    await super.ensureStarted();
  }
}

const typeDefs = gql`
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => "Hello world!",
  },
};

const server = new ServerlessCloudApollo({ typeDefs, resolvers });
// you can use top-level await here as long as your package.json type is "module" and tsconfig has "module" and "target" set to esnext.
await server.ensureStarted();

api.use(server.getMiddleware({ path: '/graphql'}));

Limitations

Your code is running in a distributed serverless environment. You cannot rely on your server being 'up' in the sense that you can/should not use in-memory sessions, web sockets, etc. You are also subject to restrictions on Serverless Cloud's request/response size, maximum duration, etc.

Edit this page
Serverless logo
Product
Expand
Option 1Option 2Option 3
DocsPricing
Company
Expand

Feature 1

Lorem ipsum dolor emet sin dor lorem ipsum

Feature 2

Lorem ipsum dolor emet sin dor lorem ipsum

Feature 3

Lorem ipsum dolor emet sin dor lorem ipsum

Feature 4

Lorem ipsum dolor emet sin dor lorem ipsum
Search
Sales & Support
LoginSign Up
Open MenuClose Menu
FRAMEWORK
Overview
CI/CD
Secrets
Plugins
Pricing
CONSOLE
Overview
Pricing
Signup
RESOURCES
Framework DocsConsole DocsGuidesExamplesBlog
COMMUNITY
SlackMeetupsForum
SUPPORT
Contact UsPremium Support
COMPANY
AboutCareersPartners
Join our monthly newsletter
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
© 2022 Serverless, Inc. All rights reserved.
Terms of ServicePrivacy Policy