Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
130 changes: 130 additions & 0 deletions hello-world/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
6 changes: 6 additions & 0 deletions hello-world/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
Comment thread
loks0n marked this conversation as resolved.
Outdated
"singleQuote": true
}
14 changes: 14 additions & 0 deletions hello-world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Hello World Function
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to give READMes structure. Ideally it should have all information developer would need to install it, configure it, and use it.

Here is my proposal, let me know what you think:

  1. Title
  2. Short description
  3. Installation Instructions
  • runtime (mention which it was tried on, mention others might or night not work)
  • env variables (name, isRequired, description, example value. If relevant, link to external docs)
  • entrypoint
  • build commands
  • recommended events (only if not empty)
  • recommended corn (only if not empty)
  • recommended timeout (only if not empty)
  • recommended permissions (only if not empty)
  1. How to use (like long description. document all possibilities - endpoints.. expected behaviour.. Like tests, but just written down)

Ideally we would have template README somewhere, so when we make new template, we use that as the base


This is a simple function that returns a "Hello, World!" message.

Navigate to the function in the browser, you should see a basic "Hello, World!" page.

Send a POST request to the function, and you will get a response that looks like this:
```json
{
"message": "Hello, World!"
}
```

The function also logs 'Hello, World' to the console.
31 changes: 31 additions & 0 deletions hello-world/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions hello-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "hello-world",
"version": "1.0.0",
"description": "",
"main": "src/main.js",
"type": "module",
"scripts": {
"format": "prettier --write src/**/*.js"
Comment thread
loks0n marked this conversation as resolved.
Comment thread
loks0n marked this conversation as resolved.
},
"author": "",
"license": "MIT",
Comment thread
loks0n marked this conversation as resolved.
Outdated
"devDependencies": {
"prettier": "^3.0.0"
}
}
23 changes: 23 additions & 0 deletions hello-world/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const staticFolder = path.join(__dirname, '../static')

export default async ({ req, res, log }) => {
Comment thread
loks0n marked this conversation as resolved.
Outdated
Comment thread
loks0n marked this conversation as resolved.
Outdated
log('Hello, World! 👋')
Comment thread
loks0n marked this conversation as resolved.
Outdated

if (req.method === 'GET') {
const html = fs
.readFileSync(path.join(staticFolder, 'index.html'))
.toString()
return res.send(html, 200, { 'Content-Type': 'text/html; charset=utf-8' })
}

return res.json({
message: 'Hello, World! 👋',
})
}
36 changes: 36 additions & 0 deletions hello-world/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello, World!</title>
<link rel="stylesheet" href="https://unpkg.com/@appwrite.io/pink" />
<link
rel="stylesheet"
href="https://unpkg.com/@appwrite.io/pink-icons"
/>
</head>
<body>
<main class="main-content">
<div class="top-cover u-padding-block-end-56">
<div class="container">
<div
class="u-flex u-gap-16 u-flex-justify-center u-margin-block-start-16"
>
<h1 class="heading-level-1">Hello, World!</h1>
<code class="u-un-break-text"></code>
</div>
<p
class="body-text-1 u-normal u-margin-block-start-8"
style="max-width: 50rem"
>
This is a simple example of how to use Appwrite
functions. Modify the <code>src/index.php</code> file to
Comment thread
loks0n marked this conversation as resolved.
Outdated
add your own logic.
</p>
</div>
</div>
</main>
</body>
</html>