Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Deno.js a template #140

Open
betterRunner opened this issue Mar 4, 2021 · 5 comments
Open

Add Deno.js a template #140

betterRunner opened this issue Mar 4, 2021 · 5 comments

Comments

@betterRunner
Copy link

I would like to submit a Deno.js template as an alternative of the Node.js template.
This is the project link: https://github.com/betterRunner/openfaas-deno-template

Here are some reasons for adding this template:
(1) deno supports Typescript out of the box. I think using Typescript to write functions would be better than using Javascript because of type checking and other features.
(2) deno is designed to be a security sandbox so in some themes I think it would be more suitable than nodejs.

You can see out more details here.

Thank you!

@alexellis
Copy link
Member

Thanks for your interest. We'll consider the submission for review, when we next have some spare cycles in the community.

You should also be able to use TypeScript with the existing node12 template, @mrsimonemms keep me honest here.

@alexellis
Copy link
Member

  1. is "hayd/deno" official, or an enthusiast build? It doesn't look like something "official"
  2. Where are the examples? See one of our examples for inspiration. How do you use it? How do you add a module like a database? How do you handle HTTP headers? How do you return success/failure? You may also want to study https://www.openfaas.com/blog/serverless-nodejs/
  3. How do you do unit testing?

@betterRunner
Copy link
Author

@alexellis thanks for the reply.
(1) As deno repo issue said, there are no official deno docker image currently and "hayd/deno" is the temporary one, I think we could replace it with the official one once it releases.
(2) Thank you for reminding me and I would add full examples following https://www.openfaas.com/blog/serverless-nodejs/
(3) I am sorry but can you give me an example template with unit testing? I have checked node12 and node14 and it seems no unit test code there.

@betterRunner
Copy link
Author

@alexellis any update about this plan? I have fixed most issues above and am ready to further complement if needed. Thanks you.

@mrsimonemms
Copy link

Apologies @alexellis and @betterRunner - I missed my mention in this thread. For the record, I've not actually used Deno yet (it's on my ever-expanding list) so everything I say here is caveated.

@alexellis yes, you can use TypeScript with the existing Node template. Deno is an entire reworking of the Node ecosystem and as such should be considered a separate language to Node.

I don't see any issue with using the hayd/deno image. It might be worth setting a build arg in the Dockerfile, eg

ARG DENO_IMG=hayd/deno:1.5.2
FROM --platform=${TARGETPLATFORM:-linux/amd64} ${DENO_IMG} as ship

The function template itself looks pretty good for the record

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants