From a6b56be0e5d2bfb4bb7ab4e57088d26693c58c54 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Wed, 25 Oct 2017 23:07:05 -0400 Subject: [PATCH 01/41] Update --- package-lock.json | 74 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +-- views/index.html | 2 +- 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..33b5d43 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,74 @@ +{ + "name": "nodejs-ex", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "basic-auth": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", + "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "morgan": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", + "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "requires": { + "basic-auth": "2.0.0", + "debug": "2.6.9", + "depd": "1.1.1", + "on-finished": "2.3.0", + "on-headers": "1.0.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "object-assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", + "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=" + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + } + } +} diff --git a/package.json b/package.json index d802fd6..3851b82 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "express": "^4.13.4", "mocha": "^2.4.5", "mongodb": "^2.1.16", - "morgan": "^1.7.0", - "object-assign":"4.1.0" + "morgan": "^1.9.0", + "object-assign": "^4.1.0" }, "engine": { "node": "*", diff --git a/views/index.html b/views/index.html index aea7910..8ebde3d 100644 --- a/views/index.html +++ b/views/index.html @@ -216,7 +216,7 @@ pre {
-

Welcome to your Node.js application on OpenShift

+

This Is A Change

From 09c90c2e5dad6174163478079b65af28de1d16b0 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Wed, 25 Oct 2017 23:29:43 -0400 Subject: [PATCH 02/41] Update --- README.md | 247 -------- helm/nodejs/Chart.yaml | 9 - helm/nodejs/templates/NOTES.txt | 3 - helm/nodejs/templates/buildconfig.yaml | 38 -- helm/nodejs/templates/deploymentconfig.yaml | 49 -- helm/nodejs/templates/imagestream.yaml | 6 - helm/nodejs/templates/route.yaml | 9 - helm/nodejs/templates/service.yaml | 13 - helm/nodejs/values.yaml | 20 - openshift/pipeline/Jenkinsfile | 6 - openshift/pipeline/README.md | 14 - .../templates/nodejs-mongodb-persistent.json | 551 ------------------ openshift/templates/nodejs-mongodb.json | 527 ----------------- openshift/templates/nodejs.json | 291 --------- package-lock.json | 338 ++++++++++- package.json | 39 +- public/views/pages/index.html | 14 + server.js | 111 +--- tests/app_test.js | 31 - views/index.html | 309 ---------- 20 files changed, 362 insertions(+), 2263 deletions(-) delete mode 100644 README.md delete mode 100755 helm/nodejs/Chart.yaml delete mode 100644 helm/nodejs/templates/NOTES.txt delete mode 100755 helm/nodejs/templates/buildconfig.yaml delete mode 100755 helm/nodejs/templates/deploymentconfig.yaml delete mode 100755 helm/nodejs/templates/imagestream.yaml delete mode 100644 helm/nodejs/templates/route.yaml delete mode 100755 helm/nodejs/templates/service.yaml delete mode 100644 helm/nodejs/values.yaml delete mode 100644 openshift/pipeline/Jenkinsfile delete mode 100644 openshift/pipeline/README.md delete mode 100644 openshift/templates/nodejs-mongodb-persistent.json delete mode 100644 openshift/templates/nodejs-mongodb.json delete mode 100644 openshift/templates/nodejs.json create mode 100644 public/views/pages/index.html delete mode 100644 tests/app_test.js delete mode 100644 views/index.html diff --git a/README.md b/README.md deleted file mode 100644 index 8e8223c..0000000 --- a/README.md +++ /dev/null @@ -1,247 +0,0 @@ - - - - -- [Node.js sample app on OpenShift!](#nodejs-sample-app-on-openshift) - * [OpenShift Origin v3 setup](#openshift-origin-v3-setup) - + [Running a virtual machine with Vagrant](#running-a-virtual-machine-with-vagrant) - + [Starting a Docker container](#starting-a-docker-container) - + [Downloading the Binary](#downloading-the-binary) - + [Running an Ansible playbook](#running-an-ansible-playbook) - * [Creating a project](#creating-a-project) - * [Creating new apps](#creating-new-apps) - + [Create a new app from source code (method 1)](#create-a-new-app-from-source-code-method-1) - + [Create a new app from a template (method 2)](#create-a-new-app-from-a-template-method-2) - + [Build the app](#build-the-app) - + [Deploy the app](#deploy-the-app) - + [Configure routing](#configure-routing) - + [Create a new app from an image (method 3)](#create-a-new-app-from-an-image-method-3) - + [Setting environment variables](#setting-environment-variables) - + [Success](#success) - + [Pushing updates](#pushing-updates) - * [Debugging](#debugging) - * [Web UI](#web-ui) - * [Looking for help](#looking-for-help) - * [Compatibility](#compatibility) - * [License](#license) - - - -## Node.js sample app on OpenShift! ------------------ - -This example will serve a welcome page and the current hit count as stored in a database. - -### OpenShift Origin v3 setup - -There are four methods to get started with OpenShift v3: - - - Running a virtual machine with Vagrant - - Starting a Docker container - - Downloading the binary - - Running an Ansible playbook - -#### Running a virtual machine with Vagrant - -One option is to use the Vagrant all-in-one launch as described in the [OpenShift Origin All-In-One Virtual Machine](https://www.openshift.org/vm/). This option works on Mac, Windows and Linux, but requires that you install [Vagrant](https://www.vagrantup.com/downloads.html) running [VirtualBox](https://www.virtualbox.org/wiki/Downloads). - -#### Starting a Docker container - -Another option is running the OpenShift Origin Docker container image from [Docker Hub](https://hub.docker.com/r/openshift/origin/) launch as described in the [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#running-in-a-docker-container). This method is supported on Fedora, CentOS, and Red Hat Enterprise Linux (RHEL) hosts only. - -#### Downloading the Binary - -Red Hat periodically publishes OpenShift Origin Server binaries for Linux, which you can download on the OpenShift Origin GitHub [Release](https://github.com/openshift/origin/releases) page. Instructions on how to install and launch the Openshift Origin Server from binary are described in [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#downloading-the-binary). - -#### Running an Ansible playbook - -Outlined as the [Advanced Installation](https://docs.openshift.org/latest/install_config/install/advanced_install.html) method for poduction environments, OpenShift Origin is also installable via Ansible playbook made avaialble on the GitHub [openshift-ansible](https://github.com/openshift/openshift-ansible) repo. - - -### Creating a project - -After logging in with `oc login` (default username/password: openshift), if you don't have a project setup all ready, go ahead and take care of that: - - $ oc new-project nodejs-echo \ - $ --display-name="nodejs" --description="Sample Node.js app" - -That's it, project has been created. Though it would probably be good to set your current project to this (thought new-project does it automatically as well), such as: - - $ oc project nodejs-echo - -### Creating new apps - -You can create a new OpenShift application using the web console or by running the `oc new-app` command from the CLI. With the OpenShift CLI there are three ways to create a new application, by specifying either: - -- [source code](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-source-code) -- [OpenShift templates](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-a-template) -- [DockerHub images](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-an-image) - -#### Create a new app from source code (method 1) - -Pointing `oc new-app` at source code kicks off a chain of events, for our example run: - - $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp - -The tool will inspect the source code, locate an appropriate image on DockerHub, create an ImageStream for that image, and then create the right build configuration, deployment configuration and service definition. - -(The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later.) - -#### Create a new app from a template (method 2) - -We can also [create new apps using OpenShift template files](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-a-template). Clone the demo app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). - - $ git clone https://github.com/openshift/nodejs-ex - -Looking at the repo, you'll notice three files in the openshift/template directory: - - nodejs-ex - ├── openshift - │   └── templates - │   ├── nodejs.json - │   ├── nodejs-mongodb.json - │   └── nodejs-mongodb-persistent.json - ├── package.json - ├── README.md - ├── server.js - ├── tests - │   └── app_test.js - └── views - └── index.html - -We can create the the new app from the `nodejs.json` template by using the `-f` flag and pointing the tool at a path to the template file: - - $ oc new-app -f /path/to/nodejs.json - -#### Build the app - -`oc new-app` will kick off a build once all required dependencies are confirmed. - -Check the status of your new nodejs app with the command: - - $ oc status - -Which should return something like: - - In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 - - svc/nodejs-ex - 172.30.108.183:8080 - dc/nodejs-ex deploys istag/nodejs-ex:latest <- - bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 - build #1 running for 7 seconds - deployment #1 waiting on image or update - -Note the server address for the web console, as yours will likely differ if you're not using the Vagrant set-up. You can follow along with the web console to see what new resources have been created and watch the progress of builds and deployments. - -If the build is not yet started (you can check by running `oc get builds`), start one and stream the logs with: - - $ oc start-build nodejs-ex --follow - -You can alternatively leave off `--follow` and use `oc logs build/nodejs-ex-n` where *n* is the number of the build to track the output of the build. - -#### Deploy the app - -Deployment happens automatically once the new application image is available. To monitor its status either watch the web console or execute `oc get pods` to see when the pod is up. Another helpful command is - - $ oc get svc - -This will help indicate what IP address the service is running, the default port for it to deploy at is 8080. Output should look like: - - NAME CLUSTER-IP EXTERNAL-IP PORT(S) SELECTOR AGE - nodejs-ex 172.30.249.251 8080/TCP deploymentconfig=nodejs-ex,name=myapp 17m - -#### Configure routing - -An OpenShift route exposes a service at a host name, like www.example.com, so that external clients can reach it by name. - -DNS resolution for a host name is handled separately from routing; you may wish to configure a cloud domain that will always correctly resolve to the OpenShift router, or if using an unrelated host name you may need to modify its DNS records independently to resolve to the router. - -That aside, let's explore our new web console, which for our example is running at [https://10.2.2.2:8443](https://10.2.2.2:8443). - -After logging into the web console with your same CLI `oc login` credentials, click on the project we just created, then click `Create route`. - -If you're running OpenShift on a local machine, you can preview the new app by setting the Hostname to a localhost like: *10.2.2.2*. - -This could also be accomplished by running: - - $ oc expose svc/nodejs-ex --hostname=www.example.com - -Now navigate to the newly created Node.js web app at the hostname we just configured, for our example it was simply [https://10.2.2.2](https://10.2.2.2). - -#### Create a new app from an image (method 3) - -You may have noticed the index page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service. We could use the second OpenShift template example (`nodejs-mongodb.json`) but for the sake of demonstration let's point `oc new-app` at a DockerHub image: - - $ oc new-app centos/mongodb-26-centos7 \ - $ -e MONGODB_USER=admin,MONGODB_DATABASE=mongo_db,MONGODB_PASSWORD=secret,MONGODB_ADMIN_PASSWORD=super-secret - -The `-e` flag sets the environment variables we want used in the configuration of our new app. - -Running `oc status` or checking the web console will reveal the address of the newly created MongoDB: - - In project nodejs-echo on server https://10.2.2.2:8443 - - svc/mongodb-26-centos7 - 172.30.0.112:27017 - dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest - deployment #1 running for 43 seconds - 1 pod - - http://10.2.2.2 to pod port 8080-tcp (svc/nodejs-ex) - dc/nodejs-ex deploys istag/nodejs-ex:latest <- - bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 - deployment #1 deployed 14 minutes ago - 1 pod - -Note that the url for our new Mongo instance, for our example, is `172.30.0.112:27017`, yours will likely differ. - -#### Setting environment variables - -To take a look at environment variables set for each pod, run `oc env pods --all --list`. - -We need to add the environment variable `MONGO_URL` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. Run: - - $ oc set env dc/nodejs-ex MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db' - -Then check `oc status` to see that an updated deployment has been kicked off: - - In project nodejs-echo on server https://10.2.2.2:8443 - - svc/mongodb-26-centos7 - 172.30.0.112:27017 - dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest - deployment #1 deployed 2 hours ago - 1 pod - - http://10.2.2.2 to pod port 8080-tcp (svc/nodejs-ex) - dc/nodejs-ex deploys istag/nodejs-ex:latest <- - bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 - deployment #2 deployed about a minute ago - 1 pod - deployment #1 deployed 2 hours ago - -#### Success - -You should now have a Node.js welcome page showing the current hit count, as stored in a MongoDB database. - -#### Pushing updates - -Assuming you used the URL of your own forked repository, we can easily push changes and simply repeat the steps above which will trigger the newly built image to be deployed. - -### Debugging - -Review some of the common tips and suggestions [here](https://github.com/openshift/origin/blob/master/docs/debugging-openshift.md). - -### Web UI - -To run this example from the Web UI, you can same steps following done on the CLI as defined above. Here's a video showing it in motion: - - - - -### Looking for help - -If you get stuck at some point, or think that this document needs further details or clarification, you can give feedback and look for help using the channels mentioned in [the OpenShift Origin repo](https://github.com/openshift/origin), or by filing an issue. - -### Compatibility - -This repository is compatible with Node.js 4 and higher, excluding any alpha or beta versions. - -### License - -This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to [CC0](http://creativecommons.org/publicdomain/zero/1.0/). diff --git a/helm/nodejs/Chart.yaml b/helm/nodejs/Chart.yaml deleted file mode 100755 index 18c8d40..0000000 --- a/helm/nodejs/Chart.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: nodejs -version: 0.1 -description: An example Node.js application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md. -keywords: -- quickstart -- nodejs -home: https://access.redhat.com -sources: -- https://github.com/openshift/nodejs-ex diff --git a/helm/nodejs/templates/NOTES.txt b/helm/nodejs/templates/NOTES.txt deleted file mode 100644 index 94c70dd..0000000 --- a/helm/nodejs/templates/NOTES.txt +++ /dev/null @@ -1,3 +0,0 @@ -The following service(s) have been created in your project: {{ .Values.name }}. - -For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md. diff --git a/helm/nodejs/templates/buildconfig.yaml b/helm/nodejs/templates/buildconfig.yaml deleted file mode 100755 index 2153999..0000000 --- a/helm/nodejs/templates/buildconfig.yaml +++ /dev/null @@ -1,38 +0,0 @@ -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: {{ .Values.name | quote }} - annotations: - description: Defines how to build the application -spec: - source: - type: Git - git: - uri: {{ .Values.source_repository_url | quote }} - ref: {{ .Values.source_repository_ref | quote }} - contextDir: {{ .Values.context_dir | quote }} - strategy: - type: Source - sourceStrategy: - from: - kind: ImageStreamTag - namespace: {{ .Values.namespace | quote }} - name: nodejs:6 - env: - - name: NPM_MIRROR - value: {{ .Values.npm_mirror | quote }} - output: - to: - kind: ImageStreamTag - name: {{ print .Values.name ":latest" | quote }} - triggers: - - type: ImageChange - - type: ConfigChange - - type: GitHub - github: - secret: {{ .Values.github_webhook_secret | default (randAlphaNum 40) | quote }} - - type: Generic - generic: - secret: {{ .Values.generic_webhook_secret | default (randAlphaNum 40) | quote }} - postCommit: - script: npm test diff --git a/helm/nodejs/templates/deploymentconfig.yaml b/helm/nodejs/templates/deploymentconfig.yaml deleted file mode 100755 index 6380bff..0000000 --- a/helm/nodejs/templates/deploymentconfig.yaml +++ /dev/null @@ -1,49 +0,0 @@ -kind: DeploymentConfig -apiVersion: apps.openshift.io/v1 -metadata: - name: {{ .Values.name | quote }} - annotations: - description: Defines how to deploy the application server - template.alpha.openshift.io/wait-for-ready: 'true' -spec: - strategy: - type: Rolling - triggers: - - type: ImageChange - imageChangeParams: - automatic: true - containerNames: - - nodejs-example - from: - kind: ImageStreamTag - name: {{ print .Values.name ":latest" | quote }} - - type: ConfigChange - replicas: 1 - selector: - name: {{ .Values.name | quote }} - template: - metadata: - name: {{ .Values.name | quote }} - labels: - name: {{ .Values.name | quote }} - spec: - containers: - - name: nodejs-example - image: " " - ports: - - containerPort: 8080 - readinessProbe: - timeoutSeconds: 3 - initialDelaySeconds: 3 - httpGet: - path: "/" - port: 8080 - livenessProbe: - timeoutSeconds: 3 - initialDelaySeconds: 30 - httpGet: - path: "/" - port: 8080 - resources: - limits: - memory: {{ .Values.memory_limit | quote }} diff --git a/helm/nodejs/templates/imagestream.yaml b/helm/nodejs/templates/imagestream.yaml deleted file mode 100755 index 2252dc5..0000000 --- a/helm/nodejs/templates/imagestream.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: ImageStream -apiVersion: image.openshift.io/v1 -metadata: - name: {{ .Values.name | quote }} - annotations: - description: Keeps track of changes in the application image diff --git a/helm/nodejs/templates/route.yaml b/helm/nodejs/templates/route.yaml deleted file mode 100644 index eeb16ca..0000000 --- a/helm/nodejs/templates/route.yaml +++ /dev/null @@ -1,9 +0,0 @@ -kind: Route -apiVersion: route.openshift.io/v1 -metadata: - name: {{ .Values.name | quote }} -spec: - host: {{ .Values.application_domain | quote }} - to: - kind: Service - name: {{ .Values.name | quote }} diff --git a/helm/nodejs/templates/service.yaml b/helm/nodejs/templates/service.yaml deleted file mode 100755 index cfcc8ca..0000000 --- a/helm/nodejs/templates/service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -kind: Service -apiVersion: v1 -metadata: - name: {{ .Values.name | quote }} - annotations: - description: Exposes and load balances the application pods -spec: - ports: - - name: web - port: 8080 - targetPort: 8080 - selector: - name: {{ .Values.name | quote }} diff --git a/helm/nodejs/values.yaml b/helm/nodejs/values.yaml deleted file mode 100644 index 2a2509c..0000000 --- a/helm/nodejs/values.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Name: The name assigned to all of the frontend objects defined in this template. -name: nodejs-example -# Namespace: The OpenShift Namespace where the ImageStream resides. -namespace: openshift -# Memory Limit: Maximum amount of memory the container can use. -memory_limit: 512Mi -# Git Repository URL: The URL of the repository with your application source code. -source_repository_url: https://github.com/openshift/nodejs-ex.git -# Git Reference: Set this to a branch name, tag or other ref of your repository if you are not using the default branch. -source_repository_ref: -# Context Directory: Set this to the relative path to your project if it is not in the root of your repository. -context_dir: -# Application Hostname: The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted. -application_domain: -# GitHub Webhook Secret: Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted. -github_webhook_secret: -# Generic Webhook Secret: A secret string used to configure the Generic webhook. -generic_webhook_secret: -# Custom NPM Mirror URL: The custom NPM mirror URL -npm_mirror: diff --git a/openshift/pipeline/Jenkinsfile b/openshift/pipeline/Jenkinsfile deleted file mode 100644 index 44aa5d1..0000000 --- a/openshift/pipeline/Jenkinsfile +++ /dev/null @@ -1,6 +0,0 @@ -node('nodejs') { - stage 'build' - openshiftBuild(buildConfig: 'nodejs-ex', showBuildLogs: 'true') - stage 'deploy' - openshiftDeploy(deploymentConfig: 'nodejs-ex') -} diff --git a/openshift/pipeline/README.md b/openshift/pipeline/README.md deleted file mode 100644 index bc5e366..0000000 --- a/openshift/pipeline/README.md +++ /dev/null @@ -1,14 +0,0 @@ -This directory contains a Jenkinsfile which can be used to build -nodejs-ex using an OpenShift build pipeline. - -To do this, run: - -```bash -# create the nodejs example as usual -oc new-app https://github.com/openshift/nodejs-ex - -# now create the pipeline build controller from the openshift/pipeline -# subdirectory -oc new-app https://github.com/openshift/nodejs-ex \ - --context-dir=openshift/pipeline --name nodejs-ex-pipeline -``` diff --git a/openshift/templates/nodejs-mongodb-persistent.json b/openshift/templates/nodejs-mongodb-persistent.json deleted file mode 100644 index 9543b56..0000000 --- a/openshift/templates/nodejs-mongodb-persistent.json +++ /dev/null @@ -1,551 +0,0 @@ -{ - "kind": "Template", - "apiVersion": "v1", - "metadata": { - "name": "nodejs-mongo-persistent", - "annotations": { - "openshift.io/display-name": "Node.js + MongoDB (Persistent)", - "description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", - "tags": "quickstart,nodejs", - "iconClass": "icon-nodejs", - "openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration.", - "openshift.io/provider-display-name": "Red Hat, Inc.", - "openshift.io/documentation-url": "https://github.com/openshift/nodejs-ex", - "openshift.io/support-url": "https://access.redhat.com" - } - }, - "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", - "labels": { - "template": "nodejs-mongo-persistent" - }, - "objects": [ - { - "kind": "Secret", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}" - }, - "stringData": { - "database-user": "${DATABASE_USER}", - "database-password": "${DATABASE_PASSWORD}", - "database-admin-password" : "${DATABASE_ADMIN_PASSWORD}" - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Exposes and load balances the application pods", - "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]" - } - }, - "spec": { - "ports": [ - { - "name": "web", - "port": 8080, - "targetPort": 8080 - } - ], - "selector": { - "name": "${NAME}" - } - } - }, - { - "kind": "Route", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "template.openshift.io/expose-uri": "http://{.spec.host}{.spec.path}" - } - }, - "spec": { - "host": "${APPLICATION_DOMAIN}", - "to": { - "kind": "Service", - "name": "${NAME}" - } - } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Keeps track of changes in the application image" - } - } - }, - { - "kind": "BuildConfig", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Defines how to build the application", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "source": { - "type": "Git", - "git": { - "uri": "${SOURCE_REPOSITORY_URL}", - "ref": "${SOURCE_REPOSITORY_REF}" - }, - "contextDir": "${CONTEXT_DIR}" - }, - "strategy": { - "type": "Source", - "sourceStrategy": { - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "nodejs:6" - }, - "env": [ - { - "name": "NPM_MIRROR", - "value": "${NPM_MIRROR}" - } - ] - } - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - }, - "triggers": [ - { - "type": "ImageChange" - }, - { - "type": "ConfigChange" - }, - { - "type": "GitHub", - "github": { - "secret": "${GITHUB_WEBHOOK_SECRET}" - } - }, - { - "type": "Generic", - "generic": { - "secret": "${GENERIC_WEBHOOK_SECRET}" - } - } - ], - "postCommit": { - "script": "npm test" - } - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Defines how to deploy the application server", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "strategy": { - "type": "Recreate" - }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "nodejs-mongo-persistent" - ], - "from": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "${NAME}" - }, - "template": { - "metadata": { - "name": "${NAME}", - "labels": { - "name": "${NAME}" - } - }, - "spec": { - "containers": [ - { - "name": "nodejs-mongo-persistent", - "image": " ", - "ports": [ - { - "containerPort": 8080 - } - ], - "env": [ - { - "name": "DATABASE_SERVICE_NAME", - "value": "${DATABASE_SERVICE_NAME}" - }, - { - "name": "MONGODB_USER", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-user" - } - } - }, - { - "name": "MONGODB_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-password" - } - } - }, - { - "name": "MONGODB_DATABASE", - "value": "${DATABASE_NAME}" - }, - { - "name": "MONGODB_ADMIN_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-admin-password" - } - } - } - ], - "readinessProbe": { - "timeoutSeconds": 3, - "initialDelaySeconds": 3, - "httpGet": { - "path": "/pagecount", - "port": 8080 - } - }, - "livenessProbe": { - "timeoutSeconds": 3, - "initialDelaySeconds": 30, - "httpGet": { - "path": "/pagecount", - "port": 8080 - } - }, - "resources": { - "limits": { - "memory": "${MEMORY_LIMIT}" - } - } - } - ] - } - } - } - }, - { - "kind": "PersistentVolumeClaim", - "apiVersion": "v1", - "metadata": { - "name": "${DATABASE_SERVICE_NAME}" - }, - "spec": { - "accessModes": [ - "ReadWriteOnce" - ], - "resources": { - "requests": { - "storage": "${VOLUME_CAPACITY}" - } - } - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "annotations": { - "description": "Exposes the database server" - } - }, - "spec": { - "ports": [ - { - "name": "mongodb", - "port": 27017, - "targetPort": 27017 - } - ], - "selector": { - "name": "${DATABASE_SERVICE_NAME}" - } - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "annotations": { - "description": "Defines how to deploy the database", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "strategy": { - "type": "Recreate" - }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "mongodb" - ], - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "mongodb:3.2" - } - } - }, - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "${DATABASE_SERVICE_NAME}" - }, - "template": { - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "labels": { - "name": "${DATABASE_SERVICE_NAME}" - } - }, - "spec": { - "containers": [ - { - "name": "mongodb", - "image": " ", - "ports": [ - { - "containerPort": 27017 - } - ], - "env": [ - { - "name": "MONGODB_USER", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-user" - } - } - }, - { - "name": "MONGODB_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-password" - } - } - }, - { - "name": "MONGODB_DATABASE", - "value": "${DATABASE_NAME}" - }, - { - "name": "MONGODB_ADMIN_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-admin-password" - } - } - } - ], - "readinessProbe": { - "timeoutSeconds": 1, - "initialDelaySeconds": 3, - "exec": { - "command": [ - "/bin/sh", - "-i", - "-c", - "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\"" - ] - } - }, - "livenessProbe": { - "timeoutSeconds": 1, - "initialDelaySeconds": 30, - "tcpSocket": { - "port": 27017 - } - }, - "resources": { - "limits": { - "memory": "${MEMORY_MONGODB_LIMIT}" - } - }, - "volumeMounts": [ - { - "name": "${DATABASE_SERVICE_NAME}-data", - "mountPath": "/var/lib/mongodb/data" - } - ] - } - ], - "volumes": [ - { - "name": "${DATABASE_SERVICE_NAME}-data", - "persistentVolumeClaim": { - "claimName": "${DATABASE_SERVICE_NAME}" - } - } - ] - } - } - } - } - ], - "parameters": [ - { - "name": "NAME", - "displayName": "Name", - "description": "The name assigned to all of the frontend objects defined in this template.", - "required": true, - "value": "nodejs-mongo-persistent" - }, - { - "name": "NAMESPACE", - "displayName": "Namespace", - "description": "The OpenShift Namespace where the ImageStream resides.", - "required": true, - "value": "openshift" - }, - { - "name": "MEMORY_LIMIT", - "displayName": "Memory Limit", - "description": "Maximum amount of memory the Node.js container can use.", - "required": true, - "value": "512Mi" - }, - { - "name": "MEMORY_MONGODB_LIMIT", - "displayName": "Memory Limit (MongoDB)", - "description": "Maximum amount of memory the MongoDB container can use.", - "required": true, - "value": "512Mi" - }, - { - "name": "VOLUME_CAPACITY", - "displayName": "Volume Capacity", - "description": "Volume space available for data, e.g. 512Mi, 2Gi", - "value": "1Gi", - "required": true - }, - { - "name": "SOURCE_REPOSITORY_URL", - "displayName": "Git Repository URL", - "description": "The URL of the repository with your application source code.", - "required": true, - "value": "https://github.com/openshift/nodejs-ex.git" - }, - { - "name": "SOURCE_REPOSITORY_REF", - "displayName": "Git Reference", - "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." - }, - { - "name": "CONTEXT_DIR", - "displayName": "Context Directory", - "description": "Set this to the relative path to your project if it is not in the root of your repository." - }, - { - "name": "APPLICATION_DOMAIN", - "displayName": "Application Hostname", - "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.", - "value": "" - }, - { - "name": "GITHUB_WEBHOOK_SECRET", - "displayName": "GitHub Webhook Secret", - "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.", - "generate": "expression", - "from": "[a-zA-Z0-9]{40}" - }, - { - "name": "GENERIC_WEBHOOK_SECRET", - "displayName": "Generic Webhook Secret", - "description": "A secret string used to configure the Generic webhook.", - "generate": "expression", - "from": "[a-zA-Z0-9]{40}" - }, - { - "name": "DATABASE_SERVICE_NAME", - "displayName": "Database Service Name", - "required": true, - "value": "mongodb" - }, - { - "name": "DATABASE_USER", - "displayName": "MongoDB Username", - "description": "Username for MongoDB user that will be used for accessing the database.", - "generate": "expression", - "from": "user[A-Z0-9]{3}" - }, - { - "name": "DATABASE_PASSWORD", - "displayName": "MongoDB Password", - "description": "Password for the MongoDB user.", - "generate": "expression", - "from": "[a-zA-Z0-9]{16}" - }, - { - "name": "DATABASE_NAME", - "displayName": "Database Name", - "required": true, - "value": "sampledb" - }, - { - "name": "DATABASE_ADMIN_PASSWORD", - "displayName": "Database Administrator Password", - "description": "Password for the database admin user.", - "generate": "expression", - "from": "[a-zA-Z0-9]{16}" - }, - { - "name": "NPM_MIRROR", - "displayName": "Custom NPM Mirror URL", - "description": "The custom NPM mirror URL", - "value": "" - } - ] -} diff --git a/openshift/templates/nodejs-mongodb.json b/openshift/templates/nodejs-mongodb.json deleted file mode 100644 index 0649d62..0000000 --- a/openshift/templates/nodejs-mongodb.json +++ /dev/null @@ -1,527 +0,0 @@ -{ - "kind": "Template", - "apiVersion": "v1", - "metadata": { - "name": "nodejs-mongodb-example", - "annotations": { - "openshift.io/display-name": "Node.js + MongoDB (Ephemeral)", - "description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.", - "tags": "quickstart,nodejs", - "iconClass": "icon-nodejs", - "openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration. The database is stored in non-persistent storage, so this configuration should be used for experimental purposes only.", - "openshift.io/provider-display-name": "Red Hat, Inc.", - "openshift.io/documentation-url": "https://github.com/openshift/nodejs-ex", - "openshift.io/support-url": "https://access.redhat.com" - } - }, - "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", - "labels": { - "template": "nodejs-mongodb-example" - }, - "objects": [ - { - "kind": "Secret", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}" - }, - "stringData": { - "database-user": "${DATABASE_USER}", - "database-password": "${DATABASE_PASSWORD}", - "database-admin-password" : "${DATABASE_ADMIN_PASSWORD}" - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Exposes and load balances the application pods", - "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]" - } - }, - "spec": { - "ports": [ - { - "name": "web", - "port": 8080, - "targetPort": 8080 - } - ], - "selector": { - "name": "${NAME}" - } - } - }, - { - "kind": "Route", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "template.openshift.io/expose-uri": "http://{.spec.host}{.spec.path}" - } - }, - "spec": { - "host": "${APPLICATION_DOMAIN}", - "to": { - "kind": "Service", - "name": "${NAME}" - } - } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Keeps track of changes in the application image" - } - } - }, - { - "kind": "BuildConfig", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Defines how to build the application", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "source": { - "type": "Git", - "git": { - "uri": "${SOURCE_REPOSITORY_URL}", - "ref": "${SOURCE_REPOSITORY_REF}" - }, - "contextDir": "${CONTEXT_DIR}" - }, - "strategy": { - "type": "Source", - "sourceStrategy": { - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "nodejs:6" - }, - "env": [ - { - "name": "NPM_MIRROR", - "value": "${NPM_MIRROR}" - } - ] - } - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - }, - "triggers": [ - { - "type": "ImageChange" - }, - { - "type": "ConfigChange" - }, - { - "type": "GitHub", - "github": { - "secret": "${GITHUB_WEBHOOK_SECRET}" - } - }, - { - "type": "Generic", - "generic": { - "secret": "${GENERIC_WEBHOOK_SECRET}" - } - } - ], - "postCommit": { - "script": "npm test" - } - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Defines how to deploy the application server", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "strategy": { - "type": "Recreate" - }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "nodejs-mongodb-example" - ], - "from": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "${NAME}" - }, - "template": { - "metadata": { - "name": "${NAME}", - "labels": { - "name": "${NAME}" - } - }, - "spec": { - "containers": [ - { - "name": "nodejs-mongodb-example", - "image": " ", - "ports": [ - { - "containerPort": 8080 - } - ], - "env": [ - { - "name": "DATABASE_SERVICE_NAME", - "value": "${DATABASE_SERVICE_NAME}" - }, - { - "name": "MONGODB_USER", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-user" - } - } - }, - { - "name": "MONGODB_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-password" - } - } - }, - { - "name": "MONGODB_DATABASE", - "value": "${DATABASE_NAME}" - }, - { - "name": "MONGODB_ADMIN_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-admin-password" - } - } - } - ], - "readinessProbe": { - "timeoutSeconds": 3, - "initialDelaySeconds": 3, - "httpGet": { - "path": "/pagecount", - "port": 8080 - } - }, - "livenessProbe": { - "timeoutSeconds": 3, - "initialDelaySeconds": 30, - "httpGet": { - "path": "/pagecount", - "port": 8080 - } - }, - "resources": { - "limits": { - "memory": "${MEMORY_LIMIT}" - } - } - } - ] - } - } - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "annotations": { - "description": "Exposes the database server" - } - }, - "spec": { - "ports": [ - { - "name": "mongodb", - "port": 27017, - "targetPort": 27017 - } - ], - "selector": { - "name": "${DATABASE_SERVICE_NAME}" - } - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "annotations": { - "description": "Defines how to deploy the database", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "strategy": { - "type": "Recreate" - }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "mongodb" - ], - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "mongodb:3.2" - } - } - }, - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "${DATABASE_SERVICE_NAME}" - }, - "template": { - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "labels": { - "name": "${DATABASE_SERVICE_NAME}" - } - }, - "spec": { - "containers": [ - { - "name": "mongodb", - "image": " ", - "ports": [ - { - "containerPort": 27017 - } - ], - "env": [ - { - "name": "MONGODB_USER", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-user" - } - } - }, - { - "name": "MONGODB_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-password" - } - } - }, - { - "name": "MONGODB_DATABASE", - "value": "${DATABASE_NAME}" - }, - { - "name": "MONGODB_ADMIN_PASSWORD", - "valueFrom": { - "secretKeyRef" : { - "name" : "${NAME}", - "key" : "database-admin-password" - } - } - } - ], - "readinessProbe": { - "timeoutSeconds": 1, - "initialDelaySeconds": 3, - "exec": { - "command": [ - "/bin/sh", - "-i", - "-c", - "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\"" - ] - } - }, - "livenessProbe": { - "timeoutSeconds": 1, - "initialDelaySeconds": 30, - "tcpSocket": { - "port": 27017 - } - }, - "resources": { - "limits": { - "memory": "${MEMORY_MONGODB_LIMIT}" - } - }, - "volumeMounts": [ - { - "name": "${DATABASE_SERVICE_NAME}-data", - "mountPath": "/var/lib/mongodb/data" - } - ] - } - ], - "volumes": [ - { - "name": "${DATABASE_SERVICE_NAME}-data", - "emptyDir": { - "medium": "" - } - } - ] - } - } - } - } - ], - "parameters": [ - { - "name": "NAME", - "displayName": "Name", - "description": "The name assigned to all of the frontend objects defined in this template.", - "required": true, - "value": "nodejs-mongodb-example" - }, - { - "name": "NAMESPACE", - "displayName": "Namespace", - "description": "The OpenShift Namespace where the ImageStream resides.", - "required": true, - "value": "openshift" - }, - { - "name": "MEMORY_LIMIT", - "displayName": "Memory Limit", - "description": "Maximum amount of memory the Node.js container can use.", - "required": true, - "value": "512Mi" - }, - { - "name": "MEMORY_MONGODB_LIMIT", - "displayName": "Memory Limit (MongoDB)", - "description": "Maximum amount of memory the MongoDB container can use.", - "required": true, - "value": "512Mi" - }, - { - "name": "SOURCE_REPOSITORY_URL", - "displayName": "Git Repository URL", - "description": "The URL of the repository with your application source code.", - "required": true, - "value": "https://github.com/openshift/nodejs-ex.git" - }, - { - "name": "SOURCE_REPOSITORY_REF", - "displayName": "Git Reference", - "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." - }, - { - "name": "CONTEXT_DIR", - "displayName": "Context Directory", - "description": "Set this to the relative path to your project if it is not in the root of your repository." - }, - { - "name": "APPLICATION_DOMAIN", - "displayName": "Application Hostname", - "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.", - "value": "" - }, - { - "name": "GITHUB_WEBHOOK_SECRET", - "displayName": "GitHub Webhook Secret", - "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.", - "generate": "expression", - "from": "[a-zA-Z0-9]{40}" - }, - { - "name": "GENERIC_WEBHOOK_SECRET", - "displayName": "Generic Webhook Secret", - "description": "A secret string used to configure the Generic webhook.", - "generate": "expression", - "from": "[a-zA-Z0-9]{40}" - }, - { - "name": "DATABASE_SERVICE_NAME", - "displayName": "Database Service Name", - "required": true, - "value": "mongodb" - }, - { - "name": "DATABASE_USER", - "displayName": "MongoDB Username", - "description": "Username for MongoDB user that will be used for accessing the database.", - "generate": "expression", - "from": "user[A-Z0-9]{3}" - }, - { - "name": "DATABASE_PASSWORD", - "displayName": "MongoDB Password", - "description": "Password for the MongoDB user.", - "generate": "expression", - "from": "[a-zA-Z0-9]{16}" - }, - { - "name": "DATABASE_NAME", - "displayName": "Database Name", - "required": true, - "value": "sampledb" - }, - { - "name": "DATABASE_ADMIN_PASSWORD", - "displayName": "Database Administrator Password", - "description": "Password for the database admin user.", - "generate": "expression", - "from": "[a-zA-Z0-9]{16}" - }, - { - "name": "NPM_MIRROR", - "displayName": "Custom NPM Mirror URL", - "description": "The custom NPM mirror URL", - "value": "" - } - ] -} diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json deleted file mode 100644 index eb922c6..0000000 --- a/openshift/templates/nodejs.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "kind": "Template", - "apiVersion": "v1", - "metadata": { - "name": "nodejs-example", - "annotations": { - "openshift.io/display-name": "Node.js", - "description": "An example Node.js application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", - "tags": "quickstart,nodejs", - "iconClass": "icon-nodejs", - "openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration and application deployment configuration. It does not include a database.", - "openshift.io/provider-display-name": "Red Hat, Inc.", - "openshift.io/documentation-url": "https://github.com/openshift/nodejs-ex", - "openshift.io/support-url": "https://access.redhat.com" - } - }, - "message": "The following service(s) have been created in your project: ${NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", - "labels": { - "template": "nodejs-example" - }, - "objects": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Exposes and load balances the application pods" - } - }, - "spec": { - "ports": [ - { - "name": "web", - "port": 8080, - "targetPort": 8080 - } - ], - "selector": { - "name": "${NAME}" - } - } - }, - { - "kind": "Route", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "template.openshift.io/expose-uri": "http://{.spec.host}{.spec.path}" - } - }, - "spec": { - "host": "${APPLICATION_DOMAIN}", - "to": { - "kind": "Service", - "name": "${NAME}" - } - } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Keeps track of changes in the application image" - } - } - }, - { - "kind": "BuildConfig", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Defines how to build the application", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "source": { - "type": "Git", - "git": { - "uri": "${SOURCE_REPOSITORY_URL}", - "ref": "${SOURCE_REPOSITORY_REF}" - }, - "contextDir": "${CONTEXT_DIR}" - }, - "strategy": { - "type": "Source", - "sourceStrategy": { - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "nodejs:6" - }, - "env": [ - { - "name": "NPM_MIRROR", - "value": "${NPM_MIRROR}" - } - ] - } - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - }, - "triggers": [ - { - "type": "ImageChange" - }, - { - "type": "ConfigChange" - }, - { - "type": "GitHub", - "github": { - "secret": "${GITHUB_WEBHOOK_SECRET}" - } - }, - { - "type": "Generic", - "generic": { - "secret": "${GENERIC_WEBHOOK_SECRET}" - } - } - ], - "postCommit": { - "script": "npm test" - } - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "${NAME}", - "annotations": { - "description": "Defines how to deploy the application server", - "template.alpha.openshift.io/wait-for-ready": "true" - } - }, - "spec": { - "strategy": { - "type": "Rolling" - }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "nodejs-example" - ], - "from": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "${NAME}" - }, - "template": { - "metadata": { - "name": "${NAME}", - "labels": { - "name": "${NAME}" - } - }, - "spec": { - "containers": [ - { - "name": "nodejs-example", - "image": " ", - "ports": [ - { - "containerPort": 8080 - } - ], - "readinessProbe": { - "timeoutSeconds": 3, - "initialDelaySeconds": 3, - "httpGet": { - "path": "/", - "port": 8080 - } - }, - "livenessProbe": { - "timeoutSeconds": 3, - "initialDelaySeconds": 30, - "httpGet": { - "path": "/", - "port": 8080 - } - }, - "resources": { - "limits": { - "memory": "${MEMORY_LIMIT}" - } - }, - "env": [ - ], - "resources": { - "limits": { - "memory": "${MEMORY_LIMIT}" - } - } - } - ] - } - } - } - } - ], - "parameters": [ - { - "name": "NAME", - "displayName": "Name", - "description": "The name assigned to all of the frontend objects defined in this template.", - "required": true, - "value": "nodejs-example" - }, - { - "name": "NAMESPACE", - "displayName": "Namespace", - "description": "The OpenShift Namespace where the ImageStream resides.", - "required": true, - "value": "openshift" - }, - { - "name": "MEMORY_LIMIT", - "displayName": "Memory Limit", - "description": "Maximum amount of memory the container can use.", - "required": true, - "value": "512Mi" - }, - { - "name": "SOURCE_REPOSITORY_URL", - "displayName": "Git Repository URL", - "description": "The URL of the repository with your application source code.", - "required": true, - "value": "https://github.com/openshift/nodejs-ex.git" - }, - { - "name": "SOURCE_REPOSITORY_REF", - "displayName": "Git Reference", - "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." - }, - { - "name": "CONTEXT_DIR", - "displayName": "Context Directory", - "description": "Set this to the relative path to your project if it is not in the root of your repository." - }, - { - "name": "APPLICATION_DOMAIN", - "displayName": "Application Hostname", - "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.", - "value": "" - }, - { - "name": "GITHUB_WEBHOOK_SECRET", - "displayName": "GitHub Webhook Secret", - "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.", - "generate": "expression", - "from": "[a-zA-Z0-9]{40}" - }, - { - "name": "GENERIC_WEBHOOK_SECRET", - "displayName": "Generic Webhook Secret", - "description": "A secret string used to configure the Generic webhook.", - "generate": "expression", - "from": "[a-zA-Z0-9]{40}" - }, - { - "name": "NPM_MIRROR", - "displayName": "Custom NPM Mirror URL", - "description": "The custom NPM mirror URL", - "value": "" - } - ] -} diff --git a/package-lock.json b/package-lock.json index 33b5d43..abc655f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,70 @@ { - "name": "nodejs-ex", - "version": "0.0.1", + "name": "diapers_new", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { - "basic-auth": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", - "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", "requires": { - "safe-buffer": "5.1.1" + "mime-types": "2.1.17", + "negotiator": "0.6.1" } }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.1", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.15" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -25,21 +78,156 @@ "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, - "morgan": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", - "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", + "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", "requires": { - "basic-auth": "2.0.0", + "accepts": "1.3.4", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "1.1.1", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.0", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", "on-finished": "2.3.0", - "on-headers": "1.0.1" + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.2", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.1", + "serve-static": "1.13.1", + "setprototypeof": "1.1.0", + "statuses": "1.3.1", + "type-is": "1.6.15", + "utils-merge": "1.0.1", + "vary": "1.1.2" + } + }, + "finalhandler": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.3.1", + "unpipe": "1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.3.1" + }, + "dependencies": { + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", + "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "requires": { + "mime-db": "1.30.0" } }, "ms": { @@ -47,10 +235,10 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "object-assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=" + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" }, "on-finished": { "version": "2.3.0", @@ -60,15 +248,123 @@ "ee-first": "1.1.1" } }, - "on-headers": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", - "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=" + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "promise": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz", + "integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=", + "requires": { + "asap": "2.0.6" + } + }, + "proxy-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", + "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.5.2" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + } }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.1", + "destroy": "1.0.4", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.3.1" + } + }, + "serve-static": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", + "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", + "requires": { + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.1" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.17" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" } } } diff --git a/package.json b/package.json index 3851b82..90842fb 100644 --- a/package.json +++ b/package.json @@ -1,34 +1,21 @@ { - "name": "nodejs-ex", - "version": "0.0.1", - "description": "Node.js sample app for OpenShift 3", + "name": "diapers_new", + "version": "1.0.0", + "description": "", "main": "server.js", - "dependencies": { - "chai": "^3.5.0", - "chai-http": "^2.0.1", - "ejs": "^2.4.1", - "express": "^4.13.4", - "mocha": "^2.4.5", - "mongodb": "^2.1.16", - "morgan": "^1.9.0", - "object-assign": "^4.1.0" - }, - "engine": { - "node": "*", - "npm": "*" - }, - "scripts": { - "start": "node server.js", - "test": "IP=0.0.0.0 PORT=3030 mocha --timeout 5000 tests/*_test.js" - }, + "scripts": {}, "repository": { "type": "git", - "url": "http://github.com/openshift/nodejs-ex.git" + "url": "git+https://github.com/briandavidjoyner/diapers_new.git" }, - "author": "Steve Speicher ", - "license": "CC-BY-1.0", + "author": "", + "license": "ISC", "bugs": { - "url": "http://github.com/openshift/nodejs-ex/issues" + "url": "https://github.com/briandavidjoyner/diapers_new/issues" }, - "homepage": "http://github.com/openshift/nodejs-ex" + "homepage": "https://github.com/briandavidjoyner/diapers_new#readme", + "dependencies": { + "express": "^4.16.2", + "promise": "^8.0.1" + } } diff --git a/public/views/pages/index.html b/public/views/pages/index.html new file mode 100644 index 0000000..9aa55e5 --- /dev/null +++ b/public/views/pages/index.html @@ -0,0 +1,14 @@ + + + + + +
+ + + URL + + + + \ No newline at end of file diff --git a/server.js b/server.js index 0415948..f70d878 100644 --- a/server.js +++ b/server.js @@ -1,105 +1,30 @@ -// OpenShift sample Node application +//Dependencies var express = require('express'), - app = express(), - morgan = require('morgan'); - -Object.assign=require('object-assign') + webapp = express(), + Promise = require('promise'); -app.engine('html', require('ejs').renderFile); -app.use(morgan('combined')) +//OpenShift Settings +var ipaddress = process.env.OPENSHIFT_NODEJS_IP || 'localhost', + port = process.env.OPENSHIFT_NODEJS_PORT || 3000; -var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080, - ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0', - mongoURL = process.env.OPENSHIFT_MONGODB_DB_URL || process.env.MONGO_URL, - mongoURLLabel = ""; +//External Routing +webapp.get('/', function (req, res, next) { + + var options = {}; -if (mongoURL == null && process.env.DATABASE_SERVICE_NAME) { - var mongoServiceName = process.env.DATABASE_SERVICE_NAME.toUpperCase(), - mongoHost = process.env[mongoServiceName + '_SERVICE_HOST'], - mongoPort = process.env[mongoServiceName + '_SERVICE_PORT'], - mongoDatabase = process.env[mongoServiceName + '_DATABASE'], - mongoPassword = process.env[mongoServiceName + '_PASSWORD'] - mongoUser = process.env[mongoServiceName + '_USER']; - - if (mongoHost && mongoPort && mongoDatabase) { - mongoURLLabel = mongoURL = 'mongodb://'; - if (mongoUser && mongoPassword) { - mongoURL += mongoUser + ':' + mongoPassword + '@'; - } - // Provide UI label that excludes user id and pw - mongoURLLabel += mongoHost + ':' + mongoPort + '/' + mongoDatabase; - mongoURL += mongoHost + ':' + mongoPort + '/' + mongoDatabase; - - } -} -var db = null, - dbDetails = new Object(); - -var initDb = function(callback) { - if (mongoURL == null) return; - - var mongodb = require('mongodb'); - if (mongodb == null) return; - - mongodb.connect(mongoURL, function(err, conn) { + res.sendFile(__dirname + '/public/views/pages/index.html', options, function (err) { if (err) { - callback(err); + next(err); + } else { return; } - - db = conn; - dbDetails.databaseName = db.databaseName; - dbDetails.url = mongoURLLabel; - dbDetails.type = 'MongoDB'; - - console.log('Connected to MongoDB at: %s', mongoURL); }); -}; -app.get('/', function (req, res) { - // try to initialize the db on every request if it's not already - // initialized. - if (!db) { - initDb(function(err){}); - } - if (db) { - var col = db.collection('counts'); - // Create a document with request IP and current time of request - col.insert({ip: req.ip, date: Date.now()}); - col.count(function(err, count){ - res.render('index.html', { pageCountMessage : count, dbInfo: dbDetails }); - }); - } else { - res.render('index.html', { pageCountMessage : null}); - } }); -app.get('/pagecount', function (req, res) { - // try to initialize the db on every request if it's not already - // initialized. - if (!db) { - initDb(function(err){}); - } - if (db) { - db.collection('counts').count(function(err, count ){ - res.send('{ pageCount: ' + count + '}'); - }); - } else { - res.send('{ pageCount: -1 }'); - } -}); +webapp.use('/public', express.static(__dirname + '/public')); -// error handling -app.use(function(err, req, res, next){ - console.error(err.stack); - res.status(500).send('Something bad happened!'); -}); - -initDb(function(err){ - console.log('Error connecting to Mongo. Message:\n'+err); -}); - -app.listen(port, ip); -console.log('Server running on http://%s:%s', ip, port); - -module.exports = app ; +//Webapp Initialize +webapp.listen(3000, function () { + console.log('started'); +}); \ No newline at end of file diff --git a/tests/app_test.js b/tests/app_test.js deleted file mode 100644 index 28da5a0..0000000 --- a/tests/app_test.js +++ /dev/null @@ -1,31 +0,0 @@ -var server = require('../server'), - chai = require('chai'), - chaiHTTP = require('chai-http'), - should = chai.should(); - -chai.use(chaiHTTP); - -reqServer = process.env.HTTP_TEST_SERVER || server - -describe('Basic routes tests', function() { - - it('GET to / should return 200', function(done){ - chai.request(reqServer) - .get('/') - .end(function(err, res) { - res.should.have.status(200); - done(); - }) - - }) - - it('GET to /pagecount should return 200', function(done){ - chai.request(reqServer) - .get('/pagecount') - .end(function(err, res) { - res.should.have.status(200); - done(); - }) - - }) -}) diff --git a/views/index.html b/views/index.html deleted file mode 100644 index 8ebde3d..0000000 --- a/views/index.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - Welcome to OpenShift - - - - - - - -
-
-

This Is A Change

-
- - -
-
-
-

How to use this example application

-

For instructions on how to use this application with OpenShift, start by reading the Developer Guide.

- -

Deploying code changes

-

- The source code for this application is available to be forked from the OpenShift GitHub repository. - You can configure a webhook in your repository to make OpenShift automatically start a build whenever you push your code: -

- -
    -
  1. From the Web Console homepage, navigate to your project
  2. -
  3. Click on Browse > Builds
  4. -
  5. Click the link with your BuildConfig name
  6. -
  7. Click the Configuration tab
  8. -
  9. Click the "Copy to clipboard" icon to the right of the "GitHub webhook URL" field
  10. -
  11. Navigate to your repository on GitHub and click on repository settings > webhooks > Add webhook
  12. -
  13. Paste your webhook URL provided by OpenShift
  14. -
  15. Leave the defaults for the remaining fields — that's it!
  16. -
-

After you save your webhook, if you refresh your settings page you can see the status of the ping that Github sent to OpenShift to verify it can reach the server.

-

Note: adding a webhook requires your OpenShift server to be reachable from GitHub.

- -

Working in your local Git repository

-

If you forked the application from the OpenShift GitHub example, you'll need to manually clone the repository to your local system. Copy the application's source code Git URL and then run:

- -
$ git clone <git_url> <directory_to_create>
-
-# Within your project directory
-# Commit your changes and push to OpenShift
-
-$ git commit -a -m 'Some commit message'
-$ git push
- -

After pushing changes, you'll need to manually trigger a build if you did not setup a webhook as described above.

- -
- -
-
- -

Managing your application

- -

Documentation on how to manage your application from the Web Console or Command Line is available at the Developer Guide.

- -

Web Console

-

You can use the Web Console to view the state of your application components and launch new builds.

- -

Command Line

-

With the OpenShift command line interface (CLI), you can create applications and manage projects from a terminal.

- -

Development Resources

- - -

Request information

-

Page view count: - <% if (pageCountMessage) { %> - <%=pageCountMessage%> -

-

DB Connection Info:

-
APIInputs
- - -
Type:<%= dbInfo.type %>
URL:<%= dbInfo.url %>
-
- <% } else { %> - No database configured -

- <%} %> -
- - - - - - From 2430900fc7c9090a131d7c970dfd5025a017c423 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Thu, 26 Oct 2017 00:01:37 -0400 Subject: [PATCH 03/41] Updates --- package-lock.json | 25 +++++++++++++++++++++++++ package.json | 5 ++++- server.js | 17 +++++++++++------ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index abc655f..c4499ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,14 @@ "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, + "basic-auth": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", + "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "requires": { + "safe-buffer": "5.1.1" + } + }, "body-parser": { "version": "1.18.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", @@ -230,6 +238,18 @@ "mime-db": "1.30.0" } }, + "morgan": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", + "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "requires": { + "basic-auth": "2.0.0", + "debug": "2.6.9", + "depd": "1.1.1", + "on-finished": "2.3.0", + "on-headers": "1.0.1" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -248,6 +268,11 @@ "ee-first": "1.1.1" } }, + "on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=" + }, "parseurl": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", diff --git a/package.json b/package.json index 90842fb..9759cf0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "1.0.0", "description": "", "main": "server.js", - "scripts": {}, + "scripts": { + "start": "node server.js" + }, "repository": { "type": "git", "url": "git+https://github.com/briandavidjoyner/diapers_new.git" @@ -16,6 +18,7 @@ "homepage": "https://github.com/briandavidjoyner/diapers_new#readme", "dependencies": { "express": "^4.16.2", + "morgan": "^1.9.0", "promise": "^8.0.1" } } diff --git a/server.js b/server.js index f70d878..176aca9 100644 --- a/server.js +++ b/server.js @@ -1,11 +1,15 @@ //Dependencies var express = require('express'), webapp = express(), - Promise = require('promise'); + Promise = require('promise'), + morgan = require('morgan'); //OpenShift Settings -var ipaddress = process.env.OPENSHIFT_NODEJS_IP || 'localhost', - port = process.env.OPENSHIFT_NODEJS_PORT || 3000; +var ip = process.env.OPENSHIFT_NODEJS_IP || 'localhost', +var port = process.env.OPENSHIFT_NODEJS_PORT || 3000; + +//Reporting +app.use(morgan('combined')); //External Routing webapp.get('/', function (req, res, next) { @@ -25,6 +29,7 @@ webapp.get('/', function (req, res, next) { webapp.use('/public', express.static(__dirname + '/public')); //Webapp Initialize -webapp.listen(3000, function () { - console.log('started'); -}); \ No newline at end of file +app.listen(port, ip); +console.log('working'); + +module.exports = webapp; \ No newline at end of file From 16a61d71f3dd668e93f393521fefe05cc930f6c9 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Thu, 26 Oct 2017 00:05:29 -0400 Subject: [PATCH 04/41] Fixes --- server.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index 176aca9..1f613f5 100644 --- a/server.js +++ b/server.js @@ -1,15 +1,15 @@ //Dependencies -var express = require('express'), - webapp = express(), - Promise = require('promise'), - morgan = require('morgan'); +var express = require('express'); +var webapp = express(); +var Promise = require('promise'); +var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.OPENSHIFT_NODEJS_IP || 'localhost', +var ip = process.env.OPENSHIFT_NODEJS_IP || 'localhost'; var port = process.env.OPENSHIFT_NODEJS_PORT || 3000; //Reporting -app.use(morgan('combined')); +webapp.use(morgan('combined')); //External Routing webapp.get('/', function (req, res, next) { @@ -29,7 +29,7 @@ webapp.get('/', function (req, res, next) { webapp.use('/public', express.static(__dirname + '/public')); //Webapp Initialize -app.listen(port, ip); +webapp.listen(port, ip); console.log('working'); module.exports = webapp; \ No newline at end of file From d40b8f64af0dd0964fbc00f2ef10f7c20abffcb3 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Thu, 26 Oct 2017 08:03:38 -0400 Subject: [PATCH 05/41] Fix Route --- server.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/server.js b/server.js index 1f613f5..c654d6f 100644 --- a/server.js +++ b/server.js @@ -12,18 +12,10 @@ var port = process.env.OPENSHIFT_NODEJS_PORT || 3000; webapp.use(morgan('combined')); //External Routing -webapp.get('/', function (req, res, next) { - - var options = {}; - - res.sendFile(__dirname + '/public/views/pages/index.html', options, function (err) { - if (err) { - next(err); - } else { - return; - } - }); +webapp.get('/', function(req, res) { + console.log(__dirname); + res.sendFile(__dirname + '/public/views/pages/index.html'); }); webapp.use('/public', express.static(__dirname + '/public')); From 9f61c3f3aaf1761899b150a251c1bdc915bb9ca0 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Fri, 27 Oct 2017 09:38:27 -0400 Subject: [PATCH 06/41] Update --- server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index c654d6f..94a3db6 100644 --- a/server.js +++ b/server.js @@ -15,13 +15,14 @@ webapp.use(morgan('combined')); webapp.get('/', function(req, res) { console.log(__dirname); - res.sendFile(__dirname + '/public/views/pages/index.html'); + //res.sendFile(__dirname + '/public/views/pages/index.html'); + res.send('works'); }); webapp.use('/public', express.static(__dirname + '/public')); //Webapp Initialize webapp.listen(port, ip); -console.log('working'); +console.log('working again'); module.exports = webapp; \ No newline at end of file From 6ce1afb13441d4d17cc3e7e5e5ee1934b4c02487 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Thu, 2 Nov 2017 08:44:18 -0400 Subject: [PATCH 07/41] Update --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 94a3db6..d5516ea 100644 --- a/server.js +++ b/server.js @@ -23,6 +23,6 @@ webapp.use('/public', express.static(__dirname + '/public')); //Webapp Initialize webapp.listen(port, ip); -console.log('working again'); +console.log('live on ip: ' + ip + ':' + port); module.exports = webapp; \ No newline at end of file From abde3d89e6000991ce241f3b5e18621e19e9c3ba Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Thu, 2 Nov 2017 09:10:13 -0400 Subject: [PATCH 08/41] Update Route --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index d5516ea..f142615 100644 --- a/server.js +++ b/server.js @@ -5,8 +5,8 @@ var Promise = require('promise'); var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.OPENSHIFT_NODEJS_IP || 'localhost'; -var port = process.env.OPENSHIFT_NODEJS_PORT || 3000; +var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; +var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 3000; //Reporting webapp.use(morgan('combined')); From 6bdc32ad2a1985570f64ac1eec67ba6c008614ab Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Thu, 2 Nov 2017 20:10:14 -0400 Subject: [PATCH 09/41] Test --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index f142615..1f80011 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,4 @@ -//Dependencies +//Dependencies var express = require('express'); var webapp = express(); var Promise = require('promise'); From 7335ec926a94c44f6f6a2bed11f276cf9f5ab6e2 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Fri, 3 Nov 2017 22:56:07 -0400 Subject: [PATCH 10/41] Fix Port --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 1f80011..a683cee 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ var morgan = require('morgan'); //OpenShift Settings var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; -var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 3000; +var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //Reporting webapp.use(morgan('combined')); From 985a90d07606aa5a760d9cd9cceddbb98a001ed4 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Fri, 3 Nov 2017 23:01:52 -0400 Subject: [PATCH 11/41] Fix IP --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index a683cee..81c4986 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,4 @@ -//Dependencies +//Dependencies var express = require('express'); var webapp = express(); var Promise = require('promise'); From 2f4775ef4bcab9e8766026e67e3c250dd80dcc4f Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 00:35:28 -0400 Subject: [PATCH 12/41] Expose process.env --- server.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.js b/server.js index 81c4986..8c7e34c 100644 --- a/server.js +++ b/server.js @@ -4,6 +4,8 @@ var webapp = express(); var Promise = require('promise'); var morgan = require('morgan'); +console.log('process.env = ' + process.env); + //OpenShift Settings var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; From d503535f7441825b905ffb1ad0ef3de45ad5c789 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 00:44:50 -0400 Subject: [PATCH 13/41] Stringify --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 8c7e34c..2f0a068 100644 --- a/server.js +++ b/server.js @@ -4,7 +4,7 @@ var webapp = express(); var Promise = require('promise'); var morgan = require('morgan'); -console.log('process.env = ' + process.env); +console.log('process.env = ' + JSON.stringify(process.env); //OpenShift Settings var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; From 999e7c3018c2727ba450eccadd5b5578588b8e45 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 00:50:33 -0400 Subject: [PATCH 14/41] Fix --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 2f0a068..76d6342 100644 --- a/server.js +++ b/server.js @@ -4,7 +4,7 @@ var webapp = express(); var Promise = require('promise'); var morgan = require('morgan'); -console.log('process.env = ' + JSON.stringify(process.env); +console.log('process.env = ' + JSON.stringify(process.env)); //OpenShift Settings var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; From a3145f6840b569363fa31f8375c2414900b1a495 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 10:24:28 -0400 Subject: [PATCH 15/41] Check Route --- server.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server.js b/server.js index 76d6342..793a885 100644 --- a/server.js +++ b/server.js @@ -4,8 +4,6 @@ var webapp = express(); var Promise = require('promise'); var morgan = require('morgan'); -console.log('process.env = ' + JSON.stringify(process.env)); - //OpenShift Settings var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; @@ -16,7 +14,7 @@ webapp.use(morgan('combined')); //External Routing webapp.get('/', function(req, res) { - console.log(__dirname); + console.log('route correct'); //res.sendFile(__dirname + '/public/views/pages/index.html'); res.send('works'); }); From 61367646bfdf7372dca58c3ff789cc6e0f1b0e4d Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 10:38:14 -0400 Subject: [PATCH 16/41] Test --- server.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index 793a885..f27cbe1 100644 --- a/server.js +++ b/server.js @@ -2,24 +2,22 @@ var express = require('express'); var webapp = express(); var Promise = require('promise'); -var morgan = require('morgan'); +//var morgan = require('morgan'); //OpenShift Settings var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //Reporting -webapp.use(morgan('combined')); +//webapp.use(morgan('combined')); //External Routing -webapp.get('/', function(req, res) { - console.log('route correct'); - //res.sendFile(__dirname + '/public/views/pages/index.html'); - res.send('works'); +app.get('/test', function (req, res) { + res.send('Hello World!'); }); -webapp.use('/public', express.static(__dirname + '/public')); +//webapp.use('/public', express.static(__dirname + '/public')); //Webapp Initialize webapp.listen(port, ip); From 8b31df22812a59ca7833f96f5a1f5fcb5bb2d1cb Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 10:52:03 -0400 Subject: [PATCH 17/41] Fix --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index f27cbe1..d8edd5c 100644 --- a/server.js +++ b/server.js @@ -13,7 +13,7 @@ var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //External Routing -app.get('/test', function (req, res) { +webapp.get('/test', function (req, res) { res.send('Hello World!'); }); From 1efa8dca8c495b4e2395305a279ffec0464b8c14 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 10:54:39 -0400 Subject: [PATCH 18/41] Fix --- server.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server.js b/server.js index d8edd5c..9fcbe19 100644 --- a/server.js +++ b/server.js @@ -12,7 +12,6 @@ var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //webapp.use(morgan('combined')); //External Routing - webapp.get('/test', function (req, res) { res.send('Hello World!'); }); From 4da901ece9b677844b7b688aadd8a8e38e3e04f4 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 11:04:37 -0400 Subject: [PATCH 19/41] Works --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index 9fcbe19..d37fb1f 100644 --- a/server.js +++ b/server.js @@ -13,6 +13,7 @@ var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //External Routing webapp.get('/test', function (req, res) { + console.log('works'); res.send('Hello World!'); }); From 387a6082cafb7f87599c2a303418c2210227e2f1 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 11:20:43 -0400 Subject: [PATCH 20/41] Open Routes --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index d37fb1f..81757fa 100644 --- a/server.js +++ b/server.js @@ -12,7 +12,7 @@ var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //webapp.use(morgan('combined')); //External Routing -webapp.get('/test', function (req, res) { +webapp.get('*', function (req, res) { console.log('works'); res.send('Hello World!'); }); From 43704140f64b1d1107c56f44b954f74dbb89d350 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 12:31:50 -0400 Subject: [PATCH 21/41] Update IP --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 81757fa..ee8e39a 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,7 @@ var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 'localhost'; +var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || '172.30.241.106'; var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; //Reporting From 46e4f6ab330a25f5302ecc219133e23086e3cff9 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 13:00:27 -0400 Subject: [PATCH 22/41] Fix IP --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index ee8e39a..f8f606a 100644 --- a/server.js +++ b/server.js @@ -5,8 +5,8 @@ var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || '172.30.241.106'; -var port = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || 8080; +var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0' +var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080, //Reporting //webapp.use(morgan('combined')); From dba6f2c355619703077d8cc2743ecc997de96919 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 13:19:37 -0400 Subject: [PATCH 23/41] Update Server.js --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index f8f606a..bfbba87 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ var Promise = require('promise'); //OpenShift Settings var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0' -var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080, +var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting //webapp.use(morgan('combined')); From ef199783f770fc7f15a7828c409dcbda625c494d Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 13:49:36 -0400 Subject: [PATCH 24/41] Update IP --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index bfbba87..422582a 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,7 @@ var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0' +var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '172.30.241.106' var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting From bb050a8b1dac96d85646ecd0df9eb146a467abdb Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 16:19:53 -0400 Subject: [PATCH 25/41] Change IP --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 422582a..bfbba87 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,7 @@ var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '172.30.241.106' +var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0' var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting From f872e7e0fb356086c5587489444e85a78a223e13 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 16:36:36 -0400 Subject: [PATCH 26/41] Next Try --- server.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index bfbba87..184a8f2 100644 --- a/server.js +++ b/server.js @@ -2,17 +2,17 @@ var express = require('express'); var webapp = express(); var Promise = require('promise'); -//var morgan = require('morgan'); +var morgan = require('morgan'); //OpenShift Settings var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0' var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting -//webapp.use(morgan('combined')); +webapp.use(morgan('combined')); //External Routing -webapp.get('*', function (req, res) { +webapp.get('/', function (req, res) { console.log('works'); res.send('Hello World!'); }); @@ -21,6 +21,7 @@ webapp.get('*', function (req, res) { //Webapp Initialize webapp.listen(port, ip); -console.log('live on ip: ' + ip + ':' + port); +//console.log('live on ip: ' + ip + ':' + port); +console.log('Server running on http://%s:%s', ip, port); module.exports = webapp; \ No newline at end of file From e4c23aa23217f7a9d99b3e2d8448de87a2270254 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 17:21:45 -0400 Subject: [PATCH 27/41] Test 2 --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 184a8f2..3ba347b 100644 --- a/server.js +++ b/server.js @@ -13,7 +13,7 @@ webapp.use(morgan('combined')); //External Routing webapp.get('/', function (req, res) { - console.log('works'); + console.log('works still?'); res.send('Hello World!'); }); From 29f248ed093e73840586fb829b07c03481a92218 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 17:31:02 -0400 Subject: [PATCH 28/41] All --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 3ba347b..2f9a018 100644 --- a/server.js +++ b/server.js @@ -12,7 +12,7 @@ var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; webapp.use(morgan('combined')); //External Routing -webapp.get('/', function (req, res) { +webapp.get('*', function (req, res) { console.log('works still?'); res.send('Hello World!'); }); From 5323a4795efbb4b68a515fe7dc6568bb4cab14cc Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 17:47:39 -0400 Subject: [PATCH 29/41] Update 3 --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 2f9a018..760b72a 100644 --- a/server.js +++ b/server.js @@ -12,9 +12,9 @@ var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; webapp.use(morgan('combined')); //External Routing -webapp.get('*', function (req, res) { +webapp.get('/', function (req, res) { console.log('works still?'); - res.send('Hello World!'); + res.send('Hello World Again!'); }); //webapp.use('/public', express.static(__dirname + '/public')); From 5c731b4b89da51a290e8f95ad39d2fa90b5c55a6 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 18:05:02 -0400 Subject: [PATCH 30/41] Fix to ; --- server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 760b72a..fbe54a5 100644 --- a/server.js +++ b/server.js @@ -2,18 +2,18 @@ var express = require('express'); var webapp = express(); var Promise = require('promise'); -var morgan = require('morgan'); +//var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0' +var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting -webapp.use(morgan('combined')); +//webapp.use(morgan('combined')); //External Routing webapp.get('/', function (req, res) { - console.log('works still?'); + console.log('works as expected'); res.send('Hello World Again!'); }); From 7904fe79808748813d48502036b33eb461ef7e51 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 18:29:29 -0400 Subject: [PATCH 31/41] Expose environmental variables --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index fbe54a5..f5b2d7c 100644 --- a/server.js +++ b/server.js @@ -23,5 +23,6 @@ webapp.get('/', function (req, res) { webapp.listen(port, ip); //console.log('live on ip: ' + ip + ':' + port); console.log('Server running on http://%s:%s', ip, port); +console.log(JSON.stringify(process.env)); module.exports = webapp; \ No newline at end of file From df7dbefdd4a6ece7b701483f19aed7c05f1c04bf Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 18:49:32 -0400 Subject: [PATCH 32/41] Try 3 --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index f5b2d7c..9bfcda4 100644 --- a/server.js +++ b/server.js @@ -5,8 +5,8 @@ var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; -var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; +var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || process.env.DIAPERSAPP_SERVICE_HOST || '0.0.0.0'; +var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || process.env.DIAPERSAPP_SERVICE_PORT_8080_TCP || 8080; //Reporting //webapp.use(morgan('combined')); From f4d2ccbd87192db4c65ae5240a0e876f179c5038 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 18:54:52 -0400 Subject: [PATCH 33/41] Back --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 9bfcda4..f5b2d7c 100644 --- a/server.js +++ b/server.js @@ -5,8 +5,8 @@ var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings -var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || process.env.DIAPERSAPP_SERVICE_HOST || '0.0.0.0'; -var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || process.env.DIAPERSAPP_SERVICE_PORT_8080_TCP || 8080; +var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; +var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting //webapp.use(morgan('combined')); From b9dd64fe361509b17d78e24fcaa0c5571620ac86 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 18:58:06 -0400 Subject: [PATCH 34/41] Remove env variables --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index f5b2d7c..ccf18d4 100644 --- a/server.js +++ b/server.js @@ -23,6 +23,6 @@ webapp.get('/', function (req, res) { webapp.listen(port, ip); //console.log('live on ip: ' + ip + ':' + port); console.log('Server running on http://%s:%s', ip, port); -console.log(JSON.stringify(process.env)); +//console.log(JSON.stringify(process.env)); -module.exports = webapp; \ No newline at end of file +//module.exports = webapp; \ No newline at end of file From 7177d1057bdbf13c8ca9a88d7413e6cbef541af2 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 19:02:35 -0400 Subject: [PATCH 35/41] Remove more --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index ccf18d4..7754a4c 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,7 @@ //Dependencies var express = require('express'); var webapp = express(); -var Promise = require('promise'); +//var Promise = require('promise'); //var morgan = require('morgan'); //OpenShift Settings From f837677aaabb3964d16d215448f03dcdf2eef0c8 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 19:08:16 -0400 Subject: [PATCH 36/41] Different send --- server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 7754a4c..e6b91d6 100644 --- a/server.js +++ b/server.js @@ -14,7 +14,8 @@ var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //External Routing webapp.get('/', function (req, res) { console.log('works as expected'); - res.send('Hello World Again!'); + res.send('

some html

'); + //res.send('Hello World Again!'); }); //webapp.use('/public', express.static(__dirname + '/public')); From 68d1ba759177fd3d66d7478963d397214c60bece Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 19:22:58 -0400 Subject: [PATCH 37/41] Webapp to app --- server.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index e6b91d6..bae1d40 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,6 @@ //Dependencies var express = require('express'); -var webapp = express(); +var app = express(); //var Promise = require('promise'); //var morgan = require('morgan'); @@ -9,19 +9,19 @@ var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //Reporting -//webapp.use(morgan('combined')); +//app.use(morgan('combined')); //External Routing -webapp.get('/', function (req, res) { +app.get('/', function (req, res) { console.log('works as expected'); res.send('

some html

'); //res.send('Hello World Again!'); }); -//webapp.use('/public', express.static(__dirname + '/public')); +//app.use('/public', express.static(__dirname + '/public')); -//Webapp Initialize -webapp.listen(port, ip); +//app Initialize +app.listen(port, ip); //console.log('live on ip: ' + ip + ':' + port); console.log('Server running on http://%s:%s', ip, port); //console.log(JSON.stringify(process.env)); From 4942b9758aa6d65dc1efe087cc43c0237493c92c Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 20:13:55 -0400 Subject: [PATCH 38/41] Update Route --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index bae1d40..7a2b036 100644 --- a/server.js +++ b/server.js @@ -14,11 +14,11 @@ var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //External Routing app.get('/', function (req, res) { console.log('works as expected'); - res.send('

some html

'); + res.sendFile(__dirname + '/public/views/pages/index.html'); //res.send('Hello World Again!'); }); -//app.use('/public', express.static(__dirname + '/public')); +app.use('/public', express.static(__dirname + '/public')); //app Initialize app.listen(port, ip); From 1c6b19178e9c085fd906ca94a1d43470911ea470 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 22:32:01 -0400 Subject: [PATCH 39/41] Update With Angular --- public/scripts/main_controller.js | 3 +++ public/scripts/module.js | 1 + public/views/pages/index.html | 7 ++++++- server.js | 6 +++--- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 public/scripts/main_controller.js create mode 100644 public/scripts/module.js diff --git a/public/scripts/main_controller.js b/public/scripts/main_controller.js new file mode 100644 index 0000000..105af7d --- /dev/null +++ b/public/scripts/main_controller.js @@ -0,0 +1,3 @@ + app.controller('main_controller', ['$scope','brandInfo','brandData','itemData','sizeData','$route','$window', 'title', + function($scope){} + ]); \ No newline at end of file diff --git a/public/scripts/module.js b/public/scripts/module.js new file mode 100644 index 0000000..8edf4fd --- /dev/null +++ b/public/scripts/module.js @@ -0,0 +1 @@ +var app = angular.module('diapers_app',[]); \ No newline at end of file diff --git a/public/views/pages/index.html b/public/views/pages/index.html index 9aa55e5..3d9ef1b 100644 --- a/public/views/pages/index.html +++ b/public/views/pages/index.html @@ -1,5 +1,10 @@ - + + + + + + diff --git a/server.js b/server.js index 7a2b036..5693536 100644 --- a/server.js +++ b/server.js @@ -12,14 +12,14 @@ var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; //app.use(morgan('combined')); //External Routing -app.get('/', function (req, res) { +app.use('/public', express.static(__dirname + '/public')); + +app.get('*', function (req, res) { console.log('works as expected'); res.sendFile(__dirname + '/public/views/pages/index.html'); //res.send('Hello World Again!'); }); -app.use('/public', express.static(__dirname + '/public')); - //app Initialize app.listen(port, ip); //console.log('live on ip: ' + ip + ':' + port); From 38ae7d2ed7495602f5fc1770134c79049548d528 Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sat, 4 Nov 2017 23:15:40 -0400 Subject: [PATCH 40/41] Update Arch --- API.js | 9 +++++++++ server.js | 20 ++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 API.js diff --git a/API.js b/API.js new file mode 100644 index 0000000..3e234a8 --- /dev/null +++ b/API.js @@ -0,0 +1,9 @@ +var express = require('express'); +var router_API = express.Router([options]); +var options; + +router_API.get('/route1', function(req, res) { + res.send('This worked'); +}); + +module.exports = router_API; \ No newline at end of file diff --git a/server.js b/server.js index 5693536..94cff74 100644 --- a/server.js +++ b/server.js @@ -1,29 +1,25 @@ //Dependencies var express = require('express'); var app = express(); -//var Promise = require('promise'); -//var morgan = require('morgan'); +var Promise = require('promise'); +var API = require(__dirname + '/API.js'); //OpenShift Settings var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; -//Reporting -//app.use(morgan('combined')); - -//External Routing +//External Routing Of Public Assets app.use('/public', express.static(__dirname + '/public')); +//External Routing Of API +app.use('/api', API); + +//External Other Routes app.get('*', function (req, res) { console.log('works as expected'); res.sendFile(__dirname + '/public/views/pages/index.html'); - //res.send('Hello World Again!'); }); //app Initialize app.listen(port, ip); -//console.log('live on ip: ' + ip + ':' + port); -console.log('Server running on http://%s:%s', ip, port); -//console.log(JSON.stringify(process.env)); - -//module.exports = webapp; \ No newline at end of file +console.log('Server running on http://%s:%s', ip, port); \ No newline at end of file From 826555024ec0e952f539cfc0386cbadf96d7562a Mon Sep 17 00:00:00 2001 From: briandavidjoyner Date: Sun, 5 Nov 2017 00:29:53 -0400 Subject: [PATCH 41/41] Speedup --- package-lock.json | 22 ++++++++++++++++++++++ package.json | 1 + server.js | 11 +++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4499ac..57704ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,6 +53,28 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" }, + "compressible": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.12.tgz", + "integrity": "sha1-xZpcmdt2dn6YdlAOJx72OzSTvWY=", + "requires": { + "mime-db": "1.30.0" + } + }, + "compression": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.1.tgz", + "integrity": "sha1-7/JgPvwuIs+G810uuTWJ+YdTc9s=", + "requires": { + "accepts": "1.3.4", + "bytes": "3.0.0", + "compressible": "2.0.12", + "debug": "2.6.9", + "on-headers": "1.0.1", + "safe-buffer": "5.1.1", + "vary": "1.1.2" + } + }, "content-disposition": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", diff --git a/package.json b/package.json index 9759cf0..5401b84 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "homepage": "https://github.com/briandavidjoyner/diapers_new#readme", "dependencies": { + "compression": "^1.7.1", "express": "^4.16.2", "morgan": "^1.9.0", "promise": "^8.0.1" diff --git a/server.js b/server.js index 94cff74..e00b820 100644 --- a/server.js +++ b/server.js @@ -2,11 +2,18 @@ var express = require('express'); var app = express(); var Promise = require('promise'); +var compression = require('compression'); + var API = require(__dirname + '/API.js'); //OpenShift Settings -var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; -var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; +//var ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; +//var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; +var port = 8080; +var ip = 'localhost' + +//Middleware +app.use(compression()); //External Routing Of Public Assets app.use('/public', express.static(__dirname + '/public'));