当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript koa-router.post函数代码示例

本文整理汇总了TypeScript中koa-router.post函数的典型用法代码示例。如果您正苦于以下问题:TypeScript post函数的具体用法?TypeScript post怎么用?TypeScript post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了post函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

	constructor() {
		const api = new AuthenticationApi();
		this.router = api.apiRouter();

		const githubAuth = new GitHubStrategy(settings.webUri('/auth/github/callback'));
		const googleAuth = new GoogleStrategy(settings.webUri('/auth/google/callback'));

		// local authentication
		this.router.post('/v1/authenticate', api.authenticate.bind(api));

		// mock route for simulating oauth2 callbacks
		if (process.env.NODE_ENV === 'test') {
			this.router.post('/v1/authenticate/mock', api.mockOAuth.bind(api));
		}

		// oauth routes
		if (config.vpdb.passport.github.enabled) {
			this.router.get('/v1/redirect/github',     githubAuth.redirectToProvider.bind(githubAuth));
			this.router.get('/v1/authenticate/github', githubAuth.authenticateOAuth.bind(githubAuth));
		}
		if (config.vpdb.passport.google.enabled) {
			this.router.get('/v1/redirect/google',     googleAuth.redirectToProvider.bind(googleAuth));
			this.router.get('/v1/authenticate/google', googleAuth.authenticateOAuth.bind(googleAuth));
		}
		config.vpdb.passport.ipboard.forEach(ips => {
			if (ips.enabled) {
				const ipsAuth = new IpsStrategy(settings.webUri('/auth/' + ips.id + '/callback'), ips);
				this.router.get('/v1/redirect/' + ips.id,     ipsAuth.redirectToProvider.bind(ipsAuth));
				this.router.get('/v1/authenticate/' + ips.id, ipsAuth.authenticateOAuth.bind(ipsAuth));
			}
		});
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:32,代码来源:authentication.api.router.ts

示例2: constructor

	constructor() {
		const api = new GameApi();
		this.router = api.apiRouter();

		this.router.get('/v1/games',       api.list.bind(api));
		this.router.head('/v1/games/:id',  api.head.bind(api));
		this.router.get('/v1/games/:id',   api.view.bind(api));
		this.router.patch('/v1/games/:id',  api.auth(api.update.bind(api), 'games', 'update-own', [ Scope.ALL ]));
		this.router.post('/v1/games',       api.auth(api.create.bind(api), 'games', 'add-og', [ Scope.ALL ]));
		this.router.delete('/v1/games/:id', api.auth(api.del.bind(api), 'games', 'delete', [ Scope.ALL ]));

		const ratingApi = new RatingApi();
		this.router.post('/v1/games/:id/rating', api.auth(ratingApi.createForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.put('/v1/games/:id/rating',  api.auth(ratingApi.updateForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.get('/v1/games/:id/rating',  api.auth(ratingApi.getForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.delete('/v1/games/:id/rating',  api.auth(ratingApi.deleteForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));

		const starsApi = new StarApi();
		this.router.post('/v1/games/:id/star',   api.auth(starsApi.star('game').bind(starsApi), 'games', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.delete('/v1/games/:id/star', api.auth(starsApi.unstar('game').bind(starsApi), 'games', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.get('/v1/games/:id/star',    api.auth(starsApi.get('game').bind(starsApi), 'games', 'star', [ Scope.ALL, Scope.COMMUNITY ]));

		const backglassApi = new BackglassApi();
		this.router.post('/v1/games/:gameId/backglasses', api.auth(backglassApi.create.bind(backglassApi), 'backglasses', 'add', [ Scope.ALL, Scope.CREATE ]));
		this.router.get('/v1/games/:gameId/backglasses', backglassApi.list.bind(backglassApi));

		const mediumApi = new MediumApi();
		this.router.get('/v1/games/:gameId/media', mediumApi.list.bind(mediumApi));

		const eventsApi = new LogEventApi();
		this.router.get('/v1/games/:id/events', eventsApi.list({ byGame: true }).bind(eventsApi));
		this.router.get('/v1/games/:id/release-name', api.auth(api.releaseName.bind(api), 'releases', 'add', [ Scope.ALL, Scope.CREATE ]));
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:33,代码来源:game.api.router.ts

示例3: constructor

	constructor() {
		const api = new RomApi();
		this.router = api.apiRouter();

		this.router.get('/v1/roms',       api.list.bind(api));
		this.router.post('/v1/roms',       api.auth(api.create.bind(api), 'roms', 'add', [ Scope.ALL , Scope.CREATE ]));
		this.router.get('/v1/roms/:id',   api.view.bind(api));
		this.router.delete('/v1/roms/:id', api.auth(api.del.bind(api), 'roms', 'delete-own', [ Scope.ALL , Scope.CREATE ]));

		this.router.get('/v1/games/:gameId/roms', api.list.bind(api));
		this.router.post('/v1/games/:gameId/roms', api.auth(api.create.bind(api), 'roms', 'add', [ Scope.ALL , Scope.CREATE ]));
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:12,代码来源:rom.api.router.ts

示例4: constructor

	constructor() {
		const api = new MediumApi();
		this.router = api.apiRouter();

		this.router.post('/v1/media',       api.auth(api.create.bind(api), 'media', 'add', [Scope.ALL, Scope.CREATE]));
		this.router.delete('/v1/media/:id', api.auth(api.del.bind(api), 'media', 'delete-own', [Scope.ALL, Scope.CREATE]));

		const starApi = new StarApi();
		this.router.post('/v1/media/:id/star',   starApi.auth(starApi.star('medium').bind(starApi), 'media', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.delete('/v1/media/:id/star', starApi.auth(starApi.unstar('medium').bind(starApi), 'media', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
		this.router.get('/v1/media/:id/star',    starApi.auth(starApi.get('medium').bind(starApi), 'media', 'star', [ Scope.ALL, Scope.COMMUNITY ]));

	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:13,代码来源:medium.api.router.ts

示例5: userApi

export function userApi(router: Router) {
  router.get('/admin/api/userList', async (ctx: IContext, next: any) => {
    let data = require('../../../data/user.json');
    ctx.body = formatRes(data, false);
    return await ctx.toJSON();
  });
  router.post('/admin/api/addUser', async (ctx: IContext, next: any) => {
    ctx.body = formatRes({ msg: '添加成功' }, false);
    return await ctx.toJSON();
  });
  router.post('/admin/api/delUser', async (ctx: IContext, next: any) => {
    ctx.body = formatRes({ msg: '删除成功' }, false);
    return await ctx.toJSON();
  });
}
开发者ID:Kpyu,项目名称:AntCMS,代码行数:15,代码来源:user.ts

示例6: buildRouter

    private buildRouter() {
        if (!this._built) {
            for (let [pathInfo, routeInfo] of routeManager.routeMap) {
                let prefix: string = routeManager.getRoutePrefix(routeInfo.constructor);
                let path: string = pathInfo.path;
                if (!path.startsWith("/")) {
                    path = prefix + path;
                }

                let route: Router.IMiddleware = this.wrapAction(routeInfo.constructor, routeInfo.function);
                switch (pathInfo.method) {
                    case "GET": this._router.get(path, route); break;
                    case "POST": this._router.post(path, route); break;
                    case "PUT": this._router.put(path, route); break;
                    case "DELETE": this._router.delete(path, route); break;
                    case "OPTIONS": this._router.options(path, route); break;
                    case "ALL": this._router.all(path, route); break;
                    default: {
                        try {
                            this._router[pathInfo.method.toLowerCase()](path, route); break;
                        } catch (error) {
                            //eat the undefined error;
                        }
                    }
                }
            }
            this._built = true;
        }
    }
开发者ID:Norgerman,项目名称:Koa-ts,代码行数:29,代码来源:RouterBuilder.ts

示例7: constructor

    constructor() {
        super({ prefix: '/testfd' });
        this.router.post('/', super.Body, async (ctx: Koa.IContext, next) => {
            let value = ctx.request.body['value'];
            const connection = await getConnection();
            try {
                await connection.execute(`UPDATE test_fd SET csc_id='${value}'`, []);
                // await connection.execute(`INSERT INTO test_fd (csc_id) VALUES ('${value}')`, []);
                ctx.body = value;
            } catch (error) {
                ctx.throw(error.message, 500);
            } finally {
                await connection.commit();
                connection.release();
            }
        });

        this.router.get('/', async (ctx: Koa.IContext, next) => {
            const connection = await getConnection();
            try {
                var results = await connection.execute(`SELECT csc_id from test_fd`, []);
                let content = results.rows[0][0];
                ctx.body = content;
            } catch (error) {
                ctx.throw(error.message, 500);
            } finally {
                connection.release();
            }
        });
    }
开发者ID:wangxin0709,项目名称:csc-scms-node-koa,代码行数:30,代码来源:testfd-controller.ts

示例8: constructor

	constructor() {
		const api = new AuthenticationStorageApi();
		this.router = api.storageRouter(true);

		// url authentication
		this.router.post('/v1/authenticate', api.authenticateUrls.bind(api));
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:7,代码来源:authentication.storage.router.ts

示例9: constructor

 constructor() {
     super({ prefix: '/auth' });
     /** 用户登录 */
     this.router.post('/login', super.Body, this.loginWhithCredential, this.loginWhithToken);
     /** 用户注销 */
     this.router.get('/logout', async (ctx, next) => { });
 }
开发者ID:wangxin0709,项目名称:csc-scms-node-koa,代码行数:7,代码来源:auth-controller.ts

示例10: constructor

	constructor() {
		const api = new TagApi();
		this.router = api.apiRouter();

		this.router.get('/v1/tags',       api.list.bind(api));
		this.router.post('/v1/tags',       api.auth(api.create.bind(api), 'tags', 'add', [Scope.ALL, Scope.CREATE]));
		this.router.delete('/v1/tags/:id', api.auth(api.del.bind(api), 'tags', 'delete-own', [Scope.ALL, Scope.CREATE]));
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:8,代码来源:tag.api.router.ts


注:本文中的koa-router.post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。