-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8015fa6
commit b520d2b
Showing
8 changed files
with
118 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'reflect-metadata'; | ||
|
||
@controller | ||
class Plane { | ||
color: string = 'red'; | ||
|
||
@get('/login') | ||
fly(): void { | ||
console.log('vrrrrrrr'); | ||
} | ||
} | ||
|
||
function get(path: string) { | ||
return function(target: Plane, key: string) { | ||
Reflect.defineMetadata('path', path, target, key); | ||
}; | ||
} | ||
|
||
function controller(target: typeof Plane) { | ||
for (let key in target.prototype) { | ||
const path = Reflect.getMetadata('path', target.prototype, key); | ||
const middleware = Reflect.getMetadata('middleware', target.prototype, key); | ||
|
||
router.get(path, middleware, target.prototype[key]); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "features", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"reflect-metadata": "^0.1.13" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var LoginController = /** @class */ (function () { | ||
function LoginController() { | ||
} | ||
LoginController.prototype.getLogin = function (req, res) { | ||
res.send("\n <form method=\"POST\">\n <div>\n <label>Email</label>\n <input name=\"email\" />\n </div>\n <div>\n <label>Password</label>\n <input name=\"password\" type=\"password\" />\n </div>\n <button>Submit</button>\n </form>\n "); | ||
}; | ||
; | ||
__decorate([ | ||
get('/login') | ||
], LoginController.prototype, "getLogin", null); | ||
LoginController = __decorate([ | ||
controller('/') | ||
], LoginController); | ||
return LoginController; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Router, Request, Response, NextFunction } from 'express'; | ||
|
||
@controller('/') | ||
class LoginController { | ||
@get('/login') | ||
getLogin(req: Request, res: Response): void { | ||
res.send(` | ||
<form method="POST"> | ||
<div> | ||
<label>Email</label> | ||
<input name="email" /> | ||
</div> | ||
<div> | ||
<label>Password</label> | ||
<input name="password" type="password" /> | ||
</div> | ||
<button>Submit</button> | ||
</form> | ||
`); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters