Last active
November 29, 2024 11:51
-
-
Save janhicken/498ff7c8cfeee9621db52c295207611f to your computer and use it in GitHub Desktop.
Google Cloud Functions with Scala.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalajs.core.tools.linker.backend.ModuleKind.CommonJSModule | |
enablePlugins(ScalaJSPlugin) | |
name := "My Cloud Function" | |
scalaVersion := "2.12.6" | |
scalaJSUseMainModuleInitializer := false | |
scalaJSModuleKind := CommonJSModule | |
libraryDependencies += "io.scalajs.npm" %%% "express" % "0.4.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.janhicken.cfwithscala | |
import scala.scalajs.js.annotation.JSExportTopLevel | |
object CloudFunctions { | |
@JSExportTopLevel("helloWorld") | |
val helloWorld: CloudFunction = (request, response) ⇒ { | |
response.status(200).send("Hello World!") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.janhicken | |
import io.scalajs.npm.express.{Request, Response} | |
import scala.scalajs.js | |
package object cfwithscala { | |
type CloudFunction = js.Function2[Request, Response, Unit] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sbt fastOptJS | |
ln -s target/scala-2.1?/*-fastopt.js index.js | |
gcloud beta functions deploy helloWorld --trigger-http |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment