deploy appwrite function
All checks were successful
/ test (push) Successful in 19s

This commit is contained in:
Dovi Cowan 2024-07-26 01:05:57 +01:00
parent 82d65466dd
commit 51785f0853
Signed by: dcowan
GPG key ID: CC4A4CB950D7E579
8 changed files with 247 additions and 2 deletions

View file

@ -4,5 +4,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: | - run: |
echo $PWD npm install
ls -la npx appwrite client \
--endpoint ${{ vars.APPWRITE_ENDPOINT }} \
--projectId ${{ vars.APPWRITE_PROJECT_ID }} \
--key ${{ secrets.APPWRITE_API_KEY }}
npx appwrite deploy function --all

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules/

24
appwrite.json Normal file
View file

@ -0,0 +1,24 @@
{
"projectId": "66a2d6c20021107d3343",
"projectName": "Forgejo Actions Test",
"functions": [
{
"$id": "66a2d6e74666ca0797f7",
"name": "demo-web",
"runtime": "node-20.0",
"execute": [ "any" ],
"events": [],
"schedule": "",
"timeout": 15,
"enabled": true,
"logging": true,
"entrypoint": "src/main.js",
"commands": "npm install",
"ignore": [
"node_modules",
".npm"
],
"path": "functions/demo-web"
}
]
}

130
functions/demo-web/.gitignore vendored Normal file
View file

@ -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.*

View file

@ -0,0 +1,46 @@
# demo-web
## 🧰 Usage
### GET /
- Returns a "Hello, World!" message.
**Response**
Sample `200` Response:
```text
Hello, World!
```
### 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 (20.0) |
| Entrypoint | `src/main.js` |
| Build Commands | `npm install` |
| Permissions | `any` |
| Timeout (Seconds) | 15 |
## 🔒 Environment Variables
No environment variables required.

View file

@ -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": "^13.0.0"
},
"devDependencies": {
"prettier": "^3.2.5"
}
}

View file

@ -0,0 +1,19 @@
// This is your Appwrite function
// It's executed each time we get a request
export default async ({ req, res, log, error }) => {
// The `req` object contains the request data
if (req.method === 'GET') {
switch (req.path) {
case "/":
return res.send('Hello, World!');
break;
default:
return res.send("Invalid route", 404)
break;
}
}
return res.send("Invalid request", 405)
};

5
package.json Normal file
View file

@ -0,0 +1,5 @@
{
"dependencies": {
"appwrite-cli": "^5.0.5"
}
}