Skip to content

Commit

Permalink
feat: update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
whxaxes committed Apr 25, 2019
1 parent 0d9727e commit f7edba7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/controller/home.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
'use strict';

import { Controller } from 'egg';
import { Controller, Context } from 'egg';
import { formatDate } from '~/app/lib/utils';

function validate() {
return (_target: HomeController, propertyKey: string, descriptor: PropertyDescriptor) => {
const oldAsyncFunc = descriptor.value;
descriptor.value = async function(ctx: Context) {
console.info('validate in', propertyKey, ctx.app.config.HOME);
await oldAsyncFunc.call(this, ctx);
};
};
}

export default class HomeController extends Controller {
@validate()
public async index() {
const { ctx, service } = this;
const time = service.time.today();
Expand Down

0 comments on commit f7edba7

Please sign in to comment.