0.2.1-main.1c7a1b5 • Published 3 years ago

@dxos/functions v0.2.1-main.1c7a1b5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@dxos/functions

Functions SDK.

Installation

pnpm i @dxos/functions

Writing functions

Create a manifest file at the package root:

functions:
  hello:
    description: Test function.

NOTE: The function name must match the filename (e.g., src/functions/hello.ts).

Create an example function:

import { FunctionContext } from '@dxos/functions';

export default (event: any, context: FunctionContext) => {
  const identity = context.client.halo.identity.get();
  return context
    .status(200)
    .succeed({ 
      message: `Hello ${identity?.profile?.displayName}` 
    });
};

Running functions with the dev server:

Configure the agent to run functions on a given port:

# ~/.config/dx/profile/default.yml
runtime:
  agent:
    functions:
      port: 7001

Start functions in dev mode (from the related package):

dx function dev -r ts-node/register --verbose

NOTE: -r ts-node/register configures native TypesScript support.

Install nodemon to support live reloading:

npm i -g nodemon

nodemon -w ./src -e ts --exec $(git rev-parse --show-toplevel)/packages/devtools/cli/bin/dev \
  function dev -r ts-node/register --verbose

Invoking functions

NOTE: The port (7001) must match the one in config.

curl http://localhost:7001/dev/hello -X POST -H 'Content-Type: application/json' -w '\n' --data '{ "message": "Hello World!" }' 

DXOS Resources

Contributions

Your ideas, issues, and code are most welcome. Please take a look at our community code of conduct, the issue guide, and the PR contribution guide.

License: MIT Copyright 2022 © DXOS

0.8.2-main.5885341

11 months ago

0.8.2-main.600d381

11 months ago

0.8.1

11 months ago

0.8.0

1 year ago

0.8.2-main.12df754

11 months ago

0.8.2-main.f081794

11 months ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.0

1 year ago

0.8.2-main.36232bc

11 months ago

0.8.2-main.7503643

11 months ago

0.8.2-main.85fa0e5

11 months ago

0.8.2-main.fbd8ed0

10 months ago

0.8.2-main.f11618f

11 months ago

0.8.2-main.30e4dbb

11 months ago

0.8.2-main.2f9c567

11 months ago

0.8.2-main.5ca3450

11 months ago

0.6.13

1 year ago

0.6.12

1 year ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.6.7

2 years ago

0.6.6

2 years ago

0.6.9

2 years ago

0.6.8

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.6.5

2 years ago

0.6.4

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.6.10

2 years ago

0.6.11

2 years ago

0.5.2

2 years ago

0.5.0

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.10

2 years ago

0.3.9

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.57

3 years ago

0.1.56

3 years ago

0.1.55

3 years ago

0.1.54

3 years ago

0.1.53

3 years ago

0.1.52

3 years ago