Docs:Getting Started
- ☁️ Fullstack, the src directory contains front-end and back-end code
- 🌈 The easiest way to develop and call back-end APIs
- 🌍 Using "React Hooks" 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
export async function get() {
return 'Hello Midway Hooks'
}
export async function post(name: string) {
return 'Hello ' + name
}
frontend
import { get, post } from './apis/lambda'
/**
* @method GET
* @url /api/get
*/
get().then((message) => {
// Display: Hello Midway Hooks
console.log(message)
})
/**
* @method POST
* @url /api/post
* @body { args: ['github'] }
*/
post('github').then((message) => {
// Display: Hello github
console.log(message)
})
backend api
import { useContext } from '@midwayjs/hooks'
export async function getPath() {
const ctx = useContext()
return ctx.path
}
frontend
import { getPath } from './apis/lambda'
/**
* @method GET
* @url /api/getPath
*/
getPath().then((path) => {
// Display: /api/getPath
console.log(path)
})
We use yarn + lerna to manage the project.
install dependencies
$ yarn
build
$ yarn build
watch
$ yarn watch
test
$ yarn test