Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dotnet starter #30

Merged
merged 3 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions dotnet/starter-template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# Visual Studio 2017 auto generated files
Generated\ Files/

# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/

# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# Visual Studio Trace Files
*.e2e

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/

##
## Visual studio for Mac
##


# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/

# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Folder config file
[Dd]esktop.ini

# JetBrains Rider
.idea/
*.sln.iml

##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
47 changes: 47 additions & 0 deletions dotnet/starter-template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ⚡ .NET Starter Function
loks0n marked this conversation as resolved.
Show resolved Hide resolved

A simple starter function. Edit `src/Index.cs` 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 | .NET (6.0) |
| Entrypoint | `src/Index.cs` |
| Permissions | `any` |
| Timeout (Seconds) | 15 |

## 🔒 Environment Variables

No environment variables required.
8 changes: 8 additions & 0 deletions dotnet/starter-template/StarterTemplate.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
42 changes: 42 additions & 0 deletions dotnet/starter-template/src/Index.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace DotNetRuntime;

using Appwrite;
using Appwrite.Services;
using Appwrite.Models;

public class Handler {

// This is your Appwrite function
// It"s executed each time we get a request
public async Task<RuntimeOutput> Main(RuntimeContext Context)
{
// Why not try the Appwrite SDK?
//
// var client = new Client()
// .SetEndpoint("http://cloud.appwrite.io/v1")
// .SetProject(Environment.GetEnvironmentVariable("APPWRITE_PROJECT_ID"))
// .SetKey(Environment.GetEnvironmentVariable("APPWRITE_API_KEY"))

// You can log messages to the console
Context.Log("Hello, Logs! 👋");

// If something goes wrong, log an error
Context.Error("Hello, Errors! ⛔");

// The `Context.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.Req.Send("Hello, World! 🌎");
}

// `Context.Res.Json()` is a handy helper for sending JSON
return Context.Res.Json(new()
{
{ "motto": "Build Fast. Scale Big. All in One Place." },
{ "learn": "https://appwrite.io/docs" },
{ "connect": "https://appwrite.io/discord" },
{ "getInspired": "https://builtwith.appwrite.io" },
});
}
}