mirror of
https://github.com/seemueller-io/cluster.git
synced 2025-09-08 22:56:46 +00:00
Development environment functions
This commit is contained in:
3
packages/example-apps/example-node-service/.dockerignore
Normal file
3
packages/example-apps/example-node-service/.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
/node_modules
|
||||
/dist
|
||||
/.wrangler
|
@@ -0,0 +1,13 @@
|
||||
FROM node:20-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY deploy/example-service .
|
||||
|
||||
RUN npm install --production
|
||||
|
||||
EXPOSE 8787
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:8787 || exit 1
|
||||
|
||||
ENTRYPOINT ["npm", "run", "dev"]
|
1
packages/example-apps/example-node-service/app.env
Normal file
1
packages/example-apps/example-node-service/app.env
Normal file
@@ -0,0 +1 @@
|
||||
SOME_USELESS_ENV_VAR_TO_TEST_FUNCTIONALITY=completely-useless-value
|
36
packages/example-apps/example-node-service/main.ts
Normal file
36
packages/example-apps/example-node-service/main.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {parse} from "cookie";
|
||||
|
||||
export default {
|
||||
async fetch(request): Promise<Response> {
|
||||
// The name of the cookie
|
||||
const COOKIE_NAME = "session";
|
||||
const cookie = parse(request.headers.get("Cookie") || "");
|
||||
if (cookie[COOKIE_NAME] != null) {
|
||||
// Respond with the cookie value
|
||||
return new Response(`
|
||||
<html>
|
||||
<body>
|
||||
<h1>Cookie Status</h1>
|
||||
<p>Cookie '${COOKIE_NAME}' exists with value: ${cookie[COOKIE_NAME]}</p>
|
||||
</body>
|
||||
</html>
|
||||
`, {
|
||||
headers: {
|
||||
"Content-Type": "text/html"
|
||||
}
|
||||
});
|
||||
}
|
||||
return new Response(`
|
||||
<html>
|
||||
<body>
|
||||
<h1>Cookie Status</h1>
|
||||
<p>No cookie found <w></w>ith name: ${COOKIE_NAME}</p>
|
||||
</body>
|
||||
</html>
|
||||
`, {
|
||||
headers: {
|
||||
"Content-Type": "text/html"
|
||||
}
|
||||
});
|
||||
},
|
||||
} satisfies ExportedHandler;
|
15
packages/example-apps/example-node-service/package.json
Normal file
15
packages/example-apps/example-node-service/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "example-service",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "wrangler dev",
|
||||
"build": "wrangler build",
|
||||
"deploy": "wrangler deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"wrangler": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cookie": "^1.0.2"
|
||||
}
|
||||
}
|
18
packages/example-apps/example-node-service/tsconfig.json
Normal file
18
packages/example-apps/example-node-service/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compatibility_date": "2025-08-07",
|
||||
"main": "main.ts",
|
||||
"name": "example-service",
|
||||
"dev": {
|
||||
"ip": "0.0.0.0"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user