Skip to content

Commit

Permalink
pm2 and rimraf
Browse files Browse the repository at this point in the history
  • Loading branch information
surajrao committed Apr 8, 2017
1 parent 3798291 commit 6aa0df2
Show file tree
Hide file tree
Showing 11 changed files with 924 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/*.log
node_modules/
/coverage/
/lib/
71 changes: 41 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
{
"name": "your-project",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "babel-node src",
"test": "eslint src && flow && jest --coverage",
"precommit": "yarn test",
"prepush": "yarn test"
},
"browserslist": [
"> 1%"
],
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-eslint": "^7.2.1",
"babel-jest": "^19.0.0",
"babel-preset-env": "^1.2.2",
"babel-preset-flow": "^6.23.0",
"eslint": "^3.18.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-compat": "^1.0.2",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
"eslint-plugin-react": "^6.9.0",
"flow-bin": "^0.42.0",
"husky": "^0.13.3",
"jest": "^19.0.2"
}
"name": "your-project",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "yarn dev:start",
"dev:start": "nodemon --ignore lib --exec babel-node src/server",
"prod:build": "rimraf lib && babel src -d lib --ignore .test.js",
"prod:start": "NODE_ENV=production pm2 start lib/server && pm2 logs",
"prod:stop": "pm2 delete server",
"test": "eslint src && flow && jest --coverage",
"precommit": "yarn test",
"prepush": "yarn test && yarn prod:build"
},
"browserslist": [
"> 1%"
],
"dependencies": {
"common-tags": "^1.4.0",
"compression": "^1.6.2",
"express": "^4.15.2"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-eslint": "^7.2.1",
"babel-jest": "^19.0.0",
"babel-preset-env": "^1.2.2",
"babel-preset-flow": "^6.23.0",
"eslint": "^3.18.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-compat": "^1.0.2",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
"eslint-plugin-react": "^6.9.0",
"flow-bin": "^0.42.0",
"husky": "^0.13.3",
"jest": "^19.0.2",
"nodemon": "^1.11.0",
"pm2": "^2.4.4",
"rimraf": "^2.6.1"
}
}
9 changes: 9 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
width: 960px;
margin: auto;
font-family: sans-serif;
}

h1 {
color: limegreen;
}
16 changes: 0 additions & 16 deletions src/dog.js

This file was deleted.

6 changes: 0 additions & 6 deletions src/dog.test.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/index.js

This file was deleted.

23 changes: 23 additions & 0 deletions src/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow

import compression from 'compression'
import express from 'express'

import { APP_NAME, STATIC_PATH, WEB_PORT } from '../shared/config'
import { isProd } from '../shared/util'
import renderApp from './render-app'

const app = express()

app.use(compression())
app.use(STATIC_PATH, express.static('dist'))
app.use(STATIC_PATH, express.static('public'))

app.get('/', (req, res) => {
res.send(renderApp(APP_NAME))
})

app.listen(WEB_PORT, () => {
// eslint-disable-next-line no-console
console.log(`Server running on port ${WEB_PORT} ${isProd ? '(production)' : '(development)'}.`)
})
19 changes: 19 additions & 0 deletions src/server/render-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @flow

import { html } from 'common-tags'
import { STATIC_PATH } from '../shared/config'

const renderApp = (title: string) =>
html`<!doctype html>
<html>
<head>
<title>${title}</title>
<link rel="stylesheet" href="${STATIC_PATH}/css/style.css">
</head>
<body>
<h1>${title}</h1>
</body>
</html>
`

export default renderApp
4 changes: 4 additions & 0 deletions src/shared/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow
export const WEB_PORT = process.env.PORT || 8000
export const STATIC_PATH = '/static'
export const APP_NAME = 'Hello App'
4 changes: 4 additions & 0 deletions src/shared/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

// eslint-disable-next-line import/prefer-default-export
export const isProd = process.env.NODE_ENV === 'production'
Loading

0 comments on commit 6aa0df2

Please sign in to comment.