1 Star 4 Fork 0

mr小卓X/Denly

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT


🦕 Denly Web Framework 🦕

Release Denly Stars MIT License

Home | Documentation

Functions

  • Router System
  • Get Args & Form Data
  • Response System (redirect,abort)
  • Memory System (useful cache)
  • Session (realized in memory sys)
  • Event (trigger and timer)
  • Hot-Loading (automatic restart after editing the file)

Try it

You just need import the file from github (or gitee)

import { Denly } from "https://deno.land/x/denly@V0.24/mod.ts";

let app = new Denly({
  hostname: "127.0.0.1",
  port: 808,
  options: {
    debug: true,
  },
});

app.route.get("/", () => {
  return "Hello Denly!";
});

app.run();

It's easy to use, you don't need to download other file, just import the package from online.

Hot-loading [unstable]

if you want the server automatic restart after the file edited, then you can use hot-loading.

deno run --allow-run https://deno.land/x/denly@V0.24/debug.ts ./mod.ts

URL parameters

You can define a URL parameter based on a regular expression.

app.route.regex("letter", /^[a-zA-Z]+$/g);
app.route.get("/user/:letter",(name: string) => {
    return `Hello ${name}`;
});

The framework is equipped with the following regular expressions by default:

  • letter [ a-z A-Z ]
  • number [ 0-9 ]
  • email [ valid email ]
  • phone [ phone number (for Chinese) ]
  • date [ valid date ]

Error fallback

You can send different error status codes and customize how you handle them.

app.route.fallback(404, () => {
    return {
        header: new Headers(), // A headers object
        body: new TextEncoder().encode("<h1>404 Not Found</h1>"),
    };
});

// trigger it
app.route.get("/error/404",() => {
    return app.response.abort(404);
});

Output file

You can simply return a file.

app.route.get("/image",() => {
    // Auto-updates headers based on the suffix.
    return app.response.file("./background.jpg"); 
});

The file function have second parameter can set Content-Type.

Static route

app.route.resource("/static", "./public");

You can bind a static routes by passing the path to the local folder and the public alias to the resource function.

File upload

const file = app.request.file("file");
Deno.writeFileSync(_tempdir + "/runtime/upload/" + file.name, new Uint8Array(await file.arrayBuffer()));

You can use Request.file to upload file.

Developer

Author: ZhuoEr Liu mrxzx@qq.com

I am a back-end engineer and have recently been learning how to use Deno.

MIT License Copyright (c) 2021 LiuZhuoEr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

用于 Deno 的 Web 开发框架,目前已支持所有常用功能! 展开 收起
TypeScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/mrxzx/Denly.git
git@gitee.com:mrxzx/Denly.git
mrxzx
Denly
Denly
master

搜索帮助