Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.

Commit 1714fee

Browse files
committed
init commit
0 parents  commit 1714fee

32 files changed

+566
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"airbnb"
4+
]
5+
}

.build/index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Development</title>
5+
</head>
6+
<body>
7+
<div id="root">
8+
</div>
9+
<script src="/dist/bundle.js"></script>
10+
</body>
11+
</html>

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org/
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = space
9+
indent_size = 2
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "airbnb"
3+
}

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*.csv
2+
*.dat
3+
*.iml
4+
*.log
5+
*.out
6+
*.pid
7+
*.seed
8+
*.sublime-*
9+
*.swo
10+
*.swp
11+
*.tgz
12+
*.xml
13+
*.save
14+
.DS_Store
15+
.idea
16+
.project
17+
.strong-pm
18+
coverage
19+
node_modules
20+
npm-debug.log
21+
.build/dist

.jshintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/client/
2+
/node_modules/

.jshintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"node": true,
3+
"esnext": true,
4+
"bitwise": true,
5+
"camelcase": true,
6+
"eqeqeq": true,
7+
"eqnull": true,
8+
"immed": true,
9+
"indent": 2,
10+
"latedef": "nofunc",
11+
"newcap": true,
12+
"nonew": true,
13+
"noarg": true,
14+
"quotmark": "single",
15+
"regexp": true,
16+
"undef": true,
17+
"unused": false,
18+
"trailing": true,
19+
"sub": true,
20+
"maxlen": 80
21+
}

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Tony Ngan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# loopback-redux-react-boilerplate
2+
3+
A boilerplate for a Redux-React application using LoopBack
4+
5+
### Get Started
6+
- **Clone this repository or use npm**
7+
```bash
8+
$ git clone https://github.com/tngan/loopback-redux-react-boilerplate.git
9+
```
10+
```bash
11+
$ npm install loopback-redux-react-boilerplate
12+
```
13+
14+
- **Install dependencies specified in package.json**
15+
```bash
16+
$ npm install
17+
```
18+
19+
- **Start the server (default port is set to 3000)**
20+
```bash
21+
$ npm start
22+
```
23+
24+
### Scripts
25+
- **npm run deploy**: Bundles the application into `.build/dist`.
26+
27+
- **npm run start_prod**: Starts production server, make sure you have already deployed the application.
28+
29+
- **npm run clean**: Removes the bundled files.
30+
31+
### Built-in example
32+
A simple 'Hello World' Redux-React application is included in this boilerplate. You can find those files under `/client`.
33+
34+
Hot reloading is only applied in development mode. In production mode, the code base is pre-compiled and placed under `.build/dist`.
35+
36+
### License
37+
38+
[MIT](LICENSE)
39+
40+
### Copyright
41+
42+
Copyright (C) 2015 Tony Ngan, released under the MIT License.

client/actions/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Define an action type, it's used for reducer switching
2+
export const GET_STARTED = 'GET_STARTED';
3+
4+
// Define the corresponding action creator, must return an object
5+
export function getStarted() {
6+
return {
7+
type: GET_STARTED,
8+
};
9+
}

client/components/DumbComponent.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React, { PropTypes } from 'react';
2+
import '../public/stylesheets/boilerplate.css';
3+
4+
export default function DumbComponent(props) {
5+
const { welcomeText } = props;
6+
return (
7+
<p className="text">{welcomeText || ''}</p>
8+
);
9+
}
10+
DumbComponent.propTypes = {
11+
welcomeText: PropTypes.string.isRequired,
12+
};

client/constants/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* Put all your constants here, all in BLOCK_LETTER
2+
*
3+
* Export the constant directly as follow:
4+
*
5+
* export const MY_CONSTANT = 'val';
6+
* export const MY_CONSTANT_1 = 'val1';
7+
*
8+
* In any files, import those constants when you need
9+
*
10+
* import { MY_CONSTANT, MY_CONSTANT_1 } from './constants';
11+
*
12+
*/
13+
export const WELCOME_TEXT = 'Thanks for using loopback-redux-react-boilerplate';

client/containers/SmartComponent.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React, { Component, PropTypes } from 'react';
2+
import { connect } from 'react-redux';
3+
import { getStarted } from '../actions';
4+
import DumbComponent from '../components/DumbComponent';
5+
6+
class SmartComponent extends Component {
7+
componentWillMount() {
8+
this.props.dispatch(getStarted());
9+
}
10+
render() {
11+
return (
12+
<div>
13+
<DumbComponent welcomeText={this.props.welcomeText} />
14+
</div>
15+
);
16+
}
17+
}
18+
19+
SmartComponent.propTypes = {
20+
welcomeText: PropTypes.string.isRequired,
21+
dispatch: PropTypes.func.isRequired,
22+
};
23+
24+
export default connect(state => state)(SmartComponent);

client/index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Development</title>
5+
</head>
6+
<body>
7+
<div id="root">
8+
</div>
9+
<script src="/dist/bundle.js"></script>
10+
</body>
11+
</html>

client/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import { Provider } from 'react-redux';
4+
import SmartComponent from './containers/SmartComponent';
5+
import configureStore from './store/configureStore';
6+
7+
const store = configureStore();
8+
9+
ReactDOM.render(
10+
<Provider store={store}>
11+
<SmartComponent />
12+
</Provider>,
13+
document.getElementById('root')
14+
);

