feat: using Bun instead of Node.js\!
This commit is contained in:
@@ -40,24 +40,22 @@
|
|||||||
},
|
},
|
||||||
"functions": [
|
"functions": [
|
||||||
{
|
{
|
||||||
"$id": "696bbbc3002c837e20d9",
|
"$id": "697270190009ebe7e1a1",
|
||||||
"name": "aemet",
|
"name": "aemet",
|
||||||
"runtime": "node-22",
|
"runtime": "bun-1.1",
|
||||||
"specification": "s-1vcpu-512mb",
|
"path": "functions/aemet",
|
||||||
|
"entrypoint": "src/main.ts",
|
||||||
"execute": [
|
"execute": [
|
||||||
"any"
|
"any"
|
||||||
],
|
],
|
||||||
"events": [],
|
|
||||||
"scopes": [
|
|
||||||
"users.read"
|
|
||||||
],
|
|
||||||
"schedule": "",
|
|
||||||
"timeout": 15,
|
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"logging": true,
|
"logging": true,
|
||||||
"entrypoint": "dist/main.js",
|
"events": [],
|
||||||
"commands": "npm install && npm run build",
|
"schedule": "",
|
||||||
"path": "functions/aemet"
|
"timeout": 15,
|
||||||
|
"commands": "bun install",
|
||||||
|
"scopes": [],
|
||||||
|
"specification": "s-0.5vcpu-512mb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
17
functions/aemet/.gitignore
vendored
17
functions/aemet/.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
### Node ###
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
@@ -102,7 +103,6 @@ dist
|
|||||||
|
|
||||||
# vuepress v2.x temp and cache directory
|
# vuepress v2.x temp and cache directory
|
||||||
.temp
|
.temp
|
||||||
.cache
|
|
||||||
|
|
||||||
# Docusaurus cache and generated files
|
# Docusaurus cache and generated files
|
||||||
.docusaurus
|
.docusaurus
|
||||||
@@ -129,5 +129,20 @@ dist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
### Node Patch ###
|
||||||
|
# Serverless Webpack directories
|
||||||
|
.webpack/
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
|
||||||
|
# SvelteKit build / generate output
|
||||||
|
.svelte-kit
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/node
|
||||||
|
|
||||||
|
# OS
|
||||||
|
## Mac
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# Directory used by Appwrite CLI for local development
|
# Directory used by Appwrite CLI for local development
|
||||||
.appwrite
|
.appwrite
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"trailingComma": "es5",
|
|
||||||
"tabWidth": 2,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": true
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
# aemet
|
# ⚡ Bun Starter Function
|
||||||
|
|
||||||
|
A simple starter function. Edit `src/main.ts` to get started and create something awesome! 🚀
|
||||||
|
|
||||||
## 🧰 Usage
|
## 🧰 Usage
|
||||||
|
|
||||||
@@ -35,11 +37,12 @@ Sample `200` Response:
|
|||||||
|
|
||||||
| Setting | Value |
|
| Setting | Value |
|
||||||
| ----------------- | ------------- |
|
| ----------------- | ------------- |
|
||||||
| Runtime | Node (18.0) |
|
| Runtime | Bun (1.0) |
|
||||||
| Entrypoint | `src/main.js` |
|
| Entrypoint | `src/main.ts` |
|
||||||
| Build Commands | `npm install` |
|
| Build Commands | `bun install` |
|
||||||
| Permissions | `any` |
|
| Permissions | `any` |
|
||||||
| Timeout (Seconds) | 15 |
|
| Timeout (Seconds) | 15 |
|
||||||
|
| Scopes | `users.read` |
|
||||||
|
|
||||||
## 🔒 Environment Variables
|
## 🔒 Environment Variables
|
||||||
|
|
||||||
|
|||||||
35
functions/aemet/bun.lock
Normal file
35
functions/aemet/bun.lock
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 1,
|
||||||
|
"workspaces": {
|
||||||
|
"": {
|
||||||
|
"name": "aemet",
|
||||||
|
"dependencies": {
|
||||||
|
"fast-xml-parser": "^5.3.3",
|
||||||
|
"node-appwrite": "^20.2.1",
|
||||||
|
"typescript": "^5.4.5",
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^22.19.0",
|
||||||
|
"prettier": "^3.2.5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@types/node": ["@types/node@22.19.7", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-MciR4AKGHWl7xwxkBa6xUGxQJ4VBOmPTF7sL+iGzuahOFaO0jHCsuEfS80pan1ef4gWId1oWOweIhrDEYLuaOw=="],
|
||||||
|
|
||||||
|
"fast-xml-parser": ["fast-xml-parser@5.3.3", "", { "dependencies": { "strnum": "^2.1.0" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-2O3dkPAAC6JavuMm8+4+pgTk+5hoAs+CjZ+sWcQLkX9+/tHRuTkQh/Oaifr8qDmZ8iEHb771Ea6G8CdwkrgvYA=="],
|
||||||
|
|
||||||
|
"node-appwrite": ["node-appwrite@20.3.0", "", { "dependencies": { "node-fetch-native-with-agent": "1.7.2" } }, "sha512-vaxlpkNTtjkccyngwc9HRSwQQasZ/CJri6KMZ62mlDAM1YdvOgqIM8EYJwvhx/fiHdyjfxithFcmnvzUR9TGTQ=="],
|
||||||
|
|
||||||
|
"node-fetch-native-with-agent": ["node-fetch-native-with-agent@1.7.2", "", {}, "sha512-5MaOOCuJEvcckoz7/tjdx1M6OusOY6Xc5f459IaruGStWnKzlI1qpNgaAwmn4LmFYcsSlj+jBMk84wmmRxfk5g=="],
|
||||||
|
|
||||||
|
"prettier": ["prettier@3.8.1", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg=="],
|
||||||
|
|
||||||
|
"strnum": ["strnum@2.1.2", "", {}, "sha512-l63NF9y/cLROq/yqKXSLtcMeeyOfnSQlfMSlzFt/K73oIaD8DGaQWd7Z34X9GPiKqP5rbSh84Hl4bOlLcjiSrQ=="],
|
||||||
|
|
||||||
|
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||||
|
|
||||||
|
"undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||||
|
}
|
||||||
|
}
|
||||||
8
functions/aemet/env.d.ts
vendored
Normal file
8
functions/aemet/env.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
declare module "bun" {
|
||||||
|
interface Env {
|
||||||
|
APPWRITE_FUNCTION_API_ENDPOINT: string;
|
||||||
|
APPWRITE_FUNCTION_PROJECT_ID: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
111
functions/aemet/package-lock.json
generated
111
functions/aemet/package-lock.json
generated
@@ -1,111 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "starter-template",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "starter-template",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"dependencies": {
|
|
||||||
"fast-xml-parser": "^5.3.3",
|
|
||||||
"node-appwrite": "^20.2.1",
|
|
||||||
"typescript": "^5.4.5"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^22.19.0",
|
|
||||||
"prettier": "^3.2.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/node": {
|
|
||||||
"version": "22.19.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.7.tgz",
|
|
||||||
"integrity": "sha512-MciR4AKGHWl7xwxkBa6xUGxQJ4VBOmPTF7sL+iGzuahOFaO0jHCsuEfS80pan1ef4gWId1oWOweIhrDEYLuaOw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"undici-types": "~6.21.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/fast-xml-parser": {
|
|
||||||
"version": "5.3.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.3.3.tgz",
|
|
||||||
"integrity": "sha512-2O3dkPAAC6JavuMm8+4+pgTk+5hoAs+CjZ+sWcQLkX9+/tHRuTkQh/Oaifr8qDmZ8iEHb771Ea6G8CdwkrgvYA==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/NaturalIntelligence"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"strnum": "^2.1.0"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"fxparser": "src/cli/cli.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/strnum": {
|
|
||||||
"version": "2.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.1.2.tgz",
|
|
||||||
"integrity": "sha512-l63NF9y/cLROq/yqKXSLtcMeeyOfnSQlfMSlzFt/K73oIaD8DGaQWd7Z34X9GPiKqP5rbSh84Hl4bOlLcjiSrQ==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/NaturalIntelligence"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/typescript": {
|
|
||||||
"version": "5.9.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
|
||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
|
||||||
"tsc": "bin/tsc",
|
|
||||||
"tsserver": "bin/tsserver"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14.17"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/undici-types": {
|
|
||||||
"version": "6.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
||||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "starter-template",
|
"name": "aemet",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/main.js",
|
"main": "src/main.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write ."
|
||||||
"build": "tsc"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fast-xml-parser": "^5.3.3",
|
"fast-xml-parser": "^5.3.3",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default async ({ req, res, log, error }: any) => {
|
|||||||
throw new Error(`Error! status: ${response.status}`);
|
throw new Error(`Error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const decoder = new TextDecoder('iso-8859-15');
|
const decoder = new TextDecoder('iso-8859-1'); // It should be iso-8859-15 but Bun 1.1 does not support it
|
||||||
let xml = decoder.decode(await response.arrayBuffer())
|
let xml = decoder.decode(await response.arrayBuffer())
|
||||||
|
|
||||||
const parser = new XMLParser();
|
const parser = new XMLParser();
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES2022",
|
|
||||||
"module": "NodeNext",
|
|
||||||
"rootDir": "src",
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"allowJs": true,
|
|
||||||
"outDir": "dist",
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"strict": true,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"skipLibCheck": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user