Docs:Getting Started
- ☁️ 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
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)
})
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)
})
Please install faas-cli first.
$ npm i @midwayjs/faas-cli -g
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
$ npm start
$ f deploy
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- 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
Midway Serverless based MIT licensed.