shepherdwind / hooks

Full Stack Framework. Zero Api. Using "React Hooks" to develop the back-end

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Faster Full Stack Framework

中文 README

Docs:Getting Started

✨ Features

  • ☁️  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

Demo

import server code into frontend code

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)
})

Hooks

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)
})

Contribute

We use yarn + lerna to manage the project.

install dependencies

$ yarn

build

$ yarn build

watch

$ yarn watch

test

$ yarn test

About

Full Stack Framework. Zero Api. Using "React Hooks" to develop the back-end


Languages

Language:TypeScript 95.4%Language:JavaScript 4.6%