3.1.6 • Published 1 year ago

@midwayjs/hooks-core v3.1.6

Weekly downloads
116
License
MIT
Repository
github
Last release
1 year 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

3.1.6

1 year ago

3.1.5

1 year ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.4

1 year ago

2.3.4

1 year ago

2.3.6

1 year ago

2.3.5

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.1.0-beta.1

1 year ago

3.1.0-beta.2

1 year ago

3.1.0-beta.0

1 year ago

2.3.4-beta-0

2 years ago

2.3.3

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

3.0.0-rc.15

2 years ago

3.0.0-rc.17

2 years ago

3.0.0-rc.16

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

3.0.0-rc.13

2 years ago

3.0.0-rc.12

2 years ago

3.0.0-rc.14

2 years ago

3.0.0-rc.11

2 years ago

3.0.0-rc.2

2 years ago

3.0.0-rc.1

2 years ago

3.0.0-rc.6

2 years ago

3.0.0-rc.5

2 years ago

3.0.0-rc.4

2 years ago

3.0.0-rc.10

2 years ago

3.0.0-rc.3

2 years ago

3.0.0-rc.9

2 years ago

3.0.0-rc.8

2 years ago

3.0.0-rc.7

2 years ago

3.0.0-alpha.0

3 years ago

2.4.0-alpha.0

3 years ago

2.3.0

3 years ago

2.3.0-next.1

3 years ago

2.3.0-next.0

3 years ago

2.2.5-next.7

3 years ago

2.2.5-next.6

3 years ago

2.2.5-next.5

3 years ago

2.2.5-next.4

3 years ago

2.2.5-next.3

3 years ago

2.2.5-next.2

3 years ago

2.2.5-next.1

3 years ago

2.2.5-next.0

3 years ago

2.2.4

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.2.0-next.9

3 years ago

2.2.0-next.8

3 years ago

2.2.0-next.7

3 years ago

2.2.0-next.6

3 years ago

2.2.0-next.5

3 years ago

2.2.0-next.4

3 years ago

2.2.0-next.3

3 years ago

2.2.0-next.2

3 years ago

2.2.0-next.1

3 years ago

2.2.0-next.0

3 years ago

2.1.0

3 years ago

2.1.0-next.7

3 years ago

2.1.0-next.6

3 years ago

2.1.0-next.5

3 years ago

2.1.0-next.2

3 years ago

2.1.0-next.4

3 years ago

2.1.0-next.3

3 years ago

2.1.0-next.1

3 years ago

2.1.0-next.0

3 years ago

2.0.1-next.0

3 years ago

2.0.0

3 years ago

2.0.0-next.5

3 years ago

2.0.0-next.4

3 years ago

2.0.0-next.2

3 years ago

2.0.0-next.1

3 years ago

2.0.0-next.0

3 years ago