Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7.0 #119

Merged
merged 33 commits into from
May 3, 2017
Merged

0.7.0 #119

Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5b13b5c
updated dependencies
Apr 5, 2017
b57ed78
refactored decorators moved each into its own file
Apr 5, 2017
59b821b
moved deprecated decorators into their own directory
Apr 5, 2017
d8303d3
added deprecations in RoutingControllersOptions
Apr 5, 2017
08df531
refactored all decorators usage
Apr 6, 2017
f8f559f
refactored parameter options
Apr 6, 2017
76aba03
refactored decorators
Apr 6, 2017
c67a6ac
fixed wrong test
Apr 6, 2017
8c659ab
added new decorators
Apr 6, 2017
9840157
removed @EmptyResultCode decorator
Apr 6, 2017
36dbc51
remove interceptor functionality
Apr 6, 2017
b226073
removed deprecated decorators
Apr 7, 2017
41d575d
moved json controller back to non-deprecated decorators :(
Apr 7, 2017
9b279da
remove string casting to fix issues with buffer returning
Apr 7, 2017
4ac2766
fixed some decorators plus some refactoring
Apr 7, 2017
8e4e617
refactored RoutingControllers class
Apr 7, 2017
b7591b2
refactored action options object
Apr 7, 2017
0e84913
refactored action parameters stuff
Apr 7, 2017
460b8f2
refactored ActionParameterHandler
Apr 20, 2017
45e6c7f
refactored action metadata + beatifying all other classes
Apr 21, 2017
906fe8d
decorators and drivers refactoring
Apr 24, 2017
15c45d6
refactored named and non-named based parameters hydration
Apr 24, 2017
eaf9b39
implemented #75 - support for custom parameters decorators
Apr 24, 2017
308ade7
added custom authorized and current user decorators support
Apr 24, 2017
8552369
added context decorator for koa
Apr 25, 2017
9bb2008
small fixes; added more docs
Apr 26, 2017
f3b931d
exported metadata args storage; version bump
Apr 26, 2017
17cf0e8
added extra release note
Apr 26, 2017
c9e28df
added role checker support; fixed bug with validation and class trans…
Apr 28, 2017
c263928
implemented global metadata args storage
Apr 28, 2017
f5c5642
Update auto-validation Readme paragraph + typo
MichalLytek Apr 30, 2017
7831c64
added authorized support for controllers, added api for model control…
May 3, 2017
38de552
Merge pull request #126 from 19majkel94/patch-3
pleerock May 3, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build/
node_modules/
typings/
coverage/
npm-debug.log
187 changes: 67 additions & 120 deletions README.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes

**0.7.0** *[BREAKING CHANGES]*

*

**0.6.10**

* added integration with `class-transform-validator` for deserialization and auto validation request parameters
Expand Down
1 change: 0 additions & 1 deletion gulpfile.js

This file was deleted.

14 changes: 8 additions & 6 deletions gulpfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "es6-shim";
import {Gulpclass, Task, SequenceTask, MergedTask} from "gulpclass";
import {Gulpclass, MergedTask, SequenceTask, Task} from "gulpclass";

const gulp = require("gulp");
const del = require("del");
Expand Down Expand Up @@ -158,7 +157,7 @@ export class Gulpfile {
*/
@Task()
coveragePre() {
return gulp.src(["./build/es5/src/**/*.js"])
return gulp.src(["./build/compiled/src/**/*.js"])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
}
Expand All @@ -169,10 +168,13 @@ export class Gulpfile {
@Task("coveragePost", ["coveragePre"])
coveragePost() {
chai.should();
chai.use(require("sinon-chai"));
chai.use(require("chai-as-promised"));
// chai.use(require("sinon-chai"));
// chai.use(require("chai-as-promised"));

return gulp.src(["./build/es5/test/functional/**/*.js"])
return gulp.src([
"./build/compiled/test/functional/**/*.js",
"./build/compiled/test/issues/**/*.js",
])
.pipe(mocha())
.pipe(istanbul.writeReports());
}
Expand Down
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,57 @@
"controllers"
],
"dependencies": {
"class-transformer": "~0.1.3",
"class-validator": "^0.6.8",
"class-transformer": "~0.1.6",
"class-validator": "^0.7.0",
"cookie": "^0.3.1",
"glob": "^7.0.5",
"reflect-metadata": "^0.1.3"
"reflect-metadata": "^0.1.10"
},
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/chai-as-promised": "0.0.29",
"@types/express": "^4.0.34",
"@types/chai": "^3.4.35",
"@types/chai-as-promised": "0.0.30",
"@types/express": "^4.0.35",
"@types/express-session": "0.0.32",
"@types/koa": "^2.0.37",
"@types/mocha": "^2.2.37",
"@types/node": "^7.0.0",
"@types/sinon": "^1.16.34",
"body-parser": "^1.15.2",
"@types/koa": "^2.0.39",
"@types/mocha": "^2.2.40",
"@types/node": "^7.0.12",
"@types/sinon": "^2.1.2",
"body-parser": "^1.17.1",
"chai": "^3.4.1",
"chai-as-promised": "^6.0.0",
"chakram": "^1.4.0",
"del": "^2.2.1",
"es6-shim": "^0.35.1",
"express": "^4.14.0",
"express-session": "^1.14.1",
"express": "^4.15.2",
"express-session": "^1.15.2",
"gulp": "^3.9.1",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^3.0.1",
"gulp-replace": "^0.5.4",
"gulp-shell": "^0.5.0",
"gulp-sourcemaps": "^2.4.0",
"gulp-tslint": "^7.0.1",
"gulp-typescript": "^3.1.4",
"gulpclass": "^0.1.1",
"gulp-shell": "^0.6.3",
"gulp-sourcemaps": "^2.5.1",
"gulp-tslint": "^7.1.0",
"gulp-typescript": "^3.1.6",
"gulpclass": "^0.1.2",
"handlebars": "^4.0.6",
"koa": "^2.0.0",
"koa-bodyparser": "^3.1.0",
"koa-bodyparser": "^4.2.0",
"koa-convert": "^1.2.0",
"koa-multer": "^1.0.1",
"koa-router": "^7.0.1",
"koa-session": "^3.4.0",
"koa-views": "^5.2.0",
"koa-router": "^7.1.1",
"koa-session": "^5.0.0",
"koa-views": "^6.0.1",
"mocha": "^3.0.0",
"multer": "^1.1.0",
"multer": "^1.3.0",
"mustache-express": "^1.2.2",
"remap-istanbul": "^0.8.4",
"request": "^2.74.0",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"tslint": "^4.3.1",
"tslint-stylish": "^2.1.0-beta",
"remap-istanbul": "^0.9.5",
"request": "^2.81.0",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"ts-node": "^3.0.2",
"tslint": "^5.0.0",
"tslint-stylish": "^2.1.0",
"typedi": "^0.4.2",
"typescript": "^2.1.5"
"typescript": "^2.2.2"
},
"scripts": {
"test": "gulp tests"
Expand Down
14 changes: 9 additions & 5 deletions sample/sample1-simple-controller/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import "reflect-metadata";
import {Request} from "express";
import {Controller} from "../../src/decorator/controllers";
import {Get, Post, Put, Patch, Delete} from "../../src/decorator/methods";
import {Req} from "../../src/decorator/params";
import {JsonResponse} from "../../src/decorator/decorators";
import {Controller} from "../../src/decorator/Controller";
import {Get} from "../../src/decorator/Get";
import {Req} from "../../src/index";
import {Post} from "../../src/decorator/Post";
import {Put} from "../../src/decorator/Put";
import {Patch} from "../../src/decorator/Patch";
import {Delete} from "../../src/decorator/Delete";
import {ContentType} from "../../src/decorator/ContentType";

@Controller()
export class UserController {

@Get("/users")
@JsonResponse()
@ContentType("application/json")
getAll() {
return [
{ id: 1, name: "First user!" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {Request} from "express";
import {JsonController} from "../../../../../src/decorator/controllers";
import {Get, Post, Put, Patch, Delete} from "../../../../../src/decorator/methods";
import {Req} from "../../../../../src/decorator/params";
import {JsonController} from "../../../../../src/decorator/JsonController";
import {Get} from "../../../../../src/decorator/Get";
import {Post} from "../../../../../src/decorator/Post";
import {Req} from "../../../../../src/decorator/Req";
import {Put} from "../../../../../src/decorator/Put";
import {Patch} from "../../../../../src/decorator/Patch";
import {Delete} from "../../../../../src/decorator/Delete";

@JsonController()
export class BlogController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MiddlewareGlobalAfter} from "../../../../../src/decorator/decorators";
import {ErrorMiddlewareInterface} from "../../../../../src/middleware/ErrorMiddlewareInterface";
import {ExpressErrorMiddlewareInterface} from "../../../../../src/driver/express/ExpressErrorMiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/Middleware";

@MiddlewareGlobalAfter()
export class BlogErrorHandler implements ErrorMiddlewareInterface {
@Middleware({ global: true, type: "after" })
export class BlogErrorHandler implements ExpressErrorMiddlewareInterface {

error(error: any, request: any, response: any, next?: Function): void {
console.log("Error handled on blog handler: ", error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MiddlewareInterface} from "../../../../../src/middleware/MiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/decorators";
import {ExpressMiddlewareInterface} from "../../../../../src/driver/express/ExpressMiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/Middleware";

@Middleware()
export class BlogMiddleware implements MiddlewareInterface {
export class BlogMiddleware implements ExpressMiddlewareInterface {

use(request: any, response: any, next?: Function): any {
console.log("logging request from blog middleware...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {Request} from "express";
import {JsonController} from "../../../../../src/decorator/controllers";
import {Get, Post, Put, Patch, Delete} from "../../../../../src/decorator/methods";
import {Req} from "../../../../../src/decorator/params";
import {JsonController} from "../../../../../src/decorator/JsonController";
import {Get} from "../../../../../src/decorator/Get";
import {Post} from "../../../../../src/decorator/Post";
import {Put} from "../../../../../src/decorator/Put";
import {Req} from "../../../../../src/decorator/Req";
import {Patch} from "../../../../../src/decorator/Patch";
import {Delete} from "../../../../../src/decorator/Delete";

@JsonController()
export class PostController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MiddlewareGlobalAfter} from "../../../../../src/decorator/decorators";
import {ErrorMiddlewareInterface} from "../../../../../src/middleware/ErrorMiddlewareInterface";
import {ExpressErrorMiddlewareInterface} from "../../../../../src/driver/express/ExpressErrorMiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/Middleware";

@MiddlewareGlobalAfter()
export class PostErrorHandler implements ErrorMiddlewareInterface {
@Middleware({ global: true, type: "after" })
export class PostErrorHandler implements ExpressErrorMiddlewareInterface {

error(error: any, request: any, response: any, next?: Function): void {
console.log("Error handled on post handler: ", error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MiddlewareInterface} from "../../../../../src/middleware/MiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/decorators";
import {ExpressMiddlewareInterface} from "../../../../../src/driver/express/ExpressMiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/Middleware";

@Middleware()
export class PostMiddleware implements MiddlewareInterface {
export class PostMiddleware implements ExpressMiddlewareInterface {

use(request: any, response: any, next?: Function): any {
console.log("logging request from post middleware...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import {Request} from "express";
import {JsonController} from "../../../../../src/decorator/controllers";
import {Get, Post, Put, Patch, Delete} from "../../../../../src/decorator/methods";
import {Req, Param} from "../../../../../src/decorator/params";
import {JsonController} from "../../../../../src/decorator/JsonController";
import {Get} from "../../../../../src/decorator/Get";
import {Param} from "../../../../../src/decorator/Param";
import {Post} from "../../../../../src/decorator/Post";
import {Req} from "../../../../../src/decorator/Req";
import {Put} from "../../../../../src/decorator/Put";
import {Patch} from "../../../../../src/decorator/Patch";
import {Delete} from "../../../../../src/decorator/Delete";

@JsonController()
export class QuestionController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MiddlewareGlobalAfter} from "../../../../../src/decorator/decorators";
import {ErrorMiddlewareInterface} from "../../../../../src/middleware/ErrorMiddlewareInterface";
import {ExpressErrorMiddlewareInterface} from "../../../../../src/driver/express/ExpressErrorMiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/Middleware";

@MiddlewareGlobalAfter()
export class QuestionErrorHandler implements ErrorMiddlewareInterface {
@Middleware({ global: true, type: "after" })
export class QuestionErrorHandler implements ExpressErrorMiddlewareInterface {

error(error: any, request: any, response: any, next?: Function): void {
console.log("Error handled on question handler: ", error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MiddlewareInterface} from "../../../../../src/middleware/MiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/decorators";
import {ExpressMiddlewareInterface} from "../../../../../src/driver/express/ExpressMiddlewareInterface";
import {Middleware} from "../../../../../src/decorator/Middleware";

@Middleware()
export class QuestionMiddleware implements MiddlewareInterface {
export class QuestionMiddleware implements ExpressMiddlewareInterface {

use(request: any, response: any, next?: Function): any {
console.log("logging request from question middleware...");
Expand Down
18 changes: 12 additions & 6 deletions sample/sample12-session-support/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import "reflect-metadata";
import {Request} from "express";
import {Controller} from "../../src/decorator/controllers";
import {Get, Post, Put, Patch, Delete} from "../../src/decorator/methods";
import {Session, Req, Param} from "../../src/decorator/params";
import {JsonResponse} from "../../src/decorator/decorators";
import {Controller} from "../../src/decorator/Controller";
import {Get} from "../../src/decorator/Get";
import {Req} from "../../src/index";
import {Post} from "../../src/decorator/Post";
import {Put} from "../../src/decorator/Put";
import {Patch} from "../../src/decorator/Patch";
import {Delete} from "../../src/decorator/Delete";
import {Param} from "../../src/decorator/Param";
import {Session} from "../../src/decorator/Session";
import {ContentType} from "../../src/decorator/ContentType";

@Controller()
export class UserController {

@Get("/users")
@JsonResponse()
@ContentType("application/json")
getAll() {
return [
{ id: 1, name: "First user!" },
Expand All @@ -18,7 +24,7 @@ export class UserController {
}

@Get("/users/:id")
@JsonResponse()
@ContentType("application/json")
getOne(@Session("user") user: any) {
return user;
}
Expand Down
6 changes: 3 additions & 3 deletions sample/sample13-koa-views-render/BlogController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "reflect-metadata";
import {Controller} from "../../src/decorator/controllers";
import {Get, Post, Put, Patch, Delete} from "../../src/decorator/methods";
import {Render} from "../../src/decorator/decorators";
import {Controller} from "../../src/decorator/Controller";
import {Get} from "../../src/decorator/Get";
import {Render} from "../../src/decorator/Render";

@Controller()
export class UserController {
Expand Down
18 changes: 18 additions & 0 deletions sample/sample14-custom-decorator/QuestionController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "reflect-metadata";
import {Get} from "../../src/decorator/Get";
import {JsonController} from "../../src/decorator/JsonController";
import {UserFromSession} from "./UserFromSession";
import {User} from "./User";

@JsonController()
export class QuestionController {

@Get("/questions")
all(@UserFromSession({ required: true }) user: User) {
return [{
id: 1,
title: "Question created by " + user.firstName
}];
}

}
13 changes: 13 additions & 0 deletions sample/sample14-custom-decorator/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class User {

id: number;
firstName: string;
lastName: string;

constructor(id: number, firstName: string, lastName: string) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}

}
22 changes: 22 additions & 0 deletions sample/sample14-custom-decorator/UserFromSession.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {registerParamDecorator} from "../../src/index";
import {User} from "./User";

/**
* Simple decorator - re-implementation of CurrentUser decorator.
*/
export function UserFromSession(options?: { required?: boolean }) {
return function(object: Object, method: string, index: number) {
registerParamDecorator({
object: object,
method: method,
index: index,
required: options && options.required ? true : false,
value: actionProperties => {
// perform queries based on token from request headers
// const token = actionProperties.request.headers["authorization"];
// return database.findUserByToken(token);
return new User(1, "Johny", "Cage");
}
});
};
}