3 Star 2 Fork 1

Gitee 极速下载 / serverless-dns

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/serverless-dns/serverless-dns
克隆/下载
server-workers.js 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
Murtaza Aliakbar 提交于 2022-02-01 19:11 . Publish parcels with events
/*
* Copyright (c) 2021 RethinkDNS and its authors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import "./core/workers/config.js";
import { handleRequest } from "./core/doh.js";
import * as system from "./system.js";
import * as util from "./commons/util.js";
export default {
// workers/runtime-apis/fetch-event#syntax-module-worker
async fetch(request, env, context) {
return await serveDoh(request, env, context);
},
};
function serveDoh(request, env, ctx) {
// on Workers, the network-context is only available in an event listener
// and so, publish system prepare from here instead of from main which
// runs in global-scope.
system.pub("prepare", { env: env });
const event = util.mkFetchEvent(
request,
null,
ctx.waitUntil.bind(ctx),
ctx.passThroughOnException.bind(ctx)
);
return new Promise((accept) => {
system
.when("go")
.then((v) => {
return handleRequest(event);
})
.then((response) => {
accept(response);
})
.catch((e) => {
console.error("server", "serveDoh err", e);
accept(util.respond405());
});
});
}
JavaScript
1
https://gitee.com/mirrors/serverless-dns.git
git@gitee.com:mirrors/serverless-dns.git
mirrors
serverless-dns
serverless-dns
main

搜索帮助