这是indexloc提供的服务,不要输入任何密码
Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Boilerplates for Azure Cloud Function serverless functions and Hasura GraphQL Engine's Event Triggers

**NOTE**
Some of the language/platforms are work in progress. We welcome contributions for the WIP langauages. See issues and the following checklist:
Some of the language/platforms are work in progress. We welcome contributions for the WIP languages. See issues and the following checklist:

| Folder name | Use-case| Javascript | Java | C# | F#
|-------------|---------|:--------:|:------:|:----:|:---:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sample boilerplates for Hasura Event Triggers

[echo](echo/): echo the trigger payload.
Helps understanding the event payload and how to parse data.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Setup tables
1. Create table:

```
notes:
id: int
note: text
```

# Setup Cloud Function
1. Add `netlify.toml` to your Netlify root directory
2. Rename `.netlifygitignore` to `.gitignore` to your Netlify root directory
2. (alt) Alternatively edit your pre-existing `.gitignore` to ignore your functions folder
3. Add the following scripts to your `package.json`:
```json
// functions is the name of your functions folder
// if you are using a different name change it
"scripts": {
"lambda-serve": "netlify-lambda serve functions",
"lambda-build": "netlify-lambda build functions"
}
```
4. Add the file `index.js` to your functions folder

# Running locally
`netlify-lambda serve functions`

# Build
`netlify-lambda build functions`

# Add the trigger in Hasura GraphQL
1. In events tab, add a trigger
2. Select all insert, update, delete operations for the trigger.
3. Paste your function URL as the webhook. (eg: http://host.docker.internal:9000/index)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports.handler = (event, context, callback) => {
const { event: {op, data}, table: {name, schema} } = JSON.parse(event.body);

// Send the response
callback(null, {
statusCode: 200,
body: JSON.stringify({msg: "Received event!", data: {op, data, name, schema}})
})
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
functions = "lambda"