-
Notifications
You must be signed in to change notification settings - Fork 66
feat: expressjs framework #784
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
Merged
Merged
Changes from 92 commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
1bf14da
feat: expressjs framework extension
yanksyoon 5d5b8ba
test: expressjs framework extension unit tests
yanksyoon 8afa87e
fix: lint
yanksyoon a887f00
fix: user prime app prefixing
yanksyoon be56040
test: spread test for express js
yanksyoon 91e87e9
fix: linting
yanksyoon 9d9be67
feat: add template
yanksyoon cb84f17
fix: app project dir
yanksyoon 0af6e6a
chore: comment runtime debs
yanksyoon eacf0a1
chore: rename organise to organize
yanksyoon dc787d0
test: fix tests
yanksyoon 98fbdd9
chore: move ca-certificates_data to slice def
yanksyoon d7c51cd
chore: move node slice
yanksyoon b7a21a5
chore: retrigger ci
yanksyoon 9233492
fix: add node build dependency
yanksyoon acc3c05
fix: use nodejs package
yanksyoon b6b9ca2
fix: add npm plugin dependency
yanksyoon a1b5209
fix: add plugin dependencies
yanksyoon 9a69970
fix: nodejs as deb
yanksyoon f55e87b
fix: nodejs package/slice separation
yanksyoon 544434b
ci: retrigger (LAUCHPAD DOWN)
yanksyoon 6ba9c5a
fix: prime default after deletion
yanksyoon 82bbf94
feat: node version option fallthrough
yanksyoon 582811b
chore: add rockcraft to supported extensions
yanksyoon 650cab0
docs: expressjs tutorial
yanksyoon a25ea2a
chore: separate out dependencies part
yanksyoon dc3b61b
feat: add generation template
yanksyoon 6e68078
docs: expressjs reference
yanksyoon 024ea8e
docs: fix linting line too long
yanksyoon 685d9be
fix: 24.04 package clash fix
yanksyoon b900591
fix: move stage packages
yanksyoon cea6fe4
fix: npmrc install
yanksyoon b20ebea
fix: tutorial code fix
yanksyoon a504403
fix: pebble lint
yanksyoon f6d31a2
test: add back build base
yanksyoon 2a46cab
fix: base change
yanksyoon 63b914d
docs: documentation improvements
yanksyoon c8d9ce5
test: add corner cases
yanksyoon c319aa2
chore: inline constants & match service def
yanksyoon a3c080a
chore: update template guildeline
yanksyoon dee32bf
docs: tutorial docs wording improvements & code highlighting
yanksyoon 24ae419
feat: expressjs user override node with different bases
yanksyoon 908581a
docs: expressjs user-override node version template
yanksyoon a5423c6
docs: reference to node-version override
yanksyoon f33666f
docs: update expressjs runtime codeblock to match template
yanksyoon 37fa47c
docs: expressjs tutorial specify run directory
yanksyoon c1c8e28
docs: expressjs tutorial fix sumaary
yanksyoon 02675c7
chore: organize expressjs extension code
yanksyoon c3af5c2
test: set node env to production
yanksyoon fd934b9
chore: remove user custom packages part
yanksyoon e3ea01b
chore: remove empty parts from rock gen
yanksyoon 3589757
docs: re-order framework extensions list
yanksyoon 752ce93
docs: remove customizing runtime deps part
yanksyoon c145919
docs: explain unsupported runtime dependencies issue
yanksyoon a90e80b
docs: expressjs explaination of different combinations
yanksyoon 81c4abb
docs: pin tutorial express generator version
yanksyoon eca73e3
docs: reword parts
yanksyoon da5b5fe
docs: formatting & spelling
yanksyoon 4128d2d
docs: fix linting
yanksyoon 0531361
docs: update tutorial documentation
yanksyoon b62355e
docs: tutorial curl --fail flag
yanksyoon 9c2dfb9
docs: lint fixes for tutorial
yanksyoon 7f9aeb7
chore: clean up code
yanksyoon 2ca47b2
chore: trigger CI
yanksyoon 4f457dd
docs: curl with fail flags
yanksyoon 2219f20
docs: tutorial refer to file
yanksyoon dc9b38c
test: node version check
yanksyoon d9fd9e0
test: fix indentation for rockcraft yaml npm version override
yanksyoon e82ec96
test: fix version check
yanksyoon b55012b
chore: revert changes to build-docs
yanksyoon 420b342
docs: grammar improvement & sphinx syntax fixes
yanksyoon 48b2ceb
docs: remove unsurprisingly vocab
yanksyoon d3e9f8b
docs: append newline for code-block rendering
yanksyoon 7acb5d0
docs: update docs reference link
yanksyoon 425be9f
docs: improve ExpressJS docs grammar
yanksyoon 12319c9
docs: update ubuntu base syntax
yanksyoon 5db1dfe
docs: improve documentation grammar
yanksyoon 2619fdc
docs: change logs to terminal directive
yanksyoon 0401fcf
chore: remove unnecessary ubuntu base replacement
yanksyoon 15a589a
docs: start from 24.04 base for tutorial
yanksyoon d41ea86
docs: fix tutorial append time app command
yanksyoon 700a625
fix: node version override from nodejs_bins fix
yanksyoon d171762
test: increase test timeout (default 15)
yanksyoon 89fc837
fix: supporting libs for npm plugin installed libs
yanksyoon a58f665
fix: bare image with nodejs included
yanksyoon fcf14cf
docs: formatting and minor grammar issues
yanksyoon 3864e55
docs: move build bases documentation to how-to
yanksyoon ba5e6b3
docs: clarify ambiguous grammar
yanksyoon 5bc4784
docs: match Go tutorial style
yanksyoon e897513
chore: remove node_modules before installation
yanksyoon 35da292
docs: lint
yanksyoon 671c606
docs: fix broken links
yanksyoon 8ec0ca4
docs: fix references
yanksyoon 06d3582
docs: improve base difference explanations
yanksyoon 903a3fb
docs: remove nesting
yanksyoon 468f03d
docs: NodeJS to Node.js spelling fix
yanksyoon bd466b9
Merge branch 'main' into feat/expressjs-framework
tigarmo 3da438f
docs: update docs/how-to/index.rst
tigarmo 6563bf6
docs: fix lint errors
yanksyoon fd92ab1
docs: change tutorial ref to setup stable
yanksyoon 635017b
fix: add missing binaries to the go-framework extension for bare base…
yanksyoon 5374920
docs: use edge setup
yanksyoon ce35823
Merge branch 'main' into feat/expressjs-framework
tigarmo 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
86 changes: 86 additions & 0 deletions
86
docs/how-to/extensions/configure-the-build-base-for-expressjs-app.rst
This file contains hidden or 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,86 @@ | ||
| .. _configure-the-build-base-for-expressjs-app: | ||
|
|
||
| expressjs-framework | ||
| =================== | ||
|
|
||
| When using the ``expressjs-framework`` extension, there are four different cases | ||
| for customising the Ubuntu base and the Node version to be included. | ||
| The main differences between the cases are: | ||
|
|
||
| - Whether to use the bare base or Ubuntu 24.04 base. | ||
| - Whether Node is installed from Ubuntu package archive or the NPM plugin. | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The remainder of this page discusses the combinations of | ||
| Ubuntu bases and sources for Node.js. | ||
|
|
||
| Ubuntu 24.04 base, Node.js from Ubuntu package archive | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. code-block:: yaml | ||
| :caption: rockcraft.yaml | ||
|
|
||
| base: ubuntu@24.04 | ||
| extensions: | ||
| - expressjs-framework | ||
|
|
||
| In this case, the application is installed and run via Node and NPM is installed | ||
| from the Ubuntu package archive. The NPM and Node versions are determined by the | ||
| versions of NPM and NodeJS shipped with the Ubuntu base. See the NodeJS version | ||
| shipped with the corressponding Ubuntu base from the chilsel-slices repository. | ||
| This `link to the slices repository | ||
| <https://github.com/canonical/chisel-releases/blob/ubuntu-24.04/slices/ | ||
| nodejs.yaml>`_ is an example of the NodeJS version shipped with the Ubuntu 24.04 | ||
| base. | ||
medubelko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Ubuntu 24.04 base, Node.js from NPM plugin | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. code-block:: yaml | ||
| :caption: rockcraft.yaml | ||
|
|
||
| base: ubuntu@24.04 | ||
| extensions: | ||
| - expressjs-framework | ||
| parts: | ||
| expressjs-framework/install-app: | ||
| npm-include-node: true | ||
| npm-node-version: 20.12 | ||
|
|
||
| In this case, the application is installed and run via NodeJS provided by the | ||
| NPM plugin. The NPM is also installed by the NPM plugin. | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Bare base, and Node.js from Ubuntu package archive | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. code-block:: yaml | ||
| :caption: rockcraft.yaml | ||
|
|
||
| base: bare | ||
| build-base: ubuntu@24.04 | ||
|
|
||
| In this case, the application is installed and run via Node and NPM is | ||
| installed from the Ubuntu package archive. The NPM and Node versions are | ||
| determined by the versions of NPM and NodeJS shipped with the Ubuntu base. | ||
| See the NodeJS version shipped with | ||
| the corressponding Ubuntu base from the chilsel-slices repository. | ||
| See the NPM version shipped with the corressponding Ubuntu base from the Ubuntu | ||
| packages archive from the `Ubuntu packages search <https://packages.ubuntu.com/\ | ||
| search?suite=default§ion=all&arch=any&keywords=npm&searchon=names>`_. | ||
|
|
||
| Bare base, Node.js from NPM plugin | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. code-block:: yaml | ||
| :caption: rockcraft.yaml | ||
|
|
||
| base: bare | ||
| build-base: ubuntu@24.04 | ||
| parts: | ||
| expressjs-framework/install-app: | ||
| npm-include-node: true | ||
| npm-node-version: 20.12 | ||
|
|
||
| In this case, the application is installed and run via NodeJS and NPM from the | ||
| NPM plugin. For different possible inputs for npm-node-version, refer to | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| the `NPM plugin documentation <https://documentation.ubuntu.com/rockcraft/en/\ | ||
| latest/common/craft-parts/reference/plugins/npm_plugin>`_. | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
tigarmo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or 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,6 @@ | ||
| .. _how-to-extensions: | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
|
|
||
| configure-the-build-base-for-expressjs-app |
This file contains hidden or 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 hidden or 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,55 @@ | ||
| .. _expressjs-framework-reference: | ||
|
|
||
| expressjs-framework | ||
| ------------------- | ||
|
|
||
| The ExpressJS extension streamlines the process of building ExpressJS | ||
| application rocks. | ||
|
|
||
| It facilitates the installation of ExpressJS application dependencies, including | ||
| Node and NPM, inside the rock. Additionally, it transfers your project files to | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``/app`` within the rock. | ||
|
|
||
| The ExpressJS extension is compatible with the ``bare`` and ``ubuntu@24.04`` | ||
| bases. | ||
|
|
||
| Project requirements | ||
| ==================== | ||
|
|
||
| There are 3 requirements to be able to use the ``expressjs-framework`` | ||
| extension: | ||
|
|
||
| 1. The application should reside in the ``app`` directory. | ||
| 2. The application should have a ``package.json`` file. | ||
| 3. The ``package.json`` file should define the ``start`` script. | ||
yanksyoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ``parts`` > ``expressjs-framework/install-app`` > ``npm-include-node`` | ||
| ====================================================================== | ||
|
|
||
| You can use this field to specify the version of Node to be installed. For | ||
| example: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| parts: | ||
| expressjs-framework/install-app: | ||
| npm-include-node: true | ||
| npm-node-version: 20.12.2 | ||
|
|
||
| For more examples of the ``npm-node-version`` key, see the | ||
| `NPM plugin <httpshttps://documentation.ubuntu.com/rockcraft/en/latest/common/ | ||
| craft-parts/reference/plugins/npm_plugin/#examples>`_ documentation. | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| If you don't customise the version of node, it will be installed from the Ubuntu | ||
| package repository. | ||
|
|
||
| ``parts`` > ``expressjs-framework/runtime:`` > ``stage-packages`` | ||
| ================================================================= | ||
|
|
||
| Installing additional runtime packages is currently unsupported. | ||
|
|
||
| See also | ||
| ======== | ||
|
|
||
| - :ref:`build-a-rock-for-an-expressjs-application` | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -15,3 +15,4 @@ initiating a new rock. | |
| django-framework | ||
| fastapi-framework | ||
| go-framework | ||
| expressjs-framework | ||
This file contains hidden or 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 hidden or 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 hidden or 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,117 @@ | ||
| ########################################### | ||
| # IMPORTANT | ||
| # Comments matter! | ||
| # The docs use the wrapping comments as | ||
| # markers for including said instructions | ||
| # as snippets in the docs. | ||
| ########################################### | ||
| summary: Getting started with ExpressJS tutorial | ||
|
|
||
| environment: | ||
|
|
||
| execute: | | ||
| # [docs:install-deps] | ||
| sudo apt-get update -y && sudo apt-get install npm -y | ||
| # [docs:install-deps-end] | ||
|
|
||
| # [docs:init-app] | ||
| sudo npm install -g express-generator@4 | ||
| express app | ||
| cd app && npm install | ||
| # [docs:init-app-end] | ||
|
|
||
| npm start & | ||
| cd .. | ||
| retry -n 5 --wait 2 curl --fail localhost:3000 | ||
|
|
||
| # [docs:curl-expressjs] | ||
| curl --fail localhost:3000 | ||
| # [docs:curl-expressjs-end] | ||
|
|
||
| kill $! | ||
| kill $(lsof -t -i:3000) | ||
yanksyoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # [docs:create-rockcraft-yaml] | ||
| rockcraft init --profile expressjs-framework | ||
| # [docs:create-rockcraft-yaml-end] | ||
|
|
||
| sed -i "s/name: .*/name: expressjs-hello-world/g" rockcraft.yaml | ||
|
|
||
| # [docs:experimental] | ||
| export ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=true | ||
| # [docs:experimental-end] | ||
|
|
||
| # [docs:pack] | ||
| rockcraft pack | ||
| # [docs:pack-end] | ||
|
|
||
| # [docs:ls-rock] | ||
| ls *.rock -l --block-size=MB | ||
| # [docs:ls-rock-end] | ||
|
|
||
| # [docs:skopeo-copy] | ||
| sudo rockcraft.skopeo --insecure-policy \ | ||
| copy oci-archive:expressjs-hello-world_0.1_amd64.rock \ | ||
| docker-daemon:expressjs-hello-world:0.1 | ||
| # [docs:skopeo-copy-end] | ||
|
|
||
| # [docs:docker-images] | ||
| sudo docker images expressjs-hello-world:0.1 | ||
| # [docs:docker-images-end] | ||
|
|
||
| # [docs:docker-run] | ||
| sudo docker run --rm -d -p 3000:3000 \ | ||
| --name expressjs-hello-world expressjs-hello-world:0.1 | ||
| # [docs:docker-run-end] | ||
| retry -n 5 --wait 2 curl --fail localhost:3000 | ||
|
|
||
| # [docs:curl-expressjs-rock] | ||
| curl --fail localhost:3000 | ||
| # [docs:curl-expressjs-rock-end] | ||
|
|
||
| # [docs:get-logs] | ||
| sudo docker exec expressjs-hello-world pebble logs expressjs | ||
| # [docs:get-logs-end] | ||
|
|
||
| # [docs:stop-docker] | ||
| sudo docker stop expressjs-hello-world | ||
| sudo docker rmi expressjs-hello-world:0.1 | ||
| # [docs:stop-docker-end] | ||
|
|
||
| mv time.js app/routes/ | ||
| original_line="var app = express();" | ||
| # Remove comments from time_app.js | ||
| sed -i 's:^//.*::g' time_app.js | ||
| append_line="$(cat time_app.js | tr '\n' ' ')" | ||
| sed -i "/$original_line/a$append_line" app/app.js | ||
| sed -i "s/version: .*/version: 0.2/g" rockcraft.yaml | ||
|
|
||
| # [docs:docker-run-update] | ||
| rockcraft pack | ||
| sudo rockcraft.skopeo --insecure-policy \ | ||
| copy oci-archive:expressjs-hello-world_0.2_amd64.rock \ | ||
| docker-daemon:expressjs-hello-world:0.2 | ||
| sudo docker images expressjs-hello-world:0.2 | ||
| sudo docker run --rm -d -p 3000:3000 \ | ||
| --name expressjs-hello-world expressjs-hello-world:0.2 | ||
| # [docs:docker-run-update-end] | ||
| retry -n 5 --wait 2 curl --fail localhost:3000/time | ||
|
|
||
| # [docs:curl-time] | ||
| curl --fail localhost:3000/time | ||
| # [docs:curl-time-end] | ||
|
|
||
| # [docs:stop-docker-updated] | ||
| sudo docker stop expressjs-hello-world | ||
| sudo docker rmi expressjs-hello-world:0.2 | ||
| # [docs:stop-docker-updated-end] | ||
|
|
||
| # [docs:cleanup] | ||
| # delete all the files created during the tutorial | ||
| npm uninstall -g express-generator@4 | ||
yanksyoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sudo apt-get remove npm -y | ||
| rm -rf app | ||
| rm expressjs-hello-world_0.1_amd64.rock \ | ||
yanksyoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expressjs-hello-world_0.2_amd64.rock \ | ||
| rockcraft.yaml | ||
| # [docs:cleanup-end] | ||
yanksyoon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,8 @@ | ||
| var express = require('express'); | ||
| var router = express.Router(); | ||
|
|
||
| router.get('/', function (req, res, next) { | ||
| res.send(Date()); | ||
| }); | ||
|
|
||
| module.exports = router; |
yanksyoon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,4 @@ | ||
| // [docs:append-lines] | ||
| var timeRouter = require('./routes/time'); | ||
| app.use('/time', timeRouter); | ||
| // [docs:append-lines-end] |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.