Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/testdrivenio/openfass-node-restful-api
Simple example of an OpenFaaS RESTful API
https://github.com/testdrivenio/openfass-node-restful-api
docker docker-swarm faas javascript kubernetes openfaas serverless
Last synced: 4 months ago
JSON representation
Simple example of an OpenFaaS RESTful API
- Host: GitHub
- URL: https://github.com/testdrivenio/openfass-node-restful-api
- Owner: testdrivenio
- License: mit
- Created: 2018-01-27T00:14:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-27T12:54:10.000Z (over 6 years ago)
- Last Synced: 2024-06-22T16:56:47.725Z (6 months ago)
- Topics: docker, docker-swarm, faas, javascript, kubernetes, openfaas, serverless
- Language: JavaScript
- Size: 13.7 KB
- Stars: 34
- Watchers: 5
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenFaaS RESTful API w/ Node and Postgres
Simple example of an [OpenFaaS](https://www.openfaas.com/) RESTful API.
## Getting Started
Build the Docker images for the functions:
```sh
$ sh build.sh
```Initialize Swarm mode:
```sh
$ docker swarm init
```Deploy:
```sh
$ docker stack deploy func --compose-file docker-compose.yml --prune
```Create database and `movie` table:
```sh
$ PG_CONTAINER_ID=$(docker ps --filter name=movies-db --format "{{.ID}}")
$ docker exec -ti $PG_CONTAINER_ID psql -U postgres -W
# CREATE DATABASE movies;
# \c movies
# CREATE TABLE movie(id SERIAL, name varchar);
# \q
```Test:
```sh
$ curl -X POST http://localhost:8080/function/func_api-create -d \
'{"name":"NeverEnding Story"}'$ curl http://localhost:8080/function/func_api-read
$ curl -X POST http://localhost:8080/function/func_api-update -d \
'{"name":"NeverEnding Story 2", "id": "1"}'$ curl -X POST http://localhost:8080/function/func_api-delete -d \
'{"id":"1"}'
```## Deploy to Digital Ocean
[deploy-swarm.md](deploy-swarm.md)