-
Notifications
You must be signed in to change notification settings - Fork 4
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 Node.js Support #710
Merged
Merged
Add Node.js Support #710
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
366ccaa
Add NodeJS service to local-server
jerico 9ddfe5e
Add Node.js documentation
jerico e505f0e
Remove unnecessary node_modules volume
jerico dc97da5
Allow setting of Node.js version
jerico 85c0b87
Add healthcheck
jerico e5e8c2d
Echo Node.js URL when startup completes
jerico 858158c
Remove Node.js healthcheck
jerico fbd0a6b
Fix formatting
jerico f7b893b
Read from package.json to determine Node.js version
jerico c2fee48
Update Node.js documentation
jerico de95468
Add env vars in Node.js container
jerico 63ae1a1
Fix linting issues
jerico d100534
Install node packages before running dev
jerico 556d894
Update docs/nodejs.md
jerico 87c188f
Add nodejs entry in logs function
jerico 58fb619
Merge branch 'add-nodejs-support' of github.com:humanmade/altis-local…
jerico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Node.js | ||
|
||
Altis supports running Node.js applications alongside WordPress, utilizing WordPress as a headless API. | ||
|
||
## Enabling Node.js in Local Server | ||
|
||
Node.js can be enabled in Local Server by adding `extra.altis.modules.local-server.nodejs` in the project's `composer.json` | ||
|
||
```json | ||
{ | ||
"extra":{ | ||
"altis":{ | ||
"modules":{ | ||
"local-server":{ | ||
"nodejs":{ | ||
"path":"../altis-nodejs-skeleton" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
`path` is relative to the directory where `composer.json` lives. | ||
|
||
## Setting Node.js Version | ||
Similar to configuring the Altis infrastructure, the Local Server determines the Node.js version to use based on the `engines.node` value found in the `package.json` at the specified `path`. | ||
|
||
## Running Development Server | ||
Once configured, the Local Server executes `npm run dev` inside the Node.js container at the specified path. This command watches for changes and recompiles necessary files. | ||
|
||
## Accessing the Application | ||
This setup makes the application accessible at `https://nodejs-{project-name}.altis.dev`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a new
altis-skeleton
withaltis-nodejs-skeleton
in anodejs
subdirectory. I had thought the nodejs code must live in the same repos as the Altis code.Anyway, I saw no evidence of it having run
npm run dev
.I tried looking at the nodejs container logs (I had to use vs-code) and it doesn't seem to show
npm run dev
instead it looks like it may have runnext dev
after that, there are only get requests shown when I refresh my browser. Changing index.jsx does nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get an entry in
composer server logs
fornodejs
, please?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this decision documented somewhere? I based this off how thehourglass manage their repo. They have front-end and backend on a separate repo.
Our skeleton uses
next.js
, internally it's running thenpm run dev
https://github.com/humanmade/altis-local-server/pull/710/files#diff-6e1aa008277f9688efac7746b347e1e418cfc7b7e36f5bec209e48022d735022R263I'll check the auto-recompile and adding log entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikelittle
nodejs
entry incomposer server logs
We also support having the nodejs code in the same repository by pointing to it using
nodejs.path
Screen.Recording.2024-07-17.at.16.36.55.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the node app location information from this notion page but it must have moved on. No worries.
The live reload still doesn't work for me. But I'll put that down to my setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs are the better place to consult; they're separate repos as we changed that decision based on feedback. It does also make me wonder if we might want the server separate as a result 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rmccue Separate server meaning separate from Local Server?
Given our current setup, it makes sense for it to be part of the Local Server for now. When deployed, Node.js runs alongside WordPress. We currently assume that there's always a WordPress instance paired with the front-end in Altis.