Skip to content

Commit 70481b2

Browse files
committed
Issue [metacall#28](metacall#28): merge with master
2 parents 47542c5 + bc5f8a8 commit 70481b2

35 files changed

+1362
-979
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**
22
!src
3+
!types
34
!package.json
45
!package-lock.json
56
!tsconfig.json

.github/workflows/ci.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ jobs:
3838
# TODO: Have working unit tests generated
3939
# - name: Run Unit Tests
4040
# run: |
41-
# npm run unit
42-
43-
# TODO: Integration tests requires metacall/FaaS or dashboard.metacall.io credentials
44-
# TODO: unComment when we are ready for integration tests
45-
# - name: Run Tests
46-
# run: |
4741
# npm run test
4842

43+
- name: Run Integration Tests
44+
shell: bash
45+
run: |
46+
docker compose build
47+
docker compose up test
48+
docker compose down
49+
4950
- name: Publish
5051
uses: JS-DevTools/npm-publish@v1
5152
if: startsWith(github.ref, 'refs/tags/')

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
dist
33
*.env
4-
/logs/app.log
4+
logs

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.yml

.vscode/launch.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"skipFiles": ["<node_internals>/**"],
12+
"program": "${workspaceFolder}/dist/server.js",
13+
"preLaunchTask": "npm: buildDebug",
14+
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
15+
}
16+
]
17+
}

Dockerfile

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# MetaCall FaaS Script by Parra Studios
3+
# Reimplementation of MetaCall FaaS platform written in TypeScript.
4+
#
5+
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
FROM node:20-bookworm-slim AS base
21+
22+
# Image descriptor
23+
LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \
24+
copyright.address="[email protected]" \
25+
maintainer.name="Vicente Eduardo Ferrer Garcia" \
26+
maintainer.address="[email protected]" \
27+
vendor="MetaCall Inc." \
28+
version="0.1"
29+
30+
WORKDIR /metacall
31+
32+
FROM base AS deps
33+
34+
COPY . .
35+
36+
RUN npm install \
37+
&& npm run build
38+
39+
FROM base as faas
40+
41+
RUN apt-get update \
42+
&& apt-get install wget ca-certificates -y --no-install-recommends \
43+
&& wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh
44+
45+
COPY --from=deps /metacall/node_modules node_modules
46+
COPY --from=deps /metacall/dist dist
47+
48+
EXPOSE 9000
49+
50+
CMD ["node", "dist/index.js"]
51+
52+
FROM base AS test
53+
54+
RUN apt-get update \
55+
&& apt-get install curl ca-certificates jq -y --no-install-recommends \
56+
&& npm install -g @metacall/deploy

README.md

+23-12
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,56 @@
22

33
Reimplementation of MetaCall FaaS platform written in TypeScript. This project requires MetaCall installed in order to run it. For more information about installation: https://github.com/metacall/install
44

5-
### Development:
5+
### Development
6+
67
```sh
78
npm install
89
npm start
910
```
1011

11-
### About Project :
12+
### About Project
1213

