phecda-server
Version:
server framework that provide IOC/type-reuse/http&rpc-adaptor
258 lines (217 loc) • 6.04 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
// src/decorators/param.ts
var _phecdacore = require('phecda-core');
function BaseParam(data) {
return (target, property, index) => {
if (!property) return;
_phecdacore.setMeta.call(void 0, target, property, index, data);
};
}
_chunk4LLLQOMFjs.__name.call(void 0, BaseParam, "BaseParam");
function Body(key = "") {
return BaseParam({
type: "body",
key
});
}
_chunk4LLLQOMFjs.__name.call(void 0, Body, "Body");
function Head(key) {
return BaseParam({
type: "headers",
key: key.toLowerCase()
});
}
_chunk4LLLQOMFjs.__name.call(void 0, Head, "Head");
function Query(key = "") {
return BaseParam({
type: "query",
key
});
}
_chunk4LLLQOMFjs.__name.call(void 0, Query, "Query");
function Param(key) {
return BaseParam({
type: "params",
key
});
}
_chunk4LLLQOMFjs.__name.call(void 0, Param, "Param");
function Arg(target, k, index) {
BaseParam({
type: "args",
key: `${index}`
})(target, k, index);
}
_chunk4LLLQOMFjs.__name.call(void 0, Arg, "Arg");
function OneFile(key = "") {
return BaseParam({
type: "file",
key
});
}
_chunk4LLLQOMFjs.__name.call(void 0, OneFile, "OneFile");
function ManyFiles(key = "") {
return BaseParam({
type: "files",
key
});
}
_chunk4LLLQOMFjs.__name.call(void 0, ManyFiles, "ManyFiles");
// src/decorators/aop.ts
function Guard(...guards) {
return (target, property) => {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
guards
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Guard, "Guard");
function Addon(...addons) {
return (target, property) => {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
addons
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Addon, "Addon");
function Filter(filter) {
return (target, property) => {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
filter
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Filter, "Filter");
function Pipe(pipe) {
return (target, property, index) => {
if (typeof index === "number") {
BaseParam({
pipe
})(target, property, index);
return;
}
_phecdacore.setMeta.call(void 0, target, property, void 0, {
pipe
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Pipe, "Pipe");
// src/decorators/http.ts
function Route(route, method) {
return (target, property) => {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
http: {
route,
method
}
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Route, "Route");
function Header(headers) {
return (target, property) => {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
http: {
headers
}
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Header, "Header");
function Get(route = "") {
return Route(route, "get");
}
_chunk4LLLQOMFjs.__name.call(void 0, Get, "Get");
function Post(route = "") {
return Route(route, "post");
}
_chunk4LLLQOMFjs.__name.call(void 0, Post, "Post");
function Put(route = "") {
return Route(route, "put");
}
_chunk4LLLQOMFjs.__name.call(void 0, Put, "Put");
function Search(route = "") {
return Route(route, "search");
}
_chunk4LLLQOMFjs.__name.call(void 0, Search, "Search");
function Patch(route = "") {
return Route(route, "patch");
}
_chunk4LLLQOMFjs.__name.call(void 0, Patch, "Patch");
function Delete(route = "") {
return Route(route, "delete");
}
_chunk4LLLQOMFjs.__name.call(void 0, Delete, "Delete");
function Controller(prefix = "") {
return (target) => {
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
controller: "http",
http: {
prefix
}
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Controller, "Controller");
// src/decorators/rpc.ts
function Queue(queue = "", isEvent) {
return (target, property) => {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
rpc: {
queue,
isEvent
}
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Queue, "Queue");
function Rpc() {
return (target) => {
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
controller: "rpc"
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Rpc, "Rpc");
// src/decorators/ctx.ts
var Ctx = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (target, property) => {
_phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
ctxs: [
property
]
});
}, "Ctx");
function Define(key, value) {
return (target, property, index) => {
if (typeof index === "number") {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
params: [
{
define: {
[key]: value
},
index
}
]
});
} else {
_phecdacore.setMeta.call(void 0, target, property, void 0, {
define: {
[key]: value
}
});
}
};
}
_chunk4LLLQOMFjs.__name.call(void 0, Define, "Define");
// src/decorators/openapi.ts
function ApiDoc(config) {
return function(target, propertyKey, _descriptor) {
_phecdacore.setMeta.call(void 0, target, propertyKey, void 0, {
openapi: config
});
};
}
_chunk4LLLQOMFjs.__name.call(void 0, ApiDoc, "ApiDoc");
exports.BaseParam = BaseParam; exports.Body = Body; exports.Head = Head; exports.Query = Query; exports.Param = Param; exports.Arg = Arg; exports.OneFile = OneFile; exports.ManyFiles = ManyFiles; exports.Guard = Guard; exports.Addon = Addon; exports.Filter = Filter; exports.Pipe = Pipe; exports.Route = Route; exports.Header = Header; exports.Get = Get; exports.Post = Post; exports.Put = Put; exports.Search = Search; exports.Patch = Patch; exports.Delete = Delete; exports.Controller = Controller; exports.Queue = Queue; exports.Rpc = Rpc; exports.Ctx = Ctx; exports.Define = Define; exports.ApiDoc = ApiDoc;