Skip to content

Commit b2f573b

Browse files
committed
Delete client side codes
1 parent 8107ee0 commit b2f573b

32 files changed

+7
-729
lines changed

.babelrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
[
44
"env", {
55
"targets": {
6-
"browsers": ["last 2 versions", "> 1%"],
76
"node": "6.2",
87
},
98
"useBuiltIns": true,
109
}
1110
],
12-
"react",
1311
]
1412
}

.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = {
1515
}
1616
},
1717
"plugins": [
18-
"react"
1918
],
2019
"rules": {
2120
"comma-dangle": ["error", "always-multiline"],
@@ -25,7 +24,5 @@ module.exports = {
2524
"semi": ["warn", "always"],
2625
"no-unused-vars": ["warn"],
2726
"no-console": 0,
28-
"react/jsx-uses-react": "warn",
29-
"react/jsx-uses-vars": "warn",
3027
},
3128
};

config/aws.config.devo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"region": "us-west-2"
44
},
55
"dynamodb": {
6-
"userTableName": "hello_user",
6+
"userTableName": "user",
77
"userIndexName": "fbid-index"
88
}
99
}

config/aws.config.prod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"region": "us-west-2"
44
},
55
"dynamodb": {
6-
"sessionTableName": "hello_session",
7-
"userTableName": "hello_user",
6+
"sessionTableName": "session",
7+
"userTableName": "user",
88
"userIndexName": "fbid-index"
99
}
1010
}

modules/connectWithRouter.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/store.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
{
2-
"name": "helloworld-lambda-web",
2+
"name": "bettit-service",
33
"version": "1.0.0",
4-
"description": "Helloworld on lambda for a web",
4+
"description": "An API server for bettit",
55
"main": "index.js",
66
"scripts": {
77
"test": "mocha-webpack --webpack-config webpack.test.config.js test",
8-
"start": "webpack-dev-server --config webpack.client.config.js --inline --content-base ./devserver/ --history-api-fallback",
98
"start:standalone": "npm run build:standalone && node ./standalone/standalone.bundle.js",
10-
"build:client": "webpack --env production -p --config webpack.client.config.js",
11-
"build:server": "webpack -p --config webpack.server.config.js",
12-
"build": "npm run build:client && npm run build:server",
13-
"build:standalone:client": "webpack --config webpack.standalone.client.config.js",
14-
"build:standalone:server": "webpack --config webpack.standalone.server.config.js",
15-
"build:standalone": "npm run build:standalone:client && npm run build:standalone:server",
9+
"build": "webpack -p --config webpack.server.config.js",
10+
"build:standalone": "webpack --config webpack.standalone.config.js",
1611
"dist": "cp package.json ./dist/ && cd ./dist && npm install --production",
1712
"lint": "eslint . --cache",
1813
"deploy": "node-lambda deploy -p --description `git rev-parse HEAD` --prebuiltDirectory dist",
@@ -30,37 +25,21 @@
3025
"express-request-id": "^1.4.0",
3126
"express-session": "^1.15.5",
3227
"prop-types": "^15.5.9",
33-
"react": "^15.4.2",
34-
"react-bootstrap": "^0.30.7",
35-
"react-dom": "^15.4.2",
36-
"react-redux": "^5.0.4",
37-
"react-router-bootstrap": "^0.24.2",
38-
"react-router-dom": "^4.1.2",
39-
"redux": "^3.6.0",
40-
"redux-logger": "^3.0.1",
41-
"redux-thunk": "^2.2.0",
4228
"shortid": "^2.2.8"
4329
},
4430
"devDependencies": {
4531
"babel-cli": "^6.22.2",
4632
"babel-loader": "^7.0.0",
4733
"babel-preset-env": "^1.6.0",
48-
"babel-preset-react": "^6.22.0",
4934
"chai": "^4.1.2",
5035
"core-js": "^2.5.0",
51-
"css-loader": "^0.28.0",
5236
"enzyme": "^2.7.1",
5337
"eslint": "^4.6.0",
5438
"eslint-loader": "^1.6.1",
55-
"eslint-plugin-react": "^7.3.0",
5639
"mocha": "^3.2.0",
5740
"mocha-webpack": "^0.7.0",
5841
"node-lambda": "^0.11.3",
59-
"react-addons-test-utils": "^15.5.1",
60-
"react-test-renderer": "^15.5.4",
61-
"style-loader": "^0.18.2",
6242
"webpack": "^3.5.5",
63-
"webpack-dev-server": "^2.3.0",
6443
"webpack-merge": "^4.1.0"
6544
}
6645
}

server/app.js

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@ var path = require('path');
55

66
import bodyParser from 'body-parser';
77
import expressRequestId from 'express-request-id';
8-
import React from 'react';
9-
import { renderToString } from 'react-dom/server';
10-
import { StaticRouter } from 'react-router-dom';
11-
import { Provider } from 'react-redux';
12-
13-
import createReduxStore from '../modules/store';
148

159
import auth from './apis/auth';
1610
import logger from './libs/logger';
1711
import session from './libs/session';
1812
import userMiddleware from './libs/userMiddleware';
1913

20-
import App from '../src/containers/App';
21-
2214
const file = 'server/app.js';
2315

2416
const app = express();
@@ -29,45 +21,6 @@ app.use(session.createSessionMiddleware());
2921
app.use(logger);
3022
app.use(express.static(path.join(__dirname, './public')));
3123

32-
const handleRequest = (req, res) => {
33-
req.log.info({ file, function: 'handleRequest', url: req.url, session: req.session, user: req.user });
34-
35-
const context = {};
36-
37-
// counter in session for demo
38-
if (!req.session.counter) req.session.counter = 0;
39-
req.session.counter++;
40-
41-
const initialState = session.createInitialReduxState(req.log, req.session, req.user);
42-
const store = createReduxStore(initialState);
43-
44-
const appHtml = renderToString(
45-
<Provider store={store}>
46-
<StaticRouter
47-
location={req.url}
48-
context={context}>
49-
<App/>
50-
</StaticRouter>
51-
</Provider>
52-
);
53-
54-
if (context.url) {
55-
res.redirect(302, context.url);
56-
} else {
57-
res.send(renderPage(appHtml, store.getState()));
58-
}
59-
};
60-
61-
app.get('*', (req, res) => {
62-
req.log.info({ file, function:'get *', url: req.url, session: req.session });
63-
64-
// Call userMiddleware here only rather than register it by app.use().
65-
// It is to reduce uncessary user db call.
66-
// Once a function is registered by app.use, it is called even for asset request.
67-
userMiddleware(req)
68-
.then(() => handleRequest(req, res));
69-
});
70-
7124
app.post('/signin', (req, res) => {
7225
req.log.info({ file, function:'post', req: { url: req.url } });
7326

@@ -85,23 +38,5 @@ app.post('/signout', (req, res) => {
8538
res.send(auth.signout(req, res));
8639
});
8740

88-
function renderPage(appHtml, initialState) {
89-
return `
90-
<!doctype html public="storage">
91-
<html>
92-
<meta charset=utf-8/>
93-
<title>helloworld-lambda-web</title>
94-
<!-- Latest compiled and minified CSS -->
95-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
96-
<!-- Optional theme -->
97-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">
98-
<div id=app>${appHtml}</div>
99-
<script>
100-
window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};
101-
</script>
102-
<script src="/bundle.js"></script>
103-
`;
104-
}
105-
10641
// Export your express server so you can import it in the lambda function.
10742
module.exports = app;

server/libs/session.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ import session from 'express-session';
44

55
const file = 'server/libs/session.js';
66

7-
const createInitialReduxState = (logger, session, user) => {
8-
const state = {
9-
sessionCounter: {
10-
counter: session.counter,
11-
},
12-
};
13-
14-
if (session.fbToken && user) {
15-
state.user = {
16-
uid: user.id,
17-
name: user.name,
18-
pictureUrl: user.pictureUrl,
19-
fbToken: session.fbToken,
20-
};
21-
}
22-
23-
logger.info({ file, function: 'createInitialReduxState', state });
24-
25-
return state;
26-
};
27-
287
const createSessionMiddleware = () => {
298
const sessionOption = {
309
resave: false,
@@ -66,7 +45,6 @@ const update = (req, data) => {
6645
};
6746

6847
module.exports = {
69-
createInitialReduxState,
7048
createSessionMiddleware,
7149
update,
7250
};

src/actions/facebook.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/actions/index.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/components/About.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)