Skip to content

yuche/beidou

 
 

Repository files navigation

Isomorphic framework for server-rendered React apps

Features

  • ✔︎ React server side render
  • ✔︎ ES6/ES7 supported
  • ✔︎ Css modules supported
  • ✔︎ Lots of plugins

How to use

Setup

Install generator

// todo
npm install beidou-bin -g

Init

// todo
beidou init

Start

npm install
npm run start

After that, go to http://localhost:6001/

Structure

beidou-project
├── package.json
├── app.js (optional)
├── agent.js (optional)
├── app
|   ├── router.js (optional)
│   ├── controller (optional)
│   |   └── home.js
│   ├── service (optional)
│   |   └── user.js
│   ├── middleware (optional)
│   |   └── response_time.js
│   ├── schedule (optional)
│   |   └── my_task.js
│   ├── public (optional)
│   |   └── reset.css
│   ├── view (optional)
│   |   └── home.tpl
│   └── extend (optional)
│       ├── helper.js (optional)
│       ├── request.js (optional)
│       ├── response.js (optional)
│       ├── context.js (optional)
│       ├── application.js (optional)
│       └── agent.js (optional)
├── config
|   ├── plugin.js
|   ├── config.default.js
│   ├── config.prod.js
|   ├── config.test.js (optional)
|   ├── config.local.js (optional)
|   └── config.unittest.js (optional)
├── client
|   ├── index.jsx
|   └── page/index.jsx
└── test
    ├── middleware
    |   └── response_time.test.js
    └── controller
        └── home.test.js

Router

Auto router

Every page in /client folder will be routed automatically. For example, visit http://localhost:6001/page-a, /client/page-a.jsx will be rendered.

Client source Router Memo
client/index.jsx / Default router
client/index/index.jsx / Default router
client/a.jsx /a Auto router
client/a/index.jsx /a Auto router
client/a/b.jsx /a/b Auto router
client/a/b/index.jsx /a/b Auto router

Custom router

if we want to map /a to /client/b.jsx, follow the next steps step 1: create a new router

//  /app/router.js
module.exports = (app) => {
  app.get('/a', app.controller.a);
};

step 2: create a new controller, and render /client/b.jsx

//  /app/controller/a.js
module.exports = function* aController() {
  yield this.render('b');
};

About

Isomorphic framework for server-rendered React apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.1%
  • Other 1.9%