Comparing version 1.0.0-canary.14 to 1.0.0-canary.15
@@ -7,2 +7,12 @@ "use strict"; | ||
const path_1 = require("path"); | ||
class DefaultDependencyResolver { | ||
resolve(type) { | ||
return new type(); | ||
} | ||
} | ||
const DefaultConfiguration = { | ||
mode: "debug", | ||
controller: "./controller", | ||
dependencyResolver: new DefaultDependencyResolver() | ||
}; | ||
class Plumier { | ||
@@ -12,3 +22,3 @@ constructor() { | ||
this.koa = new koa_1.default(); | ||
this.config = Object.assign({}, core_1.DefaultConfiguration, { middleware: [], facilities: [] }); | ||
this.config = Object.assign({}, DefaultConfiguration, { middleware: [], facilities: [] }); | ||
} | ||
@@ -45,3 +55,3 @@ use(option) { | ||
core_1.printAnalysis(core_1.analyzeRoutes(routes)); | ||
this.koa.use(core_1.router(routes, this.config, this.globalMiddleware)); | ||
this.koa.use(core_1.router(routes, this.globalMiddleware)); | ||
return this.koa; | ||
@@ -48,0 +58,0 @@ } |
/// <reference types="koa__cors" /> | ||
import Cors from "@koa/cors"; | ||
import { Class, DefaultFacility, PlumierApplication, ValidatorFunction } from "@plumier/core"; | ||
import Koa from "koa"; | ||
export interface BodyParserOption { | ||
enableTypes?: string[]; | ||
encode?: string; | ||
formLimit?: string; | ||
jsonLimit?: string; | ||
strict?: boolean; | ||
detectJSON?: (ctx: Koa.Context) => boolean; | ||
extendTypes?: { | ||
json?: string[]; | ||
form?: string[]; | ||
text?: string[]; | ||
}; | ||
onerror?: (err: Error, ctx: Koa.Context) => void; | ||
} | ||
import { Class, DefaultFacility, PlumierApplication, ValidatorStore } from "@plumier/core"; | ||
import BodyParser from "koa-body"; | ||
/** | ||
* Preset configuration for building rest. This facility contains: | ||
* | ||
* body parser: koa-bodyparser | ||
* parameter binder | ||
* | ||
* body parser: koa-body | ||
* | ||
* cors: @koa/cors | ||
@@ -30,7 +18,5 @@ */ | ||
controller?: string | Class | Class[] | undefined; | ||
bodyParser?: BodyParserOption | undefined; | ||
bodyParser?: BodyParser.IKoaBodyOptions | undefined; | ||
cors?: Cors.Options | undefined; | ||
validators?: { | ||
[key: string]: ValidatorFunction; | ||
} | undefined; | ||
validators?: ValidatorStore | undefined; | ||
} | undefined); | ||
@@ -42,4 +28,6 @@ setup(app: Readonly<PlumierApplication>): void; | ||
* | ||
* body parser: koa-bodyparser | ||
* parameter binder | ||
* | ||
* body parser: koa-body | ||
* | ||
* cors: @koa/cors | ||
@@ -46,0 +34,0 @@ * |
@@ -6,9 +6,10 @@ "use strict"; | ||
const core_1 = require("@plumier/core"); | ||
const koa_bodyparser_1 = tslib_1.__importDefault(require("koa-bodyparser")); | ||
const typedconverter_1 = require("typedconverter"); | ||
const koa_body_1 = tslib_1.__importDefault(require("koa-body")); | ||
/** | ||
* Preset configuration for building rest. This facility contains: | ||
* | ||
* body parser: koa-bodyparser | ||
* parameter binder | ||
* | ||
* body parser: koa-body | ||
* | ||
* cors: @koa/cors | ||
@@ -27,7 +28,3 @@ */ | ||
catch (e) { | ||
if (e instanceof typedconverter_1.ConversionError) { | ||
ctx.body = e.issues; | ||
ctx.status = e.status; | ||
} | ||
else if (e instanceof core_1.HttpStatusError) | ||
if (e instanceof core_1.HttpStatusError) | ||
ctx.throw(e.status, e); | ||
@@ -38,3 +35,3 @@ else | ||
}); | ||
app.koa.use(koa_bodyparser_1.default(this.opt && this.opt.bodyParser)); | ||
app.koa.use(koa_body_1.default(this.opt && this.opt.bodyParser)); | ||
app.koa.use(cors_1.default(this.opt && this.opt.cors)); | ||
@@ -45,3 +42,3 @@ if (this.opt && this.opt.controller) | ||
app.set({ validators: this.opt.validators }); | ||
app.set({ typeConverterVisitors: [core_1.validatorVisitor] }); | ||
app.use(new core_1.ValidationMiddleware(app.config)); | ||
} | ||
@@ -53,4 +50,6 @@ } | ||
* | ||
* body parser: koa-bodyparser | ||
* parameter binder | ||
* | ||
* body parser: koa-body | ||
* | ||
* cors: @koa/cors | ||
@@ -57,0 +56,0 @@ * |
@@ -1,4 +0,4 @@ | ||
export { authorize, ActionResult, Application, bind, Configuration, Class, DependencyResolver, Facility, FileUploadInfo, FileParser, HeaderPart, HttpMethod, HttpStatusError, Invocation, KoaMiddleware, middleware, Middleware, domain, PlumierApplication, PlumierConfiguration, RequestPart, route, RouteInfo, ValidationIssue, ValidatorStore, ValidatorFunction, ValidatorId, DefaultFacility, response, val } from "@plumier/core"; | ||
export { authorize, ActionResult, Application, bind, Configuration, Class, DependencyResolver, Facility, FileUploadInfo, FileParser, HeaderPart, HttpMethod, HttpStatusError, Invocation, KoaMiddleware, middleware, Middleware, domain, PlumierApplication, PlumierConfiguration, RequestPart, route, RouteInfo, ValidatorStore, ValidatorFunction, ValidatorInfo, DefaultFacility, response, val } from "@plumier/core"; | ||
export * from "./facility"; | ||
import { Plumier } from "./application"; | ||
export default Plumier; |
@@ -12,3 +12,2 @@ "use strict"; | ||
exports.route = core_1.route; | ||
exports.ValidatorId = core_1.ValidatorId; | ||
exports.DefaultFacility = core_1.DefaultFacility; | ||
@@ -15,0 +14,0 @@ exports.response = core_1.response; |
{ | ||
"name": "plumier", | ||
"version": "1.0.0-canary.14+158957b", | ||
"description": "Delightful Node.js Rest API Framework powered by Koa and TypeScript", | ||
"version": "1.0.0-canary.15+d64f567", | ||
"description": "Delightful Node.js Rest Framework", | ||
"main": "lib/index.js", | ||
@@ -22,15 +22,13 @@ "types": "lib/index.d.ts", | ||
"@koa/cors": "^3.0.0", | ||
"@plumier/core": "1.0.0-canary.14+158957b", | ||
"@types/koa": "^2.0.48", | ||
"@types/koa-bodyparser": "^5.0.0", | ||
"@plumier/core": "1.0.0-canary.15+d64f567", | ||
"@types/koa__cors": "^2.2.3", | ||
"koa": "^2.7.0", | ||
"koa-bodyparser": "^4.2.1", | ||
"koa-body": "^4.1.0", | ||
"tslib": "^1.9.3" | ||
}, | ||
"devDependencies": { | ||
"@plumier/jwt": "1.0.0-canary.14+158957b", | ||
"@plumier/mongoose": "1.0.0-canary.14+158957b", | ||
"@plumier/multipart": "1.0.0-canary.14+158957b", | ||
"@plumier/serve-static": "1.0.0-canary.14+158957b", | ||
"@plumier/jwt": "1.0.0-canary.15+d64f567", | ||
"@plumier/mongoose": "1.0.0-canary.15+d64f567", | ||
"@plumier/multipart": "1.0.0-canary.15+d64f567", | ||
"@plumier/serve-static": "1.0.0-canary.15+d64f567", | ||
"@types/body-parser": "^1.17.0", | ||
@@ -40,22 +38,24 @@ "@types/cors": "^2.8.4", | ||
"@types/express-jwt": "^0.0.42", | ||
"@types/fs-extra": "^5.0.5", | ||
"@types/fs-extra": "^7.0.0", | ||
"@types/joi": "^14.3.1", | ||
"@types/jsonwebtoken": "^8.3.0", | ||
"@types/koa-better-body": "^3.0.0", | ||
"@types/koa-router": "^7.0.39", | ||
"@types/rimraf": "^2.0.2", | ||
"@types/supertest": "^2.0.7", | ||
"autocannon": "^3.2.0", | ||
"autocannon": "^4.0.0", | ||
"benalu": "^2.0.0-beta-1", | ||
"body-parser": "^1.18.3", | ||
"cors": "^2.8.5", | ||
"express": "^4.16.4", | ||
"express": "^4.17.1", | ||
"express-jwt": "^5.3.1", | ||
"fs-extra": "^7.0.1", | ||
"fs-extra": "^8.0.0", | ||
"joi": "^14.3.1", | ||
"jsonwebtoken": "^8.4.0", | ||
"koa-better-body": "^3.0.4", | ||
"koa-router": "^7.4.0", | ||
"rimraf": "^2.6.3", | ||
"supertest": "^4.0.0", | ||
"ts-node": "^8.0.2", | ||
"typescript": "^3.3.3333" | ||
"ts-node": "^8.3.0", | ||
"typescript": "^3.5.2" | ||
}, | ||
@@ -72,3 +72,3 @@ "bugs": { | ||
}, | ||
"gitHead": "158957b44b2ac6b7a88a666cefde89d7ccbae97e" | ||
"gitHead": "d64f5673d593b07f710ab5e93ebc5aba3985726a" | ||
} |
# Plumier | ||
Delightful Node.js Rest API Framework powered by Koa and TypeScript | ||
Delightful Node.js Rest Framework | ||
@@ -4,0 +4,0 @@ [](https://travis-ci.org/plumier/plumier) |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
6
18586
30
9
193
+ Addedkoa-body@^4.1.0
+ Added@types/formidable@1.2.8(transitive)
+ Addedco-body@5.2.0(transitive)
+ Addedformidable@1.2.6(transitive)
+ Addedkoa-body@4.2.0(transitive)
- Removed@types/koa@^2.0.48
- Removed@types/koa-bodyparser@^5.0.0
- Removedkoa-bodyparser@^4.2.1
- Removed@hapi/bourne@3.0.0(transitive)
- Removed@types/koa-bodyparser@5.0.2(transitive)
- Removedco-body@6.2.0(transitive)
- Removedcopy-to@2.0.1(transitive)
- Removedkoa-bodyparser@4.4.1(transitive)