Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Home.js #1

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b023b7f
initial grammar check
ebtehaj Mar 18, 2020
bb3034b
initial grammar check
ebtehaj Mar 18, 2020
393e097
Update initialize.js
ebtehaj Mar 18, 2020
ee33e8b
Update render.js
ebtehaj Mar 18, 2020
d7f80f9
Merge pull request #5 from ebtehaj/development
ebrahimiaval Mar 18, 2020
4119f90
Update server.js
ebtehaj Mar 18, 2020
ceec630
Merge pull request #6 from ebtehaj/development
ebrahimiaval Mar 18, 2020
7fbc3b7
Merge branch 'development'
ebrahimiaval Mar 18, 2020
b1e73a7
Update README.md
ebtehaj Mar 18, 2020
2e3983b
Merge pull request #7 from ebtehaj/development
ebrahimiaval Mar 18, 2020
90cb2cc
Merge branch 'development'
ebrahimiaval Mar 18, 2020
b984633
Update Home.js
ebtehaj Mar 23, 2020
cefcfce
Update firstSetup.js
ebtehaj Mar 23, 2020
52877a3
Update setLocalUserAsGuest.js
ebtehaj Mar 23, 2020
3524789
Update signingIn.js
ebtehaj Mar 23, 2020
d223129
Update signingOut.js
ebtehaj Mar 23, 2020
f5c4c48
Update ForgetPasswordForm.js
ebtehaj Mar 23, 2020
30b5bee
Update SignInForm.js
ebtehaj Mar 23, 2020
b39c1fb
Merge pull request #8 from ebtehaj/ebtehaj-patch-1
ebrahimiaval Mar 23, 2020
88a2ce7
Update DefaultErrors.js
ebtehaj Mar 26, 2020
716a346
Update clientFetcher.js
ebtehaj Mar 26, 2020
16a654c
Update serverFetcher.js
ebtehaj Mar 26, 2020
183dcf5
Update debugLog.js
ebtehaj Mar 26, 2020
70d91d8
Update skeleton.js
ebtehaj Mar 26, 2020
8094127
Update skeletonClientProvider.js
ebtehaj Mar 26, 2020
f0a98c8
Update skeletonServerProvider.js
ebtehaj Mar 26, 2020
619197a
Update client.js
ebtehaj Mar 26, 2020
750afac
Update errorLogger.js
ebtehaj Mar 26, 2020
f6e9214
Update fetching.js
ebtehaj Mar 26, 2020
4897606
Update isErrorData.js
ebtehaj Mar 26, 2020
d88484f
Update isValidUser.js
ebtehaj Mar 26, 2020
7671e23
Update jumpScrollToTop.js
ebtehaj Mar 26, 2020
2c0fe1d
Update responseValidation.js
ebtehaj Mar 26, 2020
6ac8ef3
Update api.js
ebtehaj Mar 26, 2020
606354c
Update axiosConfig.js
ebtehaj Mar 26, 2020
08cf67b
Update localStorage.js
ebtehaj Mar 26, 2020
87a483b
Update route.js
ebtehaj Mar 26, 2020
995edcf
Update store.js
ebtehaj Mar 26, 2020
d9dffb5
Update README.md
ebtehaj Mar 26, 2020
c69eaf7
Update development.js
ebtehaj Mar 26, 2020
ab38717
Update production.js
ebtehaj Mar 26, 2020
5f9ca43
Update envLoader.js
ebtehaj Mar 26, 2020
99d5ba3
Update fileVersion.js
ebtehaj Mar 26, 2020
2f74b88
Merge branch 'master' into ebtehaj-patch-1
ebrahimiaval Mar 26, 2020
77a1471
Update rateLimit.js
ebtehaj Mar 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@
</div>

# RSSR Boilerplate
"We are no better than no one, We are not in competition with anyone, We want to be the best version of ourselves."
"We are not better than anyone, We are not in competition with anyone, We want to be the best version of ourselves."

welcome to RSSR. Being here is a sign of your professionalism.
Welcome to RSSR. Being here is a sign of your professionalism.

RSSR is a SSR boilerplate for React js and contian:
RSSR is a SSR boilerplate for React js and contains:
- SSR (Server Side Rendering)
- User Authentication Structure
- SEO optimization utilities
- SCSS Style Namespace
- and more …

