From 0d0f53a0ab3fd3ae7201057fb606e40b2a52ff91 Mon Sep 17 00:00:00 2001 From: Steren Date: Thu, 31 Jan 2019 10:35:37 -0800 Subject: [PATCH] Node.js sample: Use index.js instead of app.js. (#849) * Use index.js instead of app.js. index.js is the more idiomatic for Node.js developers. Indeed, it is the default value that npm start uses if no start script is provided. * Update package.json * Update README.md * Update package.json --- serving/samples/helloworld-nodejs/README.md | 12 +++++------- .../samples/helloworld-nodejs/{app.js => index.js} | 0 serving/samples/helloworld-nodejs/package.json | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) rename serving/samples/helloworld-nodejs/{app.js => index.js} (100%) diff --git a/serving/samples/helloworld-nodejs/README.md b/serving/samples/helloworld-nodejs/README.md index 5bbd1d6a6..398e804c1 100644 --- a/serving/samples/helloworld-nodejs/README.md +++ b/serving/samples/helloworld-nodejs/README.md @@ -19,9 +19,7 @@ While you can clone all of the code from this directory, hello world apps are generally more useful if you build them step-by-step. The following instructions recreate the source files from this folder. -1. Create a new directory and initalize `npm`. You can accept the defaults, but - change the entry point to `app.js` to be consistent with the sample code - here. +1. Create a new directory and initalize `npm`. ```shell npm init @@ -29,7 +27,7 @@ recreate the source files from this folder. package name: (helloworld-nodejs) version: (1.0.0) description: - entry point: (index.js) app.js + entry point: (index.js) test command: git repository: keywords: @@ -43,7 +41,7 @@ recreate the source files from this folder. npm install express --save ``` -1. Create a new file named `app.js` and paste the following code: +1. Create a new file named `index.js` and paste the following code: ```js const express = require("express"); @@ -69,9 +67,9 @@ recreate the source files from this folder. "name": "knative-serving-helloworld", "version": "1.0.0", "description": "", - "main": "app.js", + "main": "index.js", "scripts": { - "start": "node app.js" + "start": "node index.js" }, "author": "", "license": "Apache-2.0", diff --git a/serving/samples/helloworld-nodejs/app.js b/serving/samples/helloworld-nodejs/index.js similarity index 100% rename from serving/samples/helloworld-nodejs/app.js rename to serving/samples/helloworld-nodejs/index.js diff --git a/serving/samples/helloworld-nodejs/package.json b/serving/samples/helloworld-nodejs/package.json index 5caedc277..ce62bbc3a 100644 --- a/serving/samples/helloworld-nodejs/package.json +++ b/serving/samples/helloworld-nodejs/package.json @@ -2,9 +2,9 @@ "name": "knative-serving-helloworld", "version": "1.0.0", "description": "Simple hello world sample in Node", - "main": "app.js", + "main": "index.js", "scripts": { - "start": "node app.js" + "start": "node index.js" }, "author": "", "license": "Apache-2.0",