0.0.1 • Published 3 years ago

@midwayjs/installer v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

A Faster Full Stack Framework

中文 README

Docs:Getting Started

✨ Features

  • ☁️  Fullstack, the src directory contains front-end and back-end code
  • 🌈  "Zero" Api, import server functions directly into frontend and automatically create API requests.
  • 🌍  Using "React Hooks | Vue composition" to develop the back-end
  • 📦  Front-end Framework agnostic. Current support React / Vue3 / ICE.js
  • ⚙️  Built on Midway, providing full support for Web and Serverless scenarios
  • 🛡  TypeScript Ready

🌰 Demo

backend api & frontend invoke

backend api src/apis/lambda/index.ts

export async function get() {
  return 'Hello Midway Hooks'
}

export async function post(name: string) {
  return 'Hello ' + name
}

frontend src/page/index.tsx

import { get, post } from './apis/lambda'

get().then((message) => {
  // send GET request to /api/get
  // Result: Hello Midway Hooks
  console.log(message)
})

post('github').then((message) => {
  // send Post request to /api/post, HTTP Body is { args: ['github'] }
  // Result: Hello github
  console.log(message)
})

Using Hooks

backend api src/apis/lambda/index.ts

import { useContext } from '@midwayjs/hooks'

export async function getPath() {
  // Get HTTP request context by Hooks
  const ctx = useContext()
  return ctx.path
}

frontend src/page/index.tsx

import { getPath } from './apis/lambda'

getPath().then((path) => {
  // send GET request to /api/getPath
  // Result: /api/getPath
  console.log(path)
})

🚀 Quick Start

Please install faas-cli first.

$ npm i @midwayjs/faas-cli -g

Create

React

$ f create --template-package=@midwayjs-examples/midway-hooks-react

Vue:

$ f create --template-package=@midwayjs-examples/midway-hooks-vue3

ICE.js:

$ npm init ice ice-app --template @icedesign/scaffold-midway-faas

Run

$ npm start

Deploy

$ f deploy

Contribute

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

We use yarn + lerna to manage the project.

  • install dependencies
$ yarn
  • build
$ yarn build
  • watch
$ yarn watch
  • test
$ yarn test

license

Midway Serverless based MIT licensed.

About

Alibaba Open Source