-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from appwrite/feat-update-starters
Feat: Update starters
- Loading branch information
Showing
35 changed files
with
469 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare module "bun" { | ||
interface Env { | ||
APPWRITE_FUNCTION_API_ENDPOINT: string; | ||
APPWRITE_FUNCTION_PROJECT_ID: string; | ||
} | ||
} | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import { Client } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Client, Users } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
// This is your Appwrite function | ||
// It's executed each time we get a request | ||
// This Appwrite function will be executed every time your function is triggered | ||
export default async ({ req, res, log, error }: any) => { | ||
// Why not try the Appwrite SDK? | ||
// | ||
// const client = new Client() | ||
// .setEndpoint('https://cloud.appwrite.io/v1') | ||
// .setProject(Deno.env.get("APPWRITE_FUNCTION_PROJECT_ID")) | ||
// .setKey(Deno.env.get("APPWRITE_API_KEY")); | ||
// 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(Deno.env.get("APPWRITE_FUNCTION_API_ENDPOINT") ?? '') | ||
.setProject(Deno.env.get("APPWRITE_FUNCTION_PROJECT_ID") ?? '') | ||
.setKey(req.headers['x-appwrite-key'] ?? ''); | ||
const users = new Users(client); | ||
|
||
// You can log messages to the console | ||
log("Hello, Logs!"); | ||
|
||
// If something goes wrong, log an error | ||
error("Hello, Errors!"); | ||
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.method === "GET") { | ||
// Send a response with the res object helpers | ||
// `res.send()` dispatches a string back to the client | ||
return res.send("Hello, World!"); | ||
// 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"); | ||
} | ||
|
||
// `res.json()` is a handy helper for sending JSON | ||
return res.json({ | ||
motto: "Build like a team of hundreds_", | ||
learn: "https://appwrite.io/docs", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.