Skip to content

Commit 5fcddda

Browse files
committed
commit before publish package
1 parent 57bac3b commit 5fcddda

File tree

17 files changed

+265
-1443
lines changed

17 files changed

+265
-1443
lines changed

README.md

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,107 @@
1-
# React-end
1+
# Reactend / Express
22

3-
React http-server based on Express.js
3+
React-like http-server on Nodejs
44
<br />
55

6-
![Planet Express](public/logo.svg)
6+
![Planet Express](logo.svg)
77

88
## Install
99

10-
`npm i --save @react-end/express`
10+
`npm i --save @reactend/express react react-dom`</br>
11+
or</br>
12+
`yarn add @reactend/express react react-dom`</br>
1113

12-
### Why?
14+
</br>
15+
16+
## Why?
1317

1418
It's the only crazy idea to use React to structure Backend on Node.js.
15-
<br />
19+
<br /><br />
1620

17-
### How it works?
21+
## How it works?
1822

1923
It works with express.js framework to run Node.js server. Custom renderer we have is building express structure app from React Components.
20-
<br />
24+
<br /><br />
2125

2226
### Code Example
2327

2428
```js
2529
import React from 'react';
26-
import { registerApp, App, Static, Router, Get, Post, Res } from '@react-end/express';
30+
import { resolve } from 'path';
2731

28-
const HomePage = () => <h1>Home page</h1>;
29-
const AboutPage = () => <h1>About Page</h1>;
32+
import { registerApp, App, Static, Router, Get, Post, Res, Logger } from '@reactend/express';
3033

3134
const ExpressApp = () => (
3235
<App port={process.env.PORT || 8080}>
3336
<Static publicPath="/public" />
37+
<Logger mode="dev" />
3438
<Router path="/">
35-
<Get render={HomePage} />
36-
<Get path="/about" render={AboutPage} />
39+
<Get>
40+
<Res.Header name="Cache-Control" value="public, max-age=31557600" />
41+
<Res.Render component={HomePage} />
42+
</Get>
43+
<Get path="/components" render={ComponentsPage} />
3744
<Router path="/api">
3845
<Post
3946
path="/status"
4047
json={{ msg: 'It is okay, bro' }}
4148
handler={(req) => console.log(req.originalUrl)}
4249
/>
4350
</Router>
44-
<Updates />
4551
<Get path="*" text="Not Found" status={404} />
4652
</Router>
4753
</App>
4854
);
49-
50-
registerApp(ExpressApp);
5155
```
5256

5357
<br />
5458

5559
## You can use this way too
5660

5761
```js
58-
const Updates = () => (
59-
<>
60-
<Get path="/redirect">
61-
<Res.Redirect statusCode={301} path="https://ru.reactjs.org" />
62-
</Get>
63-
<Post path="/json">
64-
<Res.Status statusCode={401} />
65-
<Res.Content json={{ msg: 'No Access' }} contentType="application/json" />
66-
</Post>
67-
<Get path="/send-file">
68-
<Res.SendFile path={resolve('public/code-example.png')} onError={console.log} />
69-
</Get>
70-
<Get path="/render">
71-
<Res.Render component={() => <h1>Shut Up And Take My Money!</h1>} />
72-
</Get>
73-
</>
74-
);
62+
import cors from 'cors';
63+
<Middleware handler={cors()} />;
64+
```
65+
66+
```js
67+
<Get path="/redirect">
68+
<Res.Redirect statusCode={301} path="https://ru.reactjs.org" />
69+
</Get>
70+
71+
<Post path="/json">
72+
<Res.Status statusCode={401} />
73+
<Res.Content json={{ msg: 'No Access' }} contentType="application/json" />
74+
</Post>
75+
76+
<Get path="/send-file">
77+
<Res.SendFile path={resolve('public/code-example.png')} onError={console.log} />
78+
</Get>
79+
80+
<Get path="/render">
81+
<Res.Render component={() => <h1>Shut Up And Take My Money!</h1>} />
82+
</Get>
7583
```
7684

77-
### Components
78-
79-
`<App />` - App Instance (props: port)
80-
`<Static />` - Static route (props: publicPath, path, options)
81-
`<Router />` - Router-Provider (props: path)
82-
`<Get />, <Post /> and ...` - Route component (props: path, content, handler, status)
83-
`<Res />` - Response components
84-
`<Res.Render />` - Render (props: component)
85-
`<Res.Content />` - Response send (props: json, text, contentType)
86-
`<Res.Status />` - Response Status (props: statusCode)
87-
`<Res.SendFile />` - Response Send File (props: path, options, onError)
88-
`<Res.Redirect />` - Redirect (props: path, statusCode)
85+
<br/><br/>
86+
87+
## Components
88+
89+
_This minor description for now (Docs is on the way)_<br/><br/>
90+
`<App />` - App Instance (props: port) <br />
91+
`<Static />` - Static route (props: publicPath, path, options) <br />
92+
`<Router />` - Router-Provider (props: path) <br />
93+
`<Get />, <Post /> and ...` - Route component (props: path, content, <br />handler, status) <br />
94+
`<Middleware />` - Middleware (props: handler) <br />
95+
`<Logger />` - morgan logger (props: mode, disabled) <br />
96+
`<Res />` - Response components <br />
97+
`<Res.Render />` - Render (props: component) <br />
98+
`<Res.Content />` - Response send (props: json, text, contentType) <br />
99+
`<Res.Status />` - Response Status (props: statusCode) <br />
100+
`<Res.SendFile />` - Response Send File (props: path, options, <br />onError) <br />
101+
`<Res.Redirect />` - Redirect (props: path, statusCode) <br />
89102
<br />
90103
<br />
91104

92-
### Contact me
105+
## Contact me
93106

94107
Email me if you have any idea and you would like to be contributor [[email protected]](mailto:[email protected])

app/app.js

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

app/components/layout/BaseLayout.js

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

app/components/layout/GlobalStyle.js

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

app/components/layout/TopNav.js

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

app/index.js

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

app/pages/AboutPage.js

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

0 commit comments

Comments
 (0)