Skip to content

Commit 9629f24

Browse files
committed
pre-heroku fix
1 parent 301807f commit 9629f24

38 files changed

+247
-180
lines changed

.babelrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
"next/babel",
4+
"stage-0"
5+
],
6+
"plugins": [
7+
["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ],
8+
["transform-define", "./env-config.js"]
9+
]
10+
}

README.md

-49
This file was deleted.

__tests__/index.test.js

100644100755
File mode changed.

__tests__/server.test.js

100644100755
File mode changed.

actions/actionTypes.js

100644100755
File mode changed.

actions/authActions.js

100644100755
File mode changed.

actions/jokeActions.js

100644100755
File mode changed.

actions/todoActions.js

100644100755
File mode changed.

api/todosApi.js

100644100755
File mode changed.

bbj.babelrc

-6
This file was deleted.

components/AddCount.js

100644100755
File mode changed.

components/Clock.js

100644100755
File mode changed.

components/Header.js

100644100755
File mode changed.

components/NotAuthorized.js

100644100755
File mode changed.

components/Page.js

100644100755
File mode changed.

components/todo/todoInput.js

100644100755
File mode changed.

components/todo/todoList.js

100644100755
File mode changed.

config.json

100644100755
File mode changed.

hocs/defaultPage.js

100644100755
File mode changed.

hocs/securePage.js

100644100755
File mode changed.

oldpackage.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "nextjs-boilerplate",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"server": "node server.js",
6+
"jest": "jest",
7+
"jest:watch": "npm run jest -- --watch --no-cache",
8+
"test": "mocha --reporter spec __tests__/**/*.test.js",
9+
"test:watch": "npm run test -- --watch",
10+
"dev": "next",
11+
"build": "next build",
12+
"watch": "nodemon server.js -w server.js",
13+
"start": "next start",
14+
"heroku-postbuild": "heroku-nextjs-build",
15+
"lint": "standard --verbose"
16+
},
17+
"standard": {
18+
"parser": "babel-eslint",
19+
"ignore": [
20+
"**/node_modules/**"
21+
]
22+
},
23+
"engines": {
24+
"node": "6.9.x"
25+
},
26+
"cacheDirectories": [
27+
"nextjs/node_modules"
28+
],
29+
"dependencies": {
30+
"@mars/heroku-nextjs-build": "^2.0.0",
31+
"auth0-lock": "^10.15.1",
32+
"babel-eslint": "^7.2.3",
33+
"babel-jest": "^19.0.0",
34+
"babel-plugin-styled-components": "^1.1.4",
35+
"babel-preset-stage-0": "^6.16.0",
36+
"body-parser": "^1.17.1",
37+
"isomorphic-unfetch": "^1.0.0",
38+
"js-cookie": "^2.1.4",
39+
"jwt-decode": "^2.2.0",
40+
"mongodb": "^2.2.26",
41+
"mongoose": "^4.9.6",
42+
"next": "2.2.0",
43+
"next-redux-wrapper": "^1.0.0",
44+
"react": "^15.4.2",
45+
"react-dom": "^15.4.2",
46+
"react-redux": "^5.0.1",
47+
"redux": "^3.6.0",
48+
"redux-form": "^6.6.3",
49+
"redux-thunk": "^2.1.0",
50+
"styled-components": "^2.0.0-17"
51+
},
52+
"devDependencies": {
53+
"redux-devtools-extension": "^2.13.2",
54+
"colors": "^1.1.2",
55+
"enzyme": "^2.8.2",
56+
"expect": "^1.20.2",
57+
"jest": "^19.0.2",
58+
"mocha": "^3.3.0",
59+
"npm-run-all": "^4.0.2",
60+
"standard": "^10.0.2",
61+
"supertest": "^3.0.0"
62+
},
63+
"author": "Spencer Bigum",
64+
"license": "ISC"
65+
}

oldserver.js

-101
This file was deleted.

package.json

