-
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 #28 from appwrite/feat-cpp-starter
feat: C++ starter
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app |
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,47 @@ | ||
# β‘ C++ Starter Function | ||
|
||
A simple starter function. Edit `src/main.cc` to get started and create something awesome! π | ||
|
||
## π§° 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 Fast. Scale Big. All in One Place.", | ||
"learn": "https://appwrite.io/docs", | ||
"connect": "https://appwrite.io/discord", | ||
"getInspired": "https://builtwith.appwrite.io" | ||
} | ||
``` | ||
|
||
## βοΈ Configuration | ||
|
||
| Setting | Value | | ||
|-------------------|--------------------| | ||
| Runtime | C++ (17) | | ||
| Entrypoint | `src/main.cc` | | ||
| Permissions | `any` | | ||
| Timeout (Seconds) | 15 | | ||
|
||
## π Environment Variables | ||
|
||
No environment variables required. |
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,29 @@ | ||
namespace runtime { | ||
class Handler { | ||
public: | ||
// This is your Appwrite function | ||
// It's executed each time we get a request | ||
static RuntimeOutput main(RuntimeContext &context) { | ||
// You can log messages to the console | ||
context.log("Hello, Logs! π"); | ||
|
||
// If something goes wrong, log an error | ||
context.log("Hello, Errors! β"); | ||
|
||
// The `req` object contains the request data | ||
if (context.req.method == "GET") { | ||
// Send a response with the res object helpers | ||
// `context.res.send()` dispatches a string back to the client | ||
return context.res.send("Hello, World! π"); | ||
} | ||
|
||
// `context.res.json()` is a handy helper for sending JSON | ||
Json::Value response; | ||
response['motto'] = "Build Fast. Scale Big. All in One Place."; | ||
response['learn'] = "https://appwrite.io/docs"; | ||
response['connect'] = "https://appwrite.io/discord"; | ||
response['getInspired'] = "https://builtwith.appwrite.io"; | ||
return context.res.json(response); | ||
} | ||
}; | ||
} |