Howdy! This is a Todo(s) backing API implemented in Node.js w/Express.
This app is ready to push to Cloud Foundry and will rely on the Node.js Buildpack to automate containerization of the app.
- Specify version of Node.js to use
- Cloud Foundry vendoring
- Vendor using npm
- Vendor using yarn
- Vendor using yarn offline
You can target the proper Node.js version to use by supplying this information in package.json
or leave it undefined and CF will use the lowest LTS release of Node.js supported by Buildpack being used. This is one of the benefits of CF, that is the Buildpack provides a means to control and upgrade multiple versions of the Node.js middleware stack from 6.x to 11.x so you don't have to :)
{
"engines": {
"node": "10.14.1"
}
}
If you want CF to handle vendoring of your Node.js dependencies it will gladly do so. You can simply clone this sample and push the code "as is" to CF and the Node.js Buildpack will run npm install
and pull down dependencies from the public NPM registry. This is great for convenience but often deployments of CF are air-gapped and can't reach such registries.
If we clone and push this sample un-vendored (as provided) then all resolved dependencies will coming from https://registry.npmjs.org
and be placed into node_modules
along with package-lock.json
file that describes the resolved dependencies in node_modules
.
app.js
manifest.yml
package.json
Before we push to CF we can vendor by running npm install
to pull down dependencies and generate the package-lock.json
file. If we push at this point we can provide a fully encapsulated app for CF, thus it will not run npm install
and will simply use our vendored dependencies in node_modules
.
app.js
manifest.yml
node_modules/
package-lock.json
package.json
Similar to vendoring with npm, we can run yarn install
to pull down dependencies and such. In this case the registry will be https://registry.yarnpkg.com
.
app.js
manifest.yml
node_modules/
package.json
yarn.lock
If you're a Node.js developer using Cloud Foundry then here's a short list of things to consider.
- Make sure you're using a Node version provided by the Node.js Buildpack
- Understand how to Vendor a Node.js application for Cloud Foundry
- In particular running Node.js apps in an air-gapped CF
- Understand the application ENVIRONMENT being presented to the Node.js app
$ http localhost:8080/ title="make bacon pancakes"
HTTP/1.1 201 Created
{
"id": 1,
"title": "make bacon pancakes"
}
$ http localhost:8080/1
HTTP/1.1 200 OK
{
"completed": "true",
"id": 1,
"title": "make bacon pancakes"
}
$ http PATCH localhost:8080/1 completed=true
HTTP/1.1 200 OK
{
"completed": "true",
"id": 1,
"title": "make bacon pancakes"
}
$ http DELETE localhost:8080/1
HTTP/1.1 200 OK
{
"completed": "true",
"id": 1,
"title": "make bacon pancakes"
}
$ http localhost:8080/
HTTP/1.1 200 OK
[]