Daruk 是一款基于 Koa2,使用 Typescript 开发的轻量级 web 框架

网友投稿 656 2022-11-01

Daruk 是一款基于 Koa2,使用 Typescript 开发的轻量级 web 框架

Daruk 是一款基于 Koa2,使用 Typescript 开发的轻量级 web 框架

Daruk

Chinese Document

Daruk is a lightweight web framework base on Koa and written in Typescript. Koa is original http server implementation if you used it. In the daily development,we have to use many open source middleware in Koa to implement scaffold, routing, abstraction and some components such as logging, monitoring, etc.

We can create your web project by Daruk scaffold for business. Daruk core is lightweight and easy extension and learing, but it can provides more options for developer to rapid development such as constraints directory specification and code style.

Daruk, it comes from The Legend of Zelda: Breath of the Wild one of the four heroes, it have symbol of guardian ability. The goal of the framework is also as it.

Daruk is base on Koa2, includes features:

ScaffoldingDirectory and file specificationAuto loader and decorator combinationComplete Typescript development experienceLifecycle and hook.Custom(performance logs & business logs) & trackedOnline performance analysisLightweight link trackingThe MVC development of object-orientedSupport the development of the module

Installation scaffolding

# install daruk scaffold cli$ cnpm i -g daruk-cli# init project# --ignore ignore local template cache$ daruk init --ignore daruk-example# run the project$ cd daruk-example$ npm run dev

Quick start

You can write your code shown below :

import { Daruk } from 'daruk';const myApp = new Daruk('darukProject', { rootPath: __dirname, debug: process.env.NODE_ENV === 'dev'});myApp.listen(process.env.PORT || 3000);

controllers/index.ts:

import { BaseController, config, Context, Daruk, get, middleware, util } from 'daruk';export default class Index extends BaseController { @util('getToday') public getToday: Daruk['util']['getToday']; @config('author') public author: Daruk['config']['author']; @config('version') public version: Daruk['config']['version']; @middleware('cors') @get('/') public async index(ctx: Context, next: Function) { const weather = await ctx.service.weather.getWeather(); ctx.body = `Hi, ${this.author}, project version is ${ this.version }, Today is ${this.getToday()}, weather is ${weather}`; }}

More information you can check out example/03-weather.

Docs

More docs: Quick Start

Features Todo

Beta TodoList

How to Contribute

Please let us know how can we help. Do check out issues for bug reports or suggestions first.

To become a contributor, please follow our contributing guide

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:01248云影密码
下一篇:使用Python Web框架Django开发的一个B2C网上蔬果商城
相关文章

 发表评论

暂时没有评论,来抢沙发吧~