100644100755
+11-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"jest:watch": "npm run jest -- --watch --no-cache",
88
"test": "mocha --reporter spec __tests__/**/*.test.js",
99
"test:watch": "npm run test -- --watch",
10-
"dev": "next",
10+
"dev": "next -r dotenv/config",
1111
"build": "next build",
1212
"watch": "nodemon server.js -w server.js",
1313
"start": "next start",
@@ -29,34 +29,37 @@
2929
"dependencies": {
3030
"@mars/heroku-nextjs-build": "^2.0.0",
3131
"auth0-lock": "^10.15.1",
32-
"babel-eslint": "^7.2.3",
33-
"babel-jest": "^19.0.0",
34-
"babel-plugin-styled-components": "^1.1.4",
35-
"babel-preset-stage-0": "^6.16.0",
3632
"body-parser": "^1.17.1",
3733
"isomorphic-unfetch": "^1.0.0",
3834
"js-cookie": "^2.1.4",
3935
"jwt-decode": "^2.2.0",
4036
"mongodb": "^2.2.26",
4137
"mongoose": "^4.9.6",
42-
"next": "latest",
38+
"next": "2.2.0",
4339
"next-redux-wrapper": "^1.0.0",
4440
"react": "^15.4.2",
4541
"react-dom": "^15.4.2",
4642
"react-redux": "^5.0.1",
4743
"redux": "^3.6.0",
4844
"redux-form": "^6.6.3",
4945
"redux-thunk": "^2.1.0",
50-
"styled-components": "^2.0.0-17"
46+
"request": "^2.81.0",
47+
"styled-components": "^2.0.0-17",
48+
"uuid": "^3.0.1"
5149
},
5250
"devDependencies": {
53-
"redux-devtools-extension": "^2.13.2",
51+
"babel-eslint": "^7.2.3",
52+
"babel-jest": "^19.0.0",
53+
"babel-plugin-styled-components": "^1.1.4",
54+
"babel-plugin-transform-define": "^1.2.0",
55+
"babel-preset-stage-0": "^6.16.0",
5456
"colors": "^1.1.2",
5557
"enzyme": "^2.8.2",
5658
"expect": "^1.20.2",
5759
"jest": "^19.0.2",
5860
"mocha": "^3.3.0",
5961
"npm-run-all": "^4.0.2",
62+
"redux-devtools-extension": "^2.13.2",
6063
"standard": "^10.0.2",
6164
"supertest": "^3.0.0"
6265
},

pages/_document.js

100644100755
File mode changed.

pages/auth/sign-in.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react'
2+
import { initStore } from '../../store'
3+
import withRedux from 'next-redux-wrapper'
4+
import { bindActionCreators } from 'redux'
5+
import defaultPage from '../../hocs/defaultPage'
6+
import { show } from '../../utils/lock'
7+
import Router from 'next/router'
8+
const config = require('../../config.json')
9+
const Auth0Lock = require('auth0-lock').default
10+
import jwtDecode from 'jwt-decode'
11+
import Cookie from 'js-cookie'
12+
import { authenticateUser } from '../../actions/authActions'
13+
import { getUserFromLocalStorage } from '../../utils/auth'
14+
// import Auth0 from '../../utils/Auth0'
15+
const CONTAINER_ID = 'put-lock-here'
16+
//.auth0-lock.auth0-lock .auth0-lock-widget - overflow-y
17+
class SignIn extends React.Component {
18+
19+
constructor (props) {
20+
super(props)
21+
}
22+
23+
componentDidMount () {
24+
show(CONTAINER_ID)
25+
26+
}
27+
render () {
28+
return (
29+
<div>
30+
<div id={CONTAINER_ID} />
31+
</div>
32+
)
33+
}
34+
}
35+
36+
export default withRedux(initStore)(defaultPage(SignIn))

pages/auth/sign-off.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react'
2+
import { initStore } from '../../store'
3+
import { logUserOut } from '../../actions/authActions'
4+
import withRedux from 'next-redux-wrapper'
5+
import { unsetToken } from '../../utils/auth'
6+
import { bindActionCreators } from 'redux'
7+
8+
class SignOff extends React.Component {
9+
componentDidMount () {
10+
this.props.logUserOut()
11+
}
12+
13+
render () {
14+
return null
15+
}
16+
}
17+
18+
const mapDispatchToProps = (dispatch) => {
19+
return {
20+
logUserOut: bindActionCreators(logUserOut, dispatch)
21+
}
22+
}
23+
24+
export default withRedux(initStore, null, mapDispatchToProps)(SignOff)

pages/auth/signed-in.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react'
2+
import Router from 'next/router'
3+
import { bindActionCreators } from 'redux'
4+
import withRedux from 'next-redux-wrapper'
5+
import { initStore } from '../../store'
6+
import { authenticateUser } from '../../actions/authActions'
7+
import { setToken, checkSecret, extractInfoFromHash, getUserFromLocalStorage } from '../../utils/auth'
8+
9+
class SignedIn extends React.Component {
10+
static getInitialProps ({ store, isServer, push }) {
11+
return { isServer }
12+
}
13+
14+
// Deprecated
15+
// static propTypes = {
16+
// url: PropTypes.object.isRequired
17+
// }
18+
19+
componentDidMount () {
20+
console.log('signed in page hit')
21+
const {token, secret} = extractInfoFromHash()
22+
if (!checkSecret(secret) || !token) {
23+
console.error('Something happened with the Sign In request')
24+
}
25+
setToken(token)
26+
const user = getUserFromLocalStorage()
27+
console.log(user);
28+
this.props.authenticateUser(user)
29+
Router.push('/celeb-jokes')
30+
}
31+
32+
render () {
33+
return null
34+
}
35+
}
36+
37+
const mapDispatchToProps = (dispatch) => {
38+
return {
39+
authenticateUser: bindActionCreators(authenticateUser, dispatch)
40+
}
41+
}
42+
43+
export default withRedux(initStore, null, mapDispatchToProps)(SignedIn)

0 commit comments

Comments
 (0)