项目作者: jsnomad

项目描述 :
Adonisjs + Create React App Boilerplate
高级语言: JavaScript
项目地址: git://github.com/jsnomad/adonisjs-create-react-app.git
创建时间: 2019-01-07T17:05:23Z
项目社区:https://github.com/jsnomad/adonisjs-create-react-app

开源协议:MIT License

下载


adonisjs-create-react-app



Boilerplate/Starter Project for building APIs using Adonisjs, with a React frontend using Create React App.

Setup

Install AdonisJs CLI globally :

  1. npm i -g @adonisjs/cli

Then create the project :

  1. adonis new <name> --blueprint=jsnomad/adonisjs-create-react-app

Alternatively you can clone the project and install dependencies manually :

  1. git clone https://github.com/jsnomad/adonisjs-create-react-app.git
  2. npm install

Install React dependencies :

  1. cd front
  2. npm install

Start

Run the following command to start the HTTP server :

  1. adonis serve --dev

Runs the React app in development mode :

  1. cd front
  2. npm start

Then you can access to the React App using :

  1. http://localhost:3000/

Make API request

  1. fetch('/api/v1/***')

In development, the React development server will recognize that it’s not a static asset, and will proxy your request to http://localhost:3333/api/v1/*** as a fallback.

Production

Create a React production build :

  1. cd front
  2. npm run build

The build folder will be automatically moved in the Adonisjs public folder.

Then start the HTTP server using a process manager like pm2 (recommended) :

  1. pm2 start server.js

For better performance, consider using nginx as a reverse proxy (faster to server static assets).