Skip to content

Commit 57bac3b

Browse files
committed
updates & renamed to react-end
1 parent 2e41ef4 commit 57bac3b

40 files changed

+1284
-353
lines changed

.babelrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2-
"presets": ["@babel/preset-env"],
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"esmodules": true
8+
}
9+
}
10+
]
11+
],
312
"plugins": ["@babel/plugin-transform-react-jsx"]
4-
}
13+
}

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"jsx-a11y/alt-text": 0,
1313
"import/prefer-default-export": 0,
1414
"import/no-extraneous-dependencies": 0
15-
}
15+
},
16+
"ignorePatterns": "/lib"
1617
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
.vscode
2+
.vscode
3+
.npmrc
4+
lib

README.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# ReactXpress
1+
# React-end
22

3-
**React renderer to build Node.js server**
3+
React http-server based on Express.js
44
<br />
55

66
![Planet Express](public/logo.svg)
77

8+
## Install
9+
10+
`npm i --save @react-end/express`
11+
812
### Why?
913

1014
It's the only crazy idea to use React to structure Backend on Node.js.
@@ -19,8 +23,7 @@ It works with express.js framework to run Node.js server. Custom renderer we hav
1923

2024
```js
2125
import React from 'react';
22-
import { resolve } from 'path';
23-
import { ReactXpress, App, Static, Router, Get, Post, Res } from '../lib';
26+
import { registerApp, App, Static, Router, Get, Post, Res } from '@react-end/express';
2427

2528
const HomePage = () => <h1>Home page</h1>;
2629
const AboutPage = () => <h1>About Page</h1>;
@@ -44,7 +47,14 @@ const ExpressApp = () => (
4447
</App>
4548
);
4649

47-
// Updates! 🤩
50+
registerApp(ExpressApp);
51+
```
52+
53+
<br />
54+
55+
## You can use this way too
56+
57+
```js
4858
const Updates = () => (
4959
<>
5060
<Get path="/redirect">
@@ -62,17 +72,8 @@ const Updates = () => (
6272
</Get>
6373
</>
6474
);
65-
66-
ReactXpress.render(<ExpressApp />);
6775
```
6876

69-
### How to use
70-
71-
1. Clone the repo
72-
2. `npm install`
73-
3. Run dev mode - `npm run dev`
74-
4. Do all changes in `./src` folder as it's not library yet.
75-
7677
### Components
7778

7879
`<App />` - App Instance (props: port)
@@ -88,13 +89,6 @@ ReactXpress.render(<ExpressApp />);
8889
<br />
8990
<br />
9091

91-
### What is planning?
92-
93-
I work on it and I'm trying to improve it, even it's not a good idea to use this kinda renderer for real-world app. But It would be awesome to have contributors to make its DX much better.
94-
9592
### Contact me
9693

9794
Email me if you have any idea and you would like to be contributor [[email protected]](mailto:[email protected])
98-
99-
Resources: <br/>
100-
https://dev.to/orkhanjafarovr/express-in-react-react-backend-whut-4lkg

src/app.js renamed to app/app.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import React from 'react';
22
import { resolve } from 'path';
3-
import { ReactXpress, App, Static, Router, Get, Post, Res } from '../lib';
3+
import cors from 'cors';
44

5+
import { registerApp, App, Static, Router, Get, Post, Res, Logger, Middleware } from '../src';
56
import { HomePage } from './pages/HomePage';
67
import { ComponentsPage } from './pages/ComponentsPage';
78

9+
const isProd = process.env.NODE_ENV === 'production';
10+
811
const ExpressApp = () => (
912
<App port={process.env.PORT || 8080}>
10-
<Static publicPath="/public" />
13+
<Static publicPath="/../../public" />
14+
<Logger mode="dev" disabled={isProd} />
15+
<Middleware handler={cors()} />
1116
<Router path="/">
12-
<Get render={HomePage} />
17+
<Get>
18+
<Res.Header name="Cache-Control" value="public, max-age=31557600" />
19+
<Res.Render component={HomePage} />
20+
</Get>
1321
<Get path="/components" render={ComponentsPage} />
1422
<Router path="/api">
1523
<Post
@@ -42,4 +50,4 @@ const Updates = () => (
4250
</>
4351
);
4452

45-
ReactXpress.render(<ExpressApp />);
53+
registerApp(ExpressApp);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useContext, useMemo } from 'react';
22
import styled from 'styled-components';
3-
import { ReqResContext } from '../../../lib';
3+
import { ReqResContext } from '../../../src';
44

55
const PAGES = [
66
{ path: '/', label: 'Home', title: '@orkhanjafarovr' },

app/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require('@babel/register')({
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
esmodules: true,
8+
},
9+
},
10+
],
11+
],
12+
plugins: ['@babel/plugin-transform-react-jsx'],
13+
});
14+
15+
require('./app.js');

0 commit comments

Comments
 (0)