## Documentation
see [Documentation](https://github.com/rssr-org/RSSR-Documentation) in github.
See [Documentation](https://github.com/rssr-org/RSSR-Documentation) in github.

you can see also videos of RSSR team in [aparat](https://www.aparat.com/user/video/user_list/userid/722589/usercat/413997) and [youtube](https://www.youtube.com/channel/UCNkuorlYEWReSMglMp25yCw), .
You can also watch videos of RSSR team at [aparat](https://www.aparat.com/user/video/user_list/userid/722589/usercat/413997) and [youtube](https://www.youtube.com/channel/UCNkuorlYEWReSMglMp25yCw), .

## Usage Notice
core of RSSR is stable but need some changes to be released publicly. you can fork, review and star it but until the final release DONT USE it for your enterprise projects!
The core of RSSR is stable but needs some changes before it can be released publicly. You can fork, review and star it but DO NOT USE it for your enterprise projects until the final release!

To be informed, track here or [Telegram channel](https://t.me/rssr_org).
For more information, follow us at : [Telegram channel](https://t.me/rssr_org).


## Know more

#### what is SSR?
Server Side Rendering is a popular technique for rendering a normally
client-side only single page app (SPA) on the server and then sending
client-side single page app (SPA) on the server and then sending
a fully rendered page to the client. The client’s JavaScript bundle
can then take over and the SPA can operate as normal. One major
benefit of using SSR is in having an app that can be crawled
Expand All @@ -55,4 +55,4 @@ With every new project that you start, you will be repeating yourself.
This is where boilerplates come in. A boilerplate is a template that
you can clone and reuse for every project.



2 changes: 1 addition & 1 deletion provider/server/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ app.use(express.static(PUBLIC_NAME))
// create webpack compiler
const compiler = webpack(config)

// make bundled project source files accessable from memory
// make bundled project source files accessible from memory
app.use(webpackDevMiddleware(compiler, {
publicPath: DIST_ROUTE,
serverSideRender: true
Expand Down
2 changes: 1 addition & 1 deletion provider/server/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const app = express()
// cookie
app.use(cookieParser())

// make bundled final project source files accessable
// make bundled final project source files accessible
app.use(DIST_ROUTE, express.static(DIST_PATH))

// load static files
Expand Down
6 changes: 3 additions & 3 deletions provider/setup/envLoader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// load environment varibale of .env file
// load environment variable of .env file
const dotenv = require('dotenv')
dotenv.config()

// load environment varibale of .env.[NODE_ENV] files
// load environment variable of .env.[NODE_ENV] files
const fs = require('fs')
const envPath = fs.readFileSync('.env.' + process.env.NODE_ENV);
const envConfig = dotenv.parse(envPath)
for (const k in envConfig) {
process.env[k] = envConfig[k]
}
}
2 changes: 1 addition & 1 deletion provider/setup/fileVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ switch (process.env.FILE_VERSION_TYPE) {
global.FILE_VERSION = '?v=' + versionHash(); // random 24 char string
break;
case 'disable':
global.FILE_VERSION = ''; // with out version
global.FILE_VERSION = ''; // without version
break;
default:
console.error('env.FILE_VERSION is not valid!', global.FILE_VERSION)
Expand Down
8 changes: 4 additions & 4 deletions provider/setup/rateLimit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// limit request numbet
// limit request number
const rateLimit = require("express-rate-limit");

/**
Expand All @@ -14,9 +14,9 @@ module.exports = function (app) {

const limiter = rateLimit({
windowMs: 60 * 1000, // 1 minutes
max: 20 // 20 request in each 1 minutes
max: 20 // 20 requests in each 1 minute
});

// apply to all requests with out load static file (becuse defined in above)
// apply to all requests without loading static file (because defined in above)
app.use(limiter);
}
}
2 changes: 1 addition & 1 deletion src/App/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Home(props) {
<div className="jumbotron mt-3 pb-3" id="abc">
<h5>RSSR Boilderplate</h5>
<p className="lead">
We are no better than no one,
We are no better than anyone else,
We are not in competition with anyone,
We want to be the best version of ourselves.
<br/>
Expand Down
10 changes: 5 additions & 5 deletions src/Component/Auth/SignIn/ForgetPasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ForgetPasswordForm(props) {
// method: 'POST',
data: {
"email": email,
// server most be add token number to end of url and redirect to it
// server must add token number to end of url and redirect to it
"callback": window.location.origin + route.resetPassword('')
}
})
Expand All @@ -31,11 +31,11 @@ function ForgetPasswordForm(props) {
<div>
Recovery email sent.
<br/>
Please check your email inbox or smap and click on link.
Please check your email inbox or spam and click on link.
<br/>
{email}
<br/>
Apply again if you do not receive it.
Apply again if you did not receive it.
</div>
);
toast.success(message, {autoClose: false});
Expand Down Expand Up @@ -69,7 +69,7 @@ function ForgetPasswordForm(props) {
value={email}
onChange={(e) => setEmail(e.target.value)}
required/>
<div className="invalid-feedback">E-mail is not valid. please enter your account email like: [email protected]</div>
<div className="invalid-feedback">E-mail is not valid. please enter your email account like: [email protected]</div>
</div>
<button className="btn btn-block btn-primary" disabled={isLoading || !localUser.updated} type="submit">
Recovery
Expand All @@ -78,4 +78,4 @@ function ForgetPasswordForm(props) {
)
}

export default connect(s => ({localUser: s.localUser}))(ForgetPasswordForm);
export default connect(s => ({localUser: s.localUser}))(ForgetPasswordForm);
4 changes: 2 additions & 2 deletions src/Component/Auth/SignIn/SignInForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function SignInForm(props) {
data: {email: userName, password: password}
})
.then((response) => {
// set token to localStorage if remember me checked and get user details
// set token to localStorage if remember me is checked and get user details
signingIn(response.data.token, rememberMe)
.then(function () {
toast.success('logged-in successfully!', {autoClose: 1200});
Expand Down Expand Up @@ -102,4 +102,4 @@ function SignInForm(props) {
);
}

export default connect(s => ({localUser: s.localUser}))(SignInForm);
export default connect(s => ({localUser: s.localUser}))(SignInForm);
12 changes: 6 additions & 6 deletions src/Component/Auth/__action/firstSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export const firstSetup = function () {
const token = Cookies.get('localUserToken');
if (token) {
// Real user
// when token exist mean in the past one user logged-in
// but does not mean user is a valid user, so token need authentication.
// when token exists it means that one user has logged-in before
// but it does not mean that the user is valid, so token needs authentication.
//
// when server say token is valid then it's a Real and Valid user, and
// when server say is NOT valid then runing signingOut() method and
// set user as Guest user and remove token from localstorage.
// when the server says the token is valid, then it's a real and valid user, and
// when the server says it is NOT valid then signingOut() method will run and
// we set user as a Guest user and remove token from localstorage.
authentication(token)
.then(() => {
/**
Expand All @@ -27,4 +27,4 @@ export const firstSetup = function () {
// Guest user
setLocalUserAsGuest()
}
}
}
6 changes: 3 additions & 3 deletions src/Component/Auth/__action/setLocalUserAsGuest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {setStore} from "trim-redux";


/**
* set "updated: true" to stop loading of need Authentication Components and
* set "token: null" becuse user is invalid (is guest)
* NOTICE: localUser of guest user does not "detail" property.
* set "updated: true" when the user authentication is done by server and the user information is updated and final
* set "token: null" when user is invalid (is guest)
* NOTICE: The localUser object of guest user does not have "detail" property.
*/
export const setLocalUserAsGuest = function () {
setStore({localUser: {updated: true, token: null}});
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Auth/__action/signingIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import Cookies from "js-cookie";
/**
* signing in user
* push token to localStorage (change null to token string) just when user checked "remember me" checkbox.
* NOTICE: if user do not checked "remember me" stay logged-in Until the page refreshes.
* NOTICE: if user did not check the "remember me" checkbox, stay logged-in until the page refreshes.
*
* @param token <string>: user authentication key. like "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...."
* @param rememberMe <boolean>: state of "remember me" checkbox checked
*/
export const signingIn = (token, rememberMe) => {
// set local User Token when rememberMe
// set local user token when rememberMe is checked
if (rememberMe)
Cookies.set('localUserToken', token)

Expand Down
4 changes: 2 additions & 2 deletions src/Component/Auth/__action/signingOut.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Cookies from "js-cookie";

/**
* signing out user
* clear localUser data in redux and set Gust User value to it.
* clear localUser data in redux and set Guest User value to it.
*/
export const signingOut = () => {
// clear user detail from redux
Expand All @@ -16,4 +16,4 @@ export const signingOut = () => {
/**
* @@@ Clear_USER_Cart
*/
}
}
6 changes: 3 additions & 3 deletions src/Partial/fetcher/DefaultErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Error404 from "../../App/Error404/Error404";
import {browserHistory} from "../../setup/browserHistory";


// use for catch axios error in fetching proccess with fetcher
// NOTICE: all non0-200 response status catch by this view unless you write catch in fetch function for them
// use for catching axios error during the fetching process with fetcher
// NOTICE: all non0-200 response status will be catched by this view unless you write catch in fetch function for them
const DefaultErrors = (props) => {
const {status, code, data} = props.data;

Expand Down Expand Up @@ -33,4 +33,4 @@ const DefaultErrors = (props) => {
);
};

export default DefaultErrors;
export default DefaultErrors;
14 changes: 7 additions & 7 deletions src/Partial/fetcher/clientFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import axios from "axios";
/**
* provider Fetcher HOC of client side
*
* Fetcher is a HOC and wrap 'TheComponent'
* to can handel fetching data actions of 'TheComponent'.
* Fetcher in client contian all fetch actions.
* Fetcher is a HOC which wraps 'TheComponent'
* in order to handle fetching data actions of 'TheComponent'.
* Fetcher in client contians all fetch actions.
*
* @param TheComponent : React Compoentn
* @param TheComponent : React Component
* @returns {Fecher} : Fetcher HOC of client side
*/
export const clientFetcher = function (TheComponent) {
Expand Down Expand Up @@ -110,7 +110,7 @@ export const clientFetcher = function (TheComponent) {
const defaultValue = defaultState[stateName];
setStore(stateName, defaultValue);

// when try to fetch but last equal fetch was not complited
// when try to fetch but the last equal fetch was not completed
if (this.cancelRequest) {
this.cancelRequest();
delete this.cancelRequest;
Expand All @@ -129,8 +129,8 @@ export const clientFetcher = function (TheComponent) {



// update when route update. for example click on like '/post/2' in mounted component with path '/post/1'
// needFetch() need for switch between 2 route path with equal component
// update when route updates. For example click on '/post/2' in mounted component with path '/post/1'
// needFetch() needs switching between 2 route paths with equal component
componentDidUpdate(prevProps) {
if (this.props.location.key === prevProps.location.key && !this.needFetch())
return;
Expand Down
8 changes: 3 additions & 5 deletions src/Partial/fetcher/serverFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import DefaultErrors from "./DefaultErrors";
/**
* provider Fetcher HOC of server side
*
* Fetcher HOC in server just an interface
* to pass duct to 'TheComponent' when type of fetch is props base
* an in redux base is an empty component
* (need empty component to avoid React 'compoenet not found' error)
* Fetcher HOC in server is just an interface which passes the fetched data in
* redux state to 'TheComponent'
*
* @param TheComponent : React Compoentn
* @param TheComponent : React Component
* @returns {Fecher} : Fetcher HOC of server side
*/
export const serverFetcher = function (TheComponent, stateName) {
Expand Down
14 changes: 7 additions & 7 deletions src/Partial/skeleton/debugLog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// active switch for debuging logs
// active switch for debugging logs
const debug = JSON.parse(process.env.RSSR_SKELETON_DEBUG);

export const debugLog = function (msgKey) {
Expand All @@ -8,16 +8,16 @@ export const debugLog = function (msgKey) {
let msg;
switch (msgKey) {
case "INVALID_CACHE_VALUE":
msg = 'cache property is not number or more than ziro miliseconds. set skeleton cache parameter.';
msg = 'cache property is not number or more than zero milliseconds. set skeleton cache parameter.';
break;
case "WENT_WELL":
msg = 'everything went well, data successfully fetched in Server and received on Client.';
msg = 'everything went well, data was successfully fetched in Server and was received by Client.';
break;
case "FETCHED_IN_CLIENT":
msg = 'fetch errored in server but data successfully fetched in Client.';
msg = 'fetch errored in server but data was successfully fetched in Client.';
break;
case "CLIENT_ERRORED":
msg = 'fetch errored in both side.the default data is now used.';
msg = 'fetch had error in both sides.The default data is now used.';
break;
case "READ_FROM_CACHE":
msg = 'read data from cache.';
Expand All @@ -32,10 +32,10 @@ export const debugLog = function (msgKey) {
msg = 'fetching data from API.';
break;
case "SUCCESSFULLY_FETCH":
msg = 'data fetched successfully in server and pushed to skeleton state.';
msg = 'data was fetched successfully in server and pushed to skeleton state.';
break;
case "SERVER_ERRORED":
msg = 'fetch errored in server.';
msg = 'fetch had error in server.';
break;
default:
msg = 'message key is invalid!'
Expand Down
2 changes: 1 addition & 1 deletion src/Partial/skeleton/skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const skeleton = function (TheComponent, fetchFn, cache) {
}

const Skeleton = function (props) {
// refetch skeleton on client when server fetch skeleton error
// refetch skeleton in client when server fetch skeleton encounters an error
if (typeof window !== 'undefined')
skeletonClientProvider(fetchFn)

Expand Down
2 changes: 1 addition & 1 deletion src/Partial/skeleton/skeletonClientProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {debugLog} from "./debugLog";


export const skeletonClientProvider = function (fetchFn) {
// when server fetch data successfully
// when server fetches data successfully
const skeleton = getStore('skeleton');
if (skeleton && !skeleton.isErrorData) {
debugLog('WENT_WELL')
Expand Down
4 changes: 2 additions & 2 deletions src/Partial/skeleton/skeletonServerProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let fetchLock = false;
* call skeleton fetch and handle errors
*/
export const skeletonServerProvider = async function (DUCT) {
// skeleton is disable
// skeleton is disabled
if (!App.skeleton)
return true;

Expand Down Expand Up @@ -66,7 +66,7 @@ const skeletonFetch = async function (DUCT) {


/**
* 1) response vaidation
* 1) response validation
* 2) push data to updatedState (redux)
*/
function skeletonGetDataFromApi(DUCT) {
Expand Down
Loading