@alpinesoft/railjet
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -16,3 +16,2 @@ "use strict"; | ||
const Methods_1 = __importDefault(require("../src/Methods")); | ||
const Param_1 = __importDefault(require("../src/Param")); | ||
const Types = __importStar(require("../src/Types")); | ||
@@ -28,3 +27,6 @@ const app = new App_1.default(); | ||
params: [ | ||
new Param_1.default("test", Types.Boolean.isRequired(), true) | ||
{ | ||
name: "test", | ||
type: Types.Boolean.isRequired() | ||
} | ||
] | ||
@@ -31,0 +33,0 @@ }); |
@@ -5,7 +5,5 @@ import Action from "./src/Action"; | ||
import Context from "./src/Context"; | ||
import Header from "./src/Header"; | ||
import HttpError from "./src/HttpError"; | ||
import Methods from "./src/Methods"; | ||
import Param from "./src/Param"; | ||
import * as Types from "./src/Types"; | ||
export { Action, App, BodyField, Context, Header, HttpError, Methods, Param, Types }; | ||
export { Action, App, BodyField, Context, HttpError, Methods, Types }; |
@@ -21,4 +21,2 @@ "use strict"; | ||
exports.Context = Context_1.default; | ||
const Header_1 = __importDefault(require("./src/Header")); | ||
exports.Header = Header_1.default; | ||
const HttpError_1 = __importDefault(require("./src/HttpError")); | ||
@@ -28,5 +26,3 @@ exports.HttpError = HttpError_1.default; | ||
exports.Methods = Methods_1.default; | ||
const Param_1 = __importDefault(require("./src/Param")); | ||
exports.Param = Param_1.default; | ||
const Types = __importStar(require("./src/Types")); | ||
exports.Types = Types; |
import Method from "./Methods"; | ||
import Context from "./Context"; | ||
import HttpError from "./HttpError"; | ||
import Header from "./Header"; | ||
import Param from "./Param"; | ||
import BodyField from "./BodyField"; | ||
import * as Types from "./Types"; | ||
interface ActionOpts { | ||
@@ -12,12 +11,20 @@ method: Method; | ||
description?: string; | ||
headers?: Header[]; | ||
params?: Param[]; | ||
headers?: HeaderDescription[]; | ||
params?: ParamDescription[]; | ||
body?: BodyField[]; | ||
hide?: boolean; | ||
} | ||
interface ParamDescription { | ||
name: string; | ||
type: Types.Type; | ||
} | ||
interface HeaderDescription { | ||
name: string; | ||
type: Types.Type; | ||
} | ||
declare class Action { | ||
method: Method; | ||
path: string; | ||
headers: Header[]; | ||
params: Param[]; | ||
headers: HeaderDescription[]; | ||
params: ParamDescription[]; | ||
body: BodyField[]; | ||
@@ -24,0 +31,0 @@ name: string; |
@@ -60,3 +60,3 @@ "use strict"; | ||
const { headers, params, body } = req; | ||
const context = new Context_1.default(req, res, headers, params, body, this.actions); | ||
const context = new Context_1.default(req, res, body, this.actions); | ||
const action = this.actions.find(a => { | ||
@@ -75,3 +75,3 @@ const path = req.url.split("?")[0].split("#")[0]; | ||
if (!value) { | ||
if (!header.required) { | ||
if (!header.type.required) { | ||
return; | ||
@@ -110,3 +110,3 @@ } | ||
if (!value) { | ||
if (!param.required) { | ||
if (!param.type.required) { | ||
return; | ||
@@ -113,0 +113,0 @@ } |
/// <reference types="node" /> | ||
import * as http from "http"; | ||
import Header from "./Header"; | ||
import BodyField from "./BodyField"; | ||
import Param from "./Param"; | ||
import HttpError from "./HttpError"; | ||
@@ -11,7 +9,5 @@ import Action from "./Action"; | ||
res: http.ServerResponse; | ||
headers: Header[]; | ||
params: Param[]; | ||
body: BodyField[]; | ||
actions: Action[]; | ||
constructor(req: http.IncomingMessage, res: http.ServerResponse, headers: Header[], params: Param[], body: BodyField[], actions: Action[]); | ||
constructor(req: http.IncomingMessage, res: http.ServerResponse, body: BodyField[], actions: Action[]); | ||
json(o: object): void; | ||
@@ -18,0 +14,0 @@ html(html: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Context { | ||
constructor(req, res, headers, params, body, actions) { | ||
constructor(req, res, body, actions) { | ||
this.req = req; | ||
this.res = res; | ||
this.headers = headers; | ||
this.params = params; | ||
this.body = body; | ||
@@ -10,0 +8,0 @@ this.actions = actions; |
@@ -5,8 +5,16 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const twig_1 = __importDefault(require("twig")); | ||
const path = __importStar(require("path")); | ||
const Action_1 = __importDefault(require("../Action")); | ||
const Methods_1 = __importDefault(require("../Methods")); | ||
const t = twig_1.default.twig({ | ||
path: "./templates/docs.twig", | ||
path: path.join(__dirname, "..", "..", "templates", "docs.twig"), | ||
async: false | ||
@@ -13,0 +21,0 @@ }); |
{ | ||
"name": "@alpinesoft/railjet", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Lightweight Node.js library to build advanced JSON APIs.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -78,3 +78,3 @@ import http from "http"; | ||
const context = new Context(req, res, headers, params, body, this.actions); | ||
const context = new Context(req, res, body, this.actions); | ||
const action = this.actions.find(a => { | ||
@@ -99,3 +99,3 @@ const path = req.url.split("?")[0].split("#")[0]; | ||
if (!header.required) { | ||
if (!header.type.required) { | ||
return; | ||
@@ -141,3 +141,3 @@ } | ||
if (!param.required) { | ||
if (!param.type.required) { | ||
return; | ||
@@ -144,0 +144,0 @@ } |
import * as http from "http"; | ||
import Header from "./Header"; | ||
import BodyField from "./BodyField"; | ||
import Param from "./Param"; | ||
import HttpError from "./HttpError"; | ||
@@ -13,12 +11,8 @@ import Action from "./Action"; | ||
res: http.ServerResponse; | ||
headers: Header[]; | ||
params: Param[]; | ||
body: BodyField[]; | ||
actions: Action[]; | ||
constructor(req: http.IncomingMessage, res: http.ServerResponse, headers: Header[], params: Param[], body: BodyField[], actions: Action[]) { | ||
constructor(req: http.IncomingMessage, res: http.ServerResponse, body: BodyField[], actions: Action[]) { | ||
this.req = req; | ||
this.res = res; | ||
this.headers = headers; | ||
this.params = params; | ||
this.body = body; | ||
@@ -25,0 +19,0 @@ this.actions = actions; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39782
1017