client/public/javascripts/boilerplate.js

Whitespace-only changes.
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* This stylesheet can be imported to any dumb components under /components
3+
* Remarks: It's suggested those Smart components under /containers not to apply their own style
4+
*
5+
* import '../public/stylesheets/boilerplate.css'
6+
*
7+
* It's required css-loader in webpack.config.js, and it's already included in package.json.
8+
* You can also use your own loader by modifying the setting in webpack.config.js
9+
*
10+
*/
11+
p.text {
12+
color: #DCAA45;
13+
}

client/reducers/index.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { GET_STARTED } from '../actions';
2+
import { WELCOME_TEXT } from '../constants';
3+
4+
function rootReducer(state = {}, action) {
5+
switch (action.type) {
6+
case GET_STARTED:
7+
return { welcomeText: WELCOME_TEXT };
8+
default:
9+
return state;
10+
}
11+
}
12+
13+
export default rootReducer;
14+
15+
/*
16+
* Redux suggests use multiple reducers instead of creating multiple stores,
17+
* if more than one reducer is needed, use combineReducer from 'redux' module.
18+
*
19+
* import { composeReducers } from 'redux'
20+
*
21+
* export default combineReducers({
22+
* rootReducer
23+
* subReducer
24+
* });
25+
*
26+
*/

client/store/configureStore.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { createStore } from 'redux';
2+
import homeApp from '../reducers';
3+
4+
export default function configureStore(initialState) {
5+
const store = createStore(homeApp);
6+
if (module.hot) {
7+
// Enable Webpack hot module replacement for reducers
8+
module.hot.accept('../reducers', () => {
9+
const nextRootReducer = require('../reducers');
10+
store.replaceReducer(nextRootReducer);
11+
});
12+
}
13+
return store;
14+
}
15+

package.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "SoundOff",
3+
"version": "0.0.1",
4+
"description": "A Stand-Up / Stand-Down Reporting Utility.",
5+
"main": "server/server.js",
6+
"scripts": {
7+
"serve": "node .",
8+
"lint": "eslint ./",
9+
"lint:client": "eslint ./client",
10+
"lint:server": "eslint ./server",
11+
"serve:dist": "NODE_ENV=production node .",
12+
"dist": "NODE_ENV=production webpack -p --config webpack.config.production.js --progress",
13+
"clean": "rm -rf .build/dist"
14+
},
15+
"dependencies": {
16+
"compression": "^1.6.1",
17+
"cors": "^2.7.1",
18+
"history": "^2.1.1",
19+
"humps": "^1.1.0",
20+
"isomorphic-fetch": "^2.2.1",
21+
"json-loader": "^0.5.4",
22+
"loopback": "^2.28.0",
23+
"loopback-boot": "^2.18.1",
24+
"loopback-component-explorer": "^2.5.0",
25+
"loopback-datasource-juggler": "^2.46.0",
26+
"react": "^15.0.2",
27+
"react-dom": "^15.0.2",
28+
"react-redux": "^4.4.5",
29+
"redux": "^3.5.2",
30+
"serve-favicon": "^2.3.0"
31+
},
32+
"devDependencies": {
33+
"babel-core": "^6.8.0",
34+
"babel-loader": "^6.2.4",
35+
"babel-plugin-react-transform": "^2.0.2",
36+
"babel-polyfill": "^6.8.0",
37+
"babel-preset-airbnb": "^2.0.0",
38+
"concurrently": "^2.0.0",
39+
"css-loader": "^0.23.1",
40+
"eslint": "^2.9.0",
41+
"eslint-config-airbnb": "^8.0.0",
42+
"eslint-plugin-import": "^1.7.0",
43+
"eslint-plugin-jsx-a11y": "^1.2.0",
44+
"eslint-plugin-react": "^5.0.1",
45+
"react-transform-hmr": "^1.0.4",
46+
"redux-devtools": "^3.2.0",
47+
"style-loader": "^0.13.1",
48+
"webpack": "^1.13.0",
49+
"webpack-dev-middleware": "^1.6.1",
50+
"webpack-hot-middleware": "^2.10.0"
51+
}
52+
}

server/boot/authentication.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function enableAuthentication(server) {
2+
// enable authentication
3+
server.enableAuth();
4+
};

server/component-config.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"loopback-component-explorer": {
3+
"mountPath": "/explorer"
4+
}
5+
}

server/config.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"restApiRoot": "/api",
3+
"host": "0.0.0.0",
4+
"port": 3000,
5+
"remoting": {
6+
"context": {
7+
"enableHttpContext": false
8+
},
9+
"rest": {
10+
"normalizeHttpPath": false,
11+
"xml": false
12+
},
13+
"json": {
14+
"strict": false,
15+
"limit": "100kb"
16+
},
17+
"urlencoded": {
18+
"extended": true,
19+
"limit": "100kb"
20+
},
21+
"cors": false,
22+
"errorHandler": {
23+
"disableStackTrace": false
24+
}
25+
},
26+
"legacyExplorer": false
27+
}

0 commit comments

Comments
 (0)