commit 672ed867a94389b547ff85670c1fc3f395d8bee0 Author: Eneko Nieto Date: Sun Jan 18 11:26:46 2026 +0100 first commit diff --git a/appwrite.config.json b/appwrite.config.json new file mode 100644 index 0000000..5cf6031 --- /dev/null +++ b/appwrite.config.json @@ -0,0 +1,63 @@ +{ + "projectId": "696bbb680032fc5192c9", + "projectName": "heater", + "settings": { + "services": { + "account": true, + "avatars": true, + "databases": true, + "locale": true, + "health": true, + "storage": true, + "teams": true, + "users": true, + "sites": true, + "functions": true, + "graphql": true, + "messaging": true + }, + "auth": { + "methods": { + "jwt": true, + "phone": true, + "invites": true, + "anonymous": true, + "email-otp": true, + "magic-url": true, + "email-password": true + }, + "security": { + "duration": 31536000, + "limit": 0, + "sessionsLimit": 10, + "passwordHistory": 0, + "passwordDictionary": false, + "personalDataCheck": false, + "sessionAlerts": false, + "mockNumbers": [] + } + } + }, + "functions": [ + { + "$id": "696bbbc3002c837e20d9", + "name": "aemet", + "runtime": "node-22", + "specification": "s-1vcpu-512mb", + "execute": [ + "any" + ], + "events": [], + "scopes": [ + "users.read" + ], + "schedule": "", + "timeout": 15, + "enabled": true, + "logging": true, + "entrypoint": "src/main.js", + "commands": "npm install", + "path": "functions/aemet" + } + ] +} \ No newline at end of file diff --git a/functions/aemet/.gitignore b/functions/aemet/.gitignore new file mode 100644 index 0000000..46afb6b --- /dev/null +++ b/functions/aemet/.gitignore @@ -0,0 +1,133 @@ +# 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.* + +# Directory used by Appwrite CLI for local development +.appwrite \ No newline at end of file diff --git a/functions/aemet/.prettierrc.json b/functions/aemet/.prettierrc.json new file mode 100644 index 0000000..0a72520 --- /dev/null +++ b/functions/aemet/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "semi": true, + "singleQuote": true +} diff --git a/functions/aemet/README.md b/functions/aemet/README.md new file mode 100644 index 0000000..47cc077 --- /dev/null +++ b/functions/aemet/README.md @@ -0,0 +1,46 @@ +# aemet + +## 🧰 Usage + +### GET /ping + +- Returns a "Pong" message. + +**Response** + +Sample `200` Response: + +```text +Pong +``` + +### GET, POST, PUT, PATCH, DELETE / + +- Returns a "Learn More" JSON response. + +**Response** + +Sample `200` Response: + +```json +{ + "motto": "Build like a team of hundreds_", + "learn": "https://appwrite.io/docs", + "connect": "https://appwrite.io/discord", + "getInspired": "https://builtwith.appwrite.io" +} +``` + +## ⚙️ Configuration + +| Setting | Value | +| ----------------- | ------------- | +| Runtime | Node (18.0) | +| Entrypoint | `src/main.js` | +| Build Commands | `npm install` | +| Permissions | `any` | +| Timeout (Seconds) | 15 | + +## 🔒 Environment Variables + +No environment variables required. diff --git a/functions/aemet/package-lock.json b/functions/aemet/package-lock.json new file mode 100644 index 0000000..b1896fc --- /dev/null +++ b/functions/aemet/package-lock.json @@ -0,0 +1,48 @@ +{ + "name": "starter-template", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "starter-template", + "version": "1.0.0", + "dependencies": { + "node-appwrite": "^20.2.1" + }, + "devDependencies": { + "prettier": "^3.2.5" + } + }, + "node_modules/node-appwrite": { + "version": "20.2.1", + "resolved": "https://registry.npmjs.org/node-appwrite/-/node-appwrite-20.2.1.tgz", + "integrity": "sha512-RweIh+3RHjprsxhWaJzcQr/UDMBMsZCma50TIJ9t3onVgs5jAT9aqFnsMlaaC9QZn1sXpPUQV90W6uvtm64DnQ==", + "license": "BSD-3-Clause", + "dependencies": { + "node-fetch-native-with-agent": "1.7.2" + } + }, + "node_modules/node-fetch-native-with-agent": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/node-fetch-native-with-agent/-/node-fetch-native-with-agent-1.7.2.tgz", + "integrity": "sha512-5MaOOCuJEvcckoz7/tjdx1M6OusOY6Xc5f459IaruGStWnKzlI1qpNgaAwmn4LmFYcsSlj+jBMk84wmmRxfk5g==", + "license": "MIT" + }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/functions/aemet/package.json b/functions/aemet/package.json new file mode 100644 index 0000000..fb9c115 --- /dev/null +++ b/functions/aemet/package.json @@ -0,0 +1,16 @@ +{ + "name": "starter-template", + "version": "1.0.0", + "description": "", + "main": "src/main.js", + "type": "module", + "scripts": { + "format": "prettier --write ." + }, + "dependencies": { + "node-appwrite": "^20.2.1" + }, + "devDependencies": { + "prettier": "^3.2.5" + } +} diff --git a/functions/aemet/src/main.js b/functions/aemet/src/main.js new file mode 100644 index 0000000..0539b5e --- /dev/null +++ b/functions/aemet/src/main.js @@ -0,0 +1,35 @@ +import { Client, Users } from 'node-appwrite'; + +// This Appwrite function will be executed every time your function is triggered +export default async ({ req, res, log, error }) => { + // You can use the Appwrite SDK to interact with other services + // For this example, we're using the Users service + const client = new Client() + .setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT) + .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) + .setKey(req.headers['x-appwrite-key'] ?? ''); + const users = new Users(client); + + try { + const response = await users.list(); + // Log messages and errors to the Appwrite Console + // These logs won't be seen by your end users + log(`Total users: ${response.total}`); + } catch(err) { + error("Could not list users: " + err.message); + } + + // The req object contains the request data + if (req.path === "/ping") { + // Use res object to respond with text(), json(), or binary() + // Don't forget to return a response! + return res.text("Pong"); + } + + return res.json({ + motto: "Build like a team of hundreds_", + learn: "https://appwrite.io/docs", + connect: "https://appwrite.io/discord", + getInspired: "https://builtwith.appwrite.io", + }); +};