Skip to content

Basic example of MetaCall with Express FaaS-like showing the REPL protocol.

License

Notifications You must be signed in to change notification settings

metacall/express-faas-repl-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetaCall Express FaaS REPL Example

An example of building a FaaS server with NodeJS and Express, which implements a REPL protocol, suitable for projects like IPython / Jupyter where the exec constraints make embedding MetaCall difficult. This offers a multi-language REPL protocol and an inline module loader in order to allow loading and calling functions between languages in the REPL.

Run it

  1. Install MetaCall:

    curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | sh
  2. Install dependencies:

    metacall npm install
  3. In a terminal, run:

    metacall server.js
  4. For testing with CURL:

    a) Inline Module Loading:

    curl -X POST -H 'Content-Type: application/json' localhost:7777/eval/node -d '{"data": "module.exports = { f: () => 4 }"}'

    b) REPL:

    curl -X POST -H 'Content-Type: application/json' localhost:7777/repl/node -d '{"data": "5555555554\n"}'

    c) Calling the function f in the REPL, previously loaded by step a:

    curl -X POST -H 'Content-Type: application/json' localhost:7777/repl/node -d '{"data": "require(\"metacall\").metacall(\"f\")\n"}'
  5. In order to close it:

    curl localhost:7777/shutdown

About

Basic example of MetaCall with Express FaaS-like showing the REPL protocol.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published