← Public packages
@kentcdodds/space-shooter
Vertical scrolling spaceship shooter built with Three.js, playable on phone or desktop
src/app.ts
37 lines · 1.3 KB · TypeScriptimport { packageContext } from 'kody:runtime'
/**
* Serves the game page when it's hosted as a Kody package app. The browser
* client (`src/main.ts`) renders the game itself.
*/
export default {
async fetch() {
const assetBasePath = packageContext?.assetBasePath
const clientModuleUrl = packageContext?.clientModuleUrl
if (!assetBasePath || !clientModuleUrl) {
return new Response('Space Shooter must run as a Kody package app.', { status: 500 })
}
return new Response(
`<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, user-scalable=no" />
<meta name="theme-color" content="#04050d" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="icon" type="image/svg+xml" href="${assetBasePath}/icon.svg" />
<link rel="manifest" href="${assetBasePath}/manifest.webmanifest" />
<link rel="stylesheet" href="${assetBasePath}/style.css" />
<title>Space Shooter</title>
</head>
<body>
<script type="module" src="${clientModuleUrl}"></script>
</body>
</html>`,
{ headers: { 'content-type': 'text/html; charset=utf-8' } },
)
},
}