https://github.com/evervault/template-node-hello-function
Evervault template Hello World Function for NodeJS.
https://github.com/evervault/template-node-hello-function
Last synced: over 1 year ago
JSON representation
Evervault template Hello World Function for NodeJS.
- Host: GitHub
- URL: https://github.com/evervault/template-node-hello-function
- Owner: evervault
- License: mit
- Created: 2022-10-20T11:44:39.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-03T13:45:45.000Z (about 3 years ago)
- Last Synced: 2025-02-15T12:16:49.860Z (over 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hello Function
[Evervault](https://evervault.com) makes it easy to encrypt data at source, process it in a Function — a secure, serverless function — and never store it unencrypted.
This is a simple Evervault Function example, to help get you up and running on the Evervault platform quickly.
## Getting started with Evervault
Evervault consists of two parts, encrypting your data at source, using either our Node SDK, or Browser and React SDKs and then sending that encrypted data to a Function to be processed securely.
This Function takes a payload that should contain a `name` key. Running the Function is very simple.
## The steps
1. Encrypt your data at source, using one of our SDKs.
2. Process the encrypted data in a Function
### Encrypting at source
```javascript
// This example uses the Evervault Node SDK.
const Evervault = require('@evervault/sdk');
// Initialize the client with your App's API key
const evervault = new Evervault('');
// Encrypt your data
const encrypted = await evervault.encrypt({ name: 'Claude Shannon' });
```
### Process your encrypted data in a Function
You should encrypt this payload using either our Node SDK or Browser SDK, then run it in the Hello Function:
```javascript
// Process the encrypted data in a Function
const result = await evervault.run('', encrypted);
```
## Understanding the Function
This Function is very simple. Here is the full code:
```javascript
exports.handler = async (data) => {
if (data.name && typeof data.name === "string") {
console.debug(`A name of length ${data.name.length} has arrived into the Function.`);
return {
message: `Hello from a Function! It seems you have ${data.name.length} letters in your name`,
name: await context.encrypt(data.name),
};
} else {
console.debug('An empty name has arrived into the Function.');
return {
message: 'Hello from a Function! Send an encrypted `name` parameter to show Function decryption in action',
};
}
};
```
Or check it out in [index.js](./index.js).
---
If you want to know more about Evervault, check out our [documentation](https://docs.evervault.com).