13-
MetaCall organization has its own cloud platform known as [MetaCall Hub](https://metacall.io/), a production-ready and high-performance FaaS/Cloud platform where you can deploy services, web apps, and lambdas in seconds. However, the ```Real``` version of MetaCall FaaS is commercialized and requires a plan to deploy your polyglot applications, which can be found [Here](https://metacall.io/pricing/).
14+
MetaCall organization has its own cloud platform known as [MetaCall Hub](https://metacall.io/), a production-ready and high-performance FaaS/Cloud platform where you can deploy services, web apps, and lambdas in seconds. However, the `Real` version of MetaCall FaaS is commercialized and requires a plan to deploy your polyglot applications, which can be found [Here](https://metacall.io/pricing/).
1415

15-
When referring to the ```Real``` version of MetaCall FaaS, it should be noted that this refers to the commercialized FaaS cloud service, whereas ```Local``` refers to the mimic version.
16+
When referring to the `Real` version of MetaCall FaaS, it should be noted that this refers to the commercialized FaaS cloud service, whereas `Local` refers to the mimic version.
1617

17-
Soon, we realized that many contributors joining the community needed an paid account on the ```Real FaaS``` for testing their polyglot applications. To remove this barrier, we proposed a project that would mimic the ```Real FaaS```.
18+
Soon, we realized that many contributors joining the community needed an paid account on the `Real FaaS` for testing their polyglot applications. To remove this barrier, we proposed a project that would mimic the `Real FaaS`.
1819

1920
With this project, developers can now use it to deploy and test their polyglot applications (built using [MetaCall Core](https://github.com/metacall/core)), web apps, and lambdas. The process is simple:
2021

21-
- Step 1 : Spin up the "Local FaaS" by running the following command:
22+
- Step 1 : Spin up the "Local FaaS" by running the following command:
2223

2324
```sh
2425
cd faas
2526
npm start
2627
```
2728

28-
- Step 2 : Install the [metacall-deploy](https://www.npmjs.com/package/@metacall/deploy) NPM package, and wire the ```--dev``` flag with the ```metacall-deploy``` command in your application directory using the following command:
29+
- Step 2 : Install the [metacall-deploy](https://www.npmjs.com/package/@metacall/deploy) NPM package, and wire the `--dev` flag with the `metacall-deploy` command in your application directory using the following command:
2930

3031
```sh
3132
cd move-to-application-directory
3233
metacall-deploy --dev
3334
```
3435

35-
### Things that need to be implemented:
36+
### Things that need to be implemented
3637

37-
- In order to mimic the "Real FaaS", we need to create all the API endpoints that the "Real FaaS" supports, which can be found listed [Here](https://github.com/metacall/protocol/blob/master/src/protocol.ts).
38+
- In order to mimic the "Real FaaS", we need to create all the API endpoints that the "Real FaaS" supports, which can be found listed [Here](https://github.com/metacall/protocol/blob/master/src/protocol.ts).
3839

3940
### Important Note
4041

41-
- This project is still under development and there is one extra thing you need to install before running this project and its [MetaCall Core](https://github.com/metacall/core/blob/develop/docs/README.md#41-installation).
42+
- This project is still under development and there is one extra thing you need to install before running this project and its [MetaCall Core](https://github.com/metacall/core/blob/develop/docs/README.md#41-installation).
43+
44+
- This project is developed using [MetaCall Core] itself in order to provide polyglot support, we are using its [Node Port](https://github.com/metacall/core/tree/develop/source/ports/node_port) of this library to use all the functions and methods `MetaCall Core C API` provides.
45+
46+
- Also, [Here](https://github.com/metacall/faas/blob/master/types/metacall.d.ts) are all the functions of `MetaCall Core` we are using.
4247

43-
- This project is developed using [MetaCall Core] itself in order to provide polyglot support, we are using its [Node Port](https://github.com/metacall/core/tree/develop/source/ports/node_port) of this library to use all the functions and methods ```MetaCall Core C API``` provides.
48+
### Testing
4449

45-
- Also, [Here](https://github.com/metacall/faas/blob/master/types/metacall.d.ts) are all the functions of ```MetaCall Core``` we are using.
50+
This will run a test, and if the `docker compose up test` command exits with exit code 0, it will mean that the test has passed.
51+
If you want to see the output of the FaaS, run `docker compose up` instead. But when running this, the command won't terminate once the test finishes and the FaaS will keep running. You will need to press `Ctrl+C` in order to close it.
4652

53+
```sh
54+
docker compose build
55+
docker compose up test
56+
docker compose down
57+
```

TODO.md

-1
This file was deleted.

docker-compose.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# MetaCall FaaS Script by Parra Studios
3+
# Reimplementation of MetaCall FaaS platform written in TypeScript.
4+
#
5+
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
version: '3.7'
21+
22+
services:
23+
faas:
24+
image: metacall/faas
25+
container_name: metacall_faas
26+
build:
27+
context: .
28+
dockerfile: Dockerfile
29+
target: faas
30+
ports:
31+
- "9000:9000"
32+
33+
test:
34+
image: metacall/faas:test
35+
container_name: metacall_faas_test
36+
build:
37+
context: .
38+
dockerfile: Dockerfile
39+
target: test
40+
network_mode: host
41+
depends_on:
42+
- faas
43+
volumes:
44+
- ./test/:/metacall/
45+
command: /metacall/test.sh

0 commit comments

Comments
 (0)