Giter VIP home page Giter VIP logo

hello-functions-poc's Introduction

netlify functions proof of concept

Using netlify functions

Setup

Actually relatively straightforward.

In the file netlify/functions/hello.ts.

you have the following code

import { Handler, HandlerEvent, HandlerContext } from `netlify/functions`;

const handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {
  return {
    statusCode: 200,
    body: JSON.stringify({ message: "Hello World" }),
  };
};

export { handler };

You need the following packages

npm install --save-dev typescript && npm install @netlify/functions
# set up typescript
npx tsc --init
# maybe use netlify cli for development
npm install --save-dev netlify-cli

The following configuration is necessary for typescript.

{
...
  "compilerOptions":{
  ...
    "esModuleInterop" :true,
    "isolatedModules" :true,
  ...
  }
}

Development

With the netlify cli you can start a local development server

npx netlify dev

Deployment

Deployed just like a frontend via git push from repo.

The usual things are needed:

  • create a repo
  • push your code
  • connect to netlify site to github repo

The url of the function should then be <something>.netlify.app/.netlify/functions/hello.

From the docs

By default, all functions are provided with:

  • us-east-1 AWS Lambda region.
  • 1024 MB memory
  • 10 seconds execution limit for synchronous functions, including scheduled functions. 6 MB for request and response payload for synchronous functions. 256 KB for the size of the payload of request and response for background functions

If that's too little, then there are background Functions and in beta Edge Functions (which run in Deno instead of Nodejs and are deployed globally)

hello-functions-poc's People

Contributors

ff6347 avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar Ingo Hinterding avatar Dennis Ostendorf avatar  avatar

hello-functions-poc's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Branch Automerge

These updates await pending status checks before automerging. Click on a checkbox to abort the branch automerge, and create a PR instead.

  • chore(deps): update dependency netlify-cli to v12.7.2

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @netlify/functions 1.3.0
  • netlify-cli 12.5.0
  • typescript 4.9.4
nvm
.nvmrc
  • node v18.12.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.