Giter Site home page Giter Site logo

hooks's Introduction

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

hooks's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.