Skip to content

Commit

Permalink
Add new node-express sample
Browse files Browse the repository at this point in the history
  • Loading branch information
trisberg committed Jan 23, 2025
1 parent 0952d5a commit 03f779f
Show file tree
Hide file tree
Showing 14 changed files with 1,160 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/tests/node-express-1/assertions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euxo pipefail
pushd $1

# Check that TAP files exist
test -f .tanzu/config/node-express.yml
test -f tanzu.yml

npm install

popd
3 changes: 3 additions & 0 deletions .github/tests/node-express-1/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deploymentType": "tpfork8s"
}
9 changes: 9 additions & 0 deletions .github/tests/node-express-1/scan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euxo pipefail

pushd $1
grype=$2

$grype dir:. --fail-on high --config ${GITHUB_WORKSPACE}/.github/tests/.grype.yaml

popd
104 changes: 104 additions & 0 deletions node-express/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
16 changes: 16 additions & 0 deletions node-express/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
MIT No Attribution

Copyright 2022-2024 VMware, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions node-express/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# node-express

This is a starter ExpressJs project, you can run it as a standalone
app using `npm run server` in the root of the project.
The server will be listening to request on port `3000`,
so you can test the server in a browser accessing `http://localhost:3000` or via `cURL`.

Before running the command `npm run server` you need to run `npm install` to
install the dependencies
34 changes: 34 additions & 0 deletions node-express/accelerator.axl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
engine {

if (#deploymentType == 'none') {
select(!"deploy/**")
} else {
if (#deploymentType == 'tpfork8s') {
let uuid = T(java.util.UUID).randomUUID() in {
applyTo("deploy/tpfork8s/tanzu.yml") {
ReplaceSnippet(text: "node-express", with: #artifactId.toLowerCase())
OpenRewriteRecipe('org.openrewrite.yaml.ChangeValue', { oldKeyPath: "$.configuration.id", value: 'config-' + #uuid.toString() })
RewritePath(rewriteTo: #filename)
}
}
applyTo("deploy/tpfork8s/.tanzu/config/node-express.yml") {
ReplaceText({{text: "node-express", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '.yml')
}
applyTo("deploy/tpfork8s/.tanzu/config/httproute-node-express.yml") {
ReplaceText({{text: "node-express", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/httproute-' + #artifactId.toLowerCase() + '.yml')
}
select(!"deploy/**")
}
}

// Update the artifact name as needed
applyTo("README.md" || "package.json") {
ReplaceText({{text: "node-express", with: #artifactId.toLowerCase()}})
}

// Create the provenance file
Provenance()

}
11 changes: 11 additions & 0 deletions node-express/accelerator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
accelerator:
options:
- name: deploymentType
inputType: select
label: Deployment type
choices:
- value: tpfork8s
text: Tanzu Platform for Kubernetes ContainerApp
- value: none
text: Skip deployment artifacts
defaultValue: tpfork8s
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
annotations:
apps.tanzu.vmware.com/promotable: ""
apps.tanzu.vmware.com/promote-group: ContainerApp/node-express
name: node-express-http-route
spec:
parentRefs:
- group: networking.tanzu.vmware.com
kind: Entrypoint
name: node-express
rules:
- backendRefs:
- kind: Service
name: node-express
port: 3000
11 changes: 11 additions & 0 deletions node-express/deploy/tpfork8s/.tanzu/config/node-express.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps.tanzu.vmware.com/v1
kind: ContainerApp
metadata:
name: node-express
spec:
build:
buildpacks: {}
path: ../..
ports:
- name: main
port: 3000
7 changes: 7 additions & 0 deletions node-express/deploy/tpfork8s/tanzu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: config.tanzu.vmware.com/v1
configuration:
dev:
paths:
- .tanzu/config/
id: config-00000000-0000-0000-0000-000000000000
kind: TanzuConfig
Loading

0 comments on commit 03f779f

Please sign in to comment.