Giter Club home page Giter Club logo

flycran / currying Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5 KB

Currying是一个极具创意的Node Server框架,它使用函数式编程和严格的类型安全编写服务端应用,正如它的名字一样,Currying大量使用了高阶函数和柯里化来进行类型安全的传递上下文,保证不会丢失任何静态类型。但这仅仅是Currying的核心理念,它还提供了许多前所未有的新概念和**来编写服务端应用,它将彻底改变现有的开发Node Server的**。

TypeScript 100.00%

currying's Introduction

Currying

Currying是一个极具创意的Node Server框架,它使用函数式编程和严格的类型安全编写服务端应用,正如它的名字一样,Currying大量使用了高阶函数和柯里化来进行类型安全的传递上下文,保证不会丢失任何静态类型。但这仅仅是Currying的核心理念,它还提供了许多前所未有的新概念和**来编写服务端应用,它将彻底改变现有的开发Node Server的**。

目前Currying仍处于开发阶段,但它的核心架构已经初见端倪,你可以使用类似如下的方式编写Currying App

const root = createRouter()

// 不带path的中间件
const r1 = root(() => {
  // 为下级路由提供额外信息
  return {
    date: Date.now(),
  }
})

r1.controller('/path-1', (ctx) => {
  // 在这里拿到父级路由提供的额外信息
  console.log('path-1 路由控制器被执行', ctx)
})

// 带path的中间件
const r2 = r1('/path-2')

r2.controller('/', (ctx) => {
  console.log('path-2 路由控制器被执行', ctx)
})

// 模拟请求
function rootExecute(context: Omit<Context, 'consumePath'>) {
  return root.execute({
    ...context,
    consumePath: context.path,
  })
}

rootExecute({
  path: '/a2',
})

敬请期待!

currying's People

Contributors

flycran avatar

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.