Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 1 initial version #1

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM denoland/deno:latest

# Prevent interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive

# Install required dependencies
RUN apt-get update && apt-get install -y \
sudo \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Deno",
"image": "denoland/deno:latest",
"features": {
"ghcr.io/devcontainers/features/git:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"denoland.vscode-deno"
],
"settings": {
"deno.enable": true,
"deno.lint": true
}
}
},
"forwardPorts": [8000]
}
16 changes: 16 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ..:/workspace:cached
- deno-cache:/home/deno/.cache/deno
command: sleep infinity
ports:
- '8000:8000'

volumes:
deno-cache:
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.deno/
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
.env
deno.lock
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"files.autoSave": "afterDelay"
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Daytona
Copyright (c) 2025 Daytona

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
This repository contains a README file sample for Daytona Samples and the MIT License.
# Sample Deno

It can be used as a template to create sample repositories that can be added into [Daytona](https://github.com/daytonaio/daytona).

Once you finish your sample and it gets merged, you can open a PR in the Daytona repo and submit the sample into the [index file](https://github.com/daytonaio/daytona/blob/main/hack/samples/index.json).

# Sample <LANGUAGE/FRAMEWORK>

Sample description
This is an example Deno project used in Daytona.

---

Expand All @@ -17,18 +11,22 @@ Sample description
1. **Install Daytona**: Follow the [Daytona installation guide](https://www.daytona.io/docs/installation/installation/).
2. **Create the Workspace**:
```bash
daytona create <SAMPLE_REPO_URL>
daytona create https://github.com/daytonaio/sample-deno
```

... MORE STEPS IF NEEDED ...

4. **Start the Application**:
3. **Start the Application**:
```bash
command to start the app
deno task start
```
4. **Browse**

Browse to http://localhost:8000 and see the text message.

Browse to http://localhost:8000/api/hello and see the JSON message.

---

## ✨ Features

List of sample features (e.g. realtime chat app, standardized development environment with devcontainers)
standardized development environment with devcontainers

web API
27 changes: 27 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"tasks": {
"start": "deno run --allow-net server.ts",
"dev": "deno run --allow-net --watch server.ts",
"test": "deno test --allow-net",
"lint": "deno lint",
"fmt": "deno fmt"
},
"fmt": {
"useTabs": false,
"lineWidth": 80,
"indentWidth": 2,
"singleQuote": true,
"proseWrap": "always",
"semiColons": true
},
"lint": {
"rules": {
"tags": ["recommended"]
}
},
"imports": {
"std/": "https://deno.land/[email protected]/",
"oak/": "https://deno.land/x/[email protected]/",
"cors/": "https://deno.land/x/[email protected]/"
}
}
29 changes: 29 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Application, Router } from 'https://deno.land/x/[email protected]/mod.ts';

const app = new Application();
const router = new Router();
const port = 8000;

// Basic routing
router.get('/', (ctx) => {
ctx.response.body = 'Welcome to Deno!';
});

router.get('/api/hello', (ctx) => {
ctx.response.body = {
message: 'Hello from Deno!',
time: new Date().toISOString(),
};
});

// Use router
app.use(router.routes());
app.use(router.allowedMethods());

// Basic error handling
app.addEventListener('error', (evt) => {
console.log(evt.error);
});

console.log(`Server running on http://localhost:${port}`);
await app.listen({ port });