Skip to content

Conversation

@ThorstenHans
Copy link
Contributor

@ThorstenHans ThorstenHans commented Mar 19, 2025

UPDATE

Instead of adding new templates, this PR modifies existing http-ts and http-js templates. Users could now select if they wanna use itty or hono. They could also go without a router by responding to the particular prompt with none.

Original

This PR adds the two new templates to the Spin SDK for JavaScript:

  • http-hono-ts: HTTP triggered Spin application using TypeScript and Hono
  • http-hono-js: HTTP triggered Spin application using JavaScript and Hono

@ThorstenHans ThorstenHans changed the title Add http-hono-ts template Add http-hono-ts and http-hono-js templates Mar 19, 2025
Copy link
Member

@radu-matei radu-matei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the TS template, LGTM!

Thanks!

@ThorstenHans
Copy link
Contributor Author

Q: @radu-matei @karthik2804 do we wanna use the suggested names? (http-hono-ts & http-hono-js)? Mainly asking because Karthik suggested http-ts-hono and http-js-hono)

@radu-matei
Copy link
Member

http-*s-hono seems more consistent with the http-<language> format.

@karthik2804
Copy link
Collaborator

karthik2804 commented Mar 19, 2025

I prefer the consistency as well. One potential alternate for us to consider is if we want to consider just having a single template that prompts for choices? similar to the work on the package manager PR we have open. The advantage would be that we have one single template but the flipside is the user has to make more choices and that the template will look a lot more bloated with if statements( It is not something that end users will have to deal with though)

@itowlson
Copy link
Contributor

FWIW I've previously used the language-last convention (e.g. https://github.com/itowlson/spin-templates-slack/tree/main/templates/slack-slash-command-rust). But that is definitely not any kind of established project precedent.

@karthik2804 Yes, it would be even better to have a template that asks users "which router do you want to use (itty / hono / none)". It would definitely make the template gnarly though (and I think we'd need to add a choice type to the system, I don't think we have that yet).

@karthik2804
Copy link
Collaborator

We can make choices based on string matching already IIRC.

@ThorstenHans
Copy link
Contributor Author

How should we proceed here? I'm happy to rename the templates to http-{lang}-hono

If we extend prompting for the default http-js / http-ts templates, I would also vote for adding a prompt to chose the desired package manager (npm|yarn|pnpm).

Any ideas on how to proceed here in the meantime?

@karthik2804
Copy link
Collaborator

I would also vote for adding a prompt to chose the desired package manager (npm|yarn|pnpm).
@ThorstenHans as we have found out yarn does not work with the v3 build tooling, so that will have to wait until v4 but I agree that it is a good idea to add it as well once that is a possibility.

I am happy to go eitherway on the template but have a slight preference on the "extending prompting" approach as that will mean lesser templates.

@ThorstenHans ThorstenHans changed the title Add http-hono-ts and http-hono-js templates Add support for hono, itty and no router to http-ts and http-js Mar 20, 2025
@ThorstenHans
Copy link
Contributor Author

I've updated the templates http-js and http-ts now. Until the PR mentioned by @itowlson lands in spin:main, I added a question with a regex that allows the user to chose between hono, itty, or go without a router.

@ThorstenHans
Copy link
Contributor Author

@karthik2804 I updated both templates http-ts and http-js as we discussed. Also the matrix strategy for testing templates has been updated

Copy link
Collaborator

@karthik2804 karthik2804 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!
I am just curious if we are able to use partials and split things into multiple files?

@itowlson
Copy link
Contributor

@karthik2804 Looking at how Liquid partials work (https://docs.rs/liquid/latest/liquid/partials/index.html)... the template system doesn't currently do any of that. No reason it couldn't, but we'd have to do some work on it, which might be fairly easy, but would still mean not until Spin 3.3. Sorry - I can see the value, just hasn't been needed before.

@ThorstenHans ThorstenHans merged commit 06dcba7 into main Apr 14, 2025
11 checks passed
@ThorstenHans ThorstenHans deleted the templates/hono-ts branch April 14, 2025 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants