How to use the midway.controller function in midway

To help you get started, we’ve selected a few midway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github midwayjs / midway-examples / demo-unittest / src / app / controller / home.ts View on Github external
import { controller, get, provide } from 'midway';

@provide()
@controller('/')
export class HomeController {

  @get('/')
  async index(ctx) {
    ctx.body = `Welcome to midwayjs!`;
  }
}
github alibaba / ice / packages / iceworks-server / src / app / controller / home.ts View on Github external
import { controller, get, provide } from 'midway';

@provide()
@controller('/')
export class HomeController {

  @get('*')
  async render(ctx) {
    await ctx.render('index.html');
    await ctx.render('index.html', ctx.clientConfig);
  }
}
github midwayjs / midway-examples / demo-plugin-egg-swagger-doc / src / app / controller / api.ts View on Github external
import { controller, post, provide, Context, inject } from 'midway';
/**
 * @controller api 登录接口
 */
@provide()
@controller('/api')
export default class APIController {

  @inject()
  ctx: Context;

  @inject()
  userService;

  /**
     * @summary 注册用户
     * @description 注册用户,记录用户账户/密码/
     * @router post /api/doRegist
     * @request body registUserRequest *body    
     */
  @post('/doRegist')
  async doRegist() {
github midwayjs / midway-examples / demo-pm2 / src / app / controller / home.ts View on Github external
import { controller, get, provide } from 'midway';

@provide()
@controller('/')
export class HomeController {

  @get('/')
  async index(ctx) {
    ctx.body = `Welcome to midwayjs!`;
  }
}
github midwayjs / midway-examples / demo-plugin-egg-acm / src / app / controller / home.ts View on Github external
import { controller, get, provide, inject } from 'midway';

@provide()
@controller('/')
export class HomeController {

  @inject()
  acmService;

  @get('/')
  async index(ctx: any) {
    ctx.body = this.acmService.getData();
  }

}
github midwayjs / midway / benchmark / fixtures / midway-request-scope / src / app / controller / user.ts View on Github external
import { controller, get, inject, provide } from 'midway';
import { IUserResult, IUserService } from '../../interface';

@provide()
@controller('/user')
export class UserController {
  @inject('userService')
  service: IUserService;

  @get('/:id')
  async getUser(ctx): Promise {
    const id: number = ctx.params.id;
    const user: IUserResult = await this.service.getUser({id});
    ctx.body = {success: true, message: 'OK', data: user};
  }
}
github midwayjs / midway-examples / demo-plugin-egg-graphql / src / app / controller / home.ts View on Github external
import { controller, get, provide } from 'midway';

@provide()
@controller('/')
export class HomeController {

  @get('/')
  async index(ctx) {
    ctx.body = `Welcome to midwayjs!`;
  }
}
github midwayjs / midway-examples / demo-sequelize-typescript / src / app / controller / post.ts View on Github external
import { controller, get, post, provide, inject } from 'midway';
import { IPostService } from '../../interface';

@provide()
@controller('/post')
export class PostController {
  @inject()
  postService: IPostService;

  @get('/')
  async index(ctx) {
    const query = {
      limit: parseInt(ctx.query.limit, 10) || 10,
      offset: parseInt(ctx.query.offset, 10) || 0,
    };

    ctx.body = await this.postService.list(query);
  }

  @get('/find')
  async show(ctx) {
github midwayjs / midway / packages / midway-init / boilerplate / midway-demo-boilerplate / boilerplate / src / app / controller / home.ts View on Github external
import { Context, controller, inject, get, provide } from 'midway';

@provide()
@controller('/')
export class HomeController {

  @inject()
  ctx: Context;

  @get('/')
  async index() {
    this.ctx.body = `Welcome to midwayjs!`;
  }
}
github midwayjs / midway / packages / midway-init / boilerplate / midway-ts-ant-design-pro-boilerplate / boilerplate / server / src / app / controller / user.ts View on Github external
import { Context, controller, provide, get, post, inject } from 'midway';
import { IUserService } from '../../lib/interface';

@provide()
@controller('/user')
export class UserController {

  @inject()
  ctx: Context;

  @inject('userService')
  service: IUserService;

  /**
   * GET /user/profile
   */
  @get('/profile')
  async profile() {
    const res = await this.service.profile();
    this.ctx.body = res.data;
  }

midway

A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade.

MIT
Latest version published 3 years ago

Package Health Score

60 / 100
Full package analysis