-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for Wrangler 2 and Kotlin 1.7.10
This uses the newer Worker syntax and removes some of the bespoke browser work now that Kotlin better supports JavaScript.
- Loading branch information
1 parent
195e97c
commit 8c574d8
Showing
10 changed files
with
37 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,7 @@ node_modules/ | |
.cargo-ok | ||
/index.js | ||
/build/ | ||
.idea | ||
.gradle | ||
.DS_Store | ||
kotlin-js-store |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
kotlin.code.style=official | ||
kotlin.code.style=official | ||
kotlin.js.ir.output.granularity=whole-program |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
{ | ||
"name": "{{ project-name }}", | ||
"name": "kotlin-worker-hello-world", | ||
"version": "1.0.0", | ||
"description": "Kotlin hello world for Cloudflare Workers", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "{{ authors }}", | ||
"license": "MIT", | ||
"devDependencies": { | ||
} | ||
"license": "MIT" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import org.w3c.fetch.Request | ||
import org.w3c.fetch.Response | ||
import org.w3c.fetch.ResponseInit | ||
import org.w3c.workers.FetchEvent | ||
import kotlin.js.Promise | ||
|
||
external fun addEventListener(type: String, f: (FetchEvent) -> Unit) | ||
|
||
fun main() { | ||
addEventListener("fetch") { event: FetchEvent -> | ||
val headers: dynamic = object {} | ||
headers["content-type"] = "text/plain" | ||
event.respondWith( | ||
Promise.resolve( | ||
Response( | ||
"Kotlin Worker hello world", | ||
ResponseInit(headers = headers) | ||
) | ||
) | ||
) | ||
} | ||
@OptIn(ExperimentalJsExport::class) | ||
@JsExport | ||
fun fetch(request: Request) : Response { | ||
val headers: dynamic = object {} | ||
headers["content-type"] = "text/plain" | ||
return Response( | ||
"Kotlin Worker hello world", | ||
ResponseInit(headers = headers) | ||
) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
name = "" | ||
type = "javascript" | ||
account_id = "" | ||
workers_dev = true | ||
route = "" | ||
zone_id = "" | ||
compatibility_date = "2022-08-11" |