Advertisement
Guest User

Untitled

a guest
Sep 6th, 2017
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. import express from 'express';
  2. import open from 'open';
  3. import compression from "compression";
  4.  
  5. const app = express();
  6.  
  7. app.get('/', function (req, res) {
  8. res.send('Hello World!');
  9. });
  10.  
  11. app.get('/users', function (req, res) {
  12. // Hard coding for simplicity. Pretend this hits a real database
  13. res.json([
  14. {"id": 1, "firstName": "Bob", "lastName": "Smith", "email": "bob@gmail.com"},
  15. {"id": 2, "firstName": "Tammy", "lastName": "Norton", "email": "tnorton@yahoo.com"},
  16. {"id": 3, "firstName": "Tina", "lastName": "Lee", "email": "lee.tina@hotmail.com"}
  17. ]);
  18. });
  19.  
  20.  
  21. // Functions to start the server
  22. let startDevServer = function(port) {
  23. runServer(port);
  24. };
  25.  
  26. let startProdServer = function(port) {
  27. app.use(express.static('dist'));
  28. app.use(compression());
  29.  
  30. runServer(port);
  31. };
  32.  
  33. let runServer = function (port) {
  34. app.listen(port, function (err) {
  35. if (err) {
  36. console.log(err);
  37. } else {
  38. open(`http://localhost:${port}`);
  39. }
  40. });
  41. };
  42.  
  43. module.exports = {
  44. startDevServer: startDevServer,
  45. startProdServer: startProdServer
  46. };
  47.  
  48. import {startDevServer} from "./server";
  49. startDevServer(3001);
  50.  
  51. import {startProdServer} from "./server";
  52. startProdServer(3001);
  53.  
  54. /Users/harit/org/code/apollo-server/src/index.js (0/1)
  55. ! 9:5 Unexpected console statement no-console
  56.  
  57. /Users/harit/org/code/apollo-server/buildScripts/distServer.js (1/0)
  58. ✖ 1:9 startProdServer not found in './server' import/named
  59.  
  60. /Users/harit/org/code/apollo-server/buildScripts/server.js (0/1)
  61. ! 36:7 Unexpected console statement no-console
  62.  
  63. /Users/harit/org/code/apollo-server/buildScripts/srcServer.js (1/0)
  64. ✖ 1:9 startDevServer not found in './server' import/named
  65.  
  66. ✖ 2 errors ! 2 warnings (12:48:46 PM)
  67. npm ERR! code ELIFECYCLE
  68. npm ERR! errno 1
  69. npm ERR! apollo-server@1.0.0 lint: `esw webpack.config.* src buildScripts --color`
  70. npm ERR! Exit status 1
  71. npm ERR!
  72. npm ERR! Failed at the apollo-server@1.0.0 lint script.
  73. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  74.  
  75. npm ERR! A complete log of this run can be found in:
  76. npm ERR! /Users/harit/.npm/_logs/2017-09-07T00_48_46_543Z-debug.log
  77. ERROR: "lint" exited with 1.
  78. npm ERR! code ELIFECYCLE
  79. npm ERR! errno 1
  80. npm ERR! apollo-server@1.0.0 prebuild: `npm-run-all clean-dist lint`
  81. npm ERR! Exit status 1
  82. npm ERR!
  83. npm ERR! Failed at the apollo-server@1.0.0 prebuild script.
  84. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  85.  
  86. npm ERR! A complete log of this run can be found in:
  87.  
  88. {
  89. "root": true,
  90. "extends": [
  91. "eslint:recommended",
  92. "plugin:import/errors",
  93. "plugin:import/warnings"
  94. ],
  95. "parserOptions": {
  96. "ecmaVersion": 7,
  97. "sourceType": "module"
  98. },
  99. "env": {
  100. "browser": true,
  101. "node": true,
  102. "mocha": true,
  103. "es6": true
  104. },
  105. "rules": {
  106. "no-console": 1
  107. }
  108. }
  109.  
  110. {
  111. "name": "apollo-server",
  112. "version": "1.0.0",
  113. "description": "Serving Apollo's request",
  114. "main": "src/index.js",
  115. "scripts": {
  116. "prestart": "babel-node buildScripts/startMessage.js",
  117. "start": "npm-run-all --parallel open:src lint:watch",
  118. "open:src": "babel-node buildScripts/srcServer.js",
  119. "lint": "esw webpack.config.* src buildScripts --color",
  120. "lint:watch": "npm run lint -- --watch",
  121. "clean-dist": "rimraf ./dist && mkdir dist",
  122. "prebuild": "npm-run-all clean-dist lint",
  123. "build": "babel-node buildScripts/build.js",
  124. "postbuild": "babel-node buildScripts/distServer.js"
  125. },
  126. "author": "Harit Himanshu",
  127. "dependencies": {
  128. "whatwg-fetch": "^2.0.3"
  129. },
  130. "devDependencies": {
  131. "babel-cli": "6.16.0",
  132. "babel-core": "6.17.0",
  133. "babel-loader": "6.2.5",
  134. "babel-preset-latest": "6.16.0",
  135. "babel-register": "6.16.3",
  136. "chai": "3.5.0",
  137. "chalk": "1.1.3",
  138. "cheerio": "0.22.0",
  139. "compression": "1.6.2",
  140. "cross-env": "3.1.3",
  141. "css-loader": "0.25.0",
  142. "eslint": "3.8.1",
  143. "eslint-plugin-import": "2.0.1",
  144. "eslint-watch": "2.1.14",
  145. "express": "4.14.0",
  146. "extract-text-webpack-plugin": "1.0.1",
  147. "html-webpack-plugin": "2.22.0",
  148. "jsdom": "9.8.0",
  149. "json-loader": "^0.5.7",
  150. "json-schema-faker": "0.3.6",
  151. "json-server": "0.8.22",
  152. "localtunnel": "1.8.1",
  153. "mocha": "3.1.2",
  154. "nock": "8.1.0",
  155. "npm-run-all": "3.1.1",
  156. "nsp": "2.6.2",
  157. "numeral": "1.5.3",
  158. "open": "0.0.5",
  159. "rimraf": "2.5.4",
  160. "style-loader": "0.13.1",
  161. "surge": "0.18.0",
  162. "webpack": "1.13.2",
  163. "webpack-dev-middleware": "1.8.4",
  164. "webpack-hot-middleware": "2.13.0",
  165. "webpack-md5-hash": "0.0.5"
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement