-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor #14: Moved localstorage to loginPage
- Loading branch information
Showing
11 changed files
with
15,647 additions
and
17,390 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require("ignore-styles"); | ||
|
||
require("@babel/register")({ | ||
ignore: [/(node_modules)/], | ||
presets: ["@babel/preset-env", "react-app"] | ||
}); | ||
|
||
require("./index"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import express from "express"; | ||
|
||
// we'll talk about this in a minute: | ||
import serverRenderer from "./middleware/renderer"; | ||
|
||
const PORT = 3000; | ||
const path = require("path"); | ||
|
||
// initialize the application and create the routes | ||
const app = express(); | ||
const router = express.Router(); | ||
|
||
// root (/) should always serve our server rendered page | ||
router.use("^/$", serverRenderer); | ||
|
||
// other static resources should just be served as they are | ||
router.use( | ||
express.static(path.resolve(__dirname, "..", "build"), { maxAge: "30d" }) | ||
); | ||
|
||
// tell the app to use the above rules | ||
app.use(router); | ||
|
||
// start the app | ||
app.listen(PORT, error => { | ||
if (error) { | ||
return console.log("something bad happened", error); | ||
} | ||
|
||
console.log("listening on " + PORT + "..."); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
import ReactDOMServer from "react-dom/server"; | ||
|
||
// import our main App component | ||
import App from "../../src/components/App"; | ||
|
||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
export default (req, res, next) => { | ||
// point to the html file created by CRA's build tool | ||
const filePath = path.resolve(__dirname, "..", "..", "build", "index.html"); | ||
|
||
fs.readFile(filePath, "utf8", (err, htmlData) => { | ||
if (err) { | ||
console.error("err", err); | ||
return res.status(404).end(); | ||
} | ||
|
||
// render the app as a string | ||
const html = ReactDOMServer.renderToString(<App />); | ||
|
||
// inject the rendered app into our html and send it | ||
return res.send( | ||
htmlData.replace('<div id="root"></div>', `<div id="root">${html}</div>`) | ||
); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters