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


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

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: constructor

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

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

示例5: 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

示例6: constructor

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

		this.router.get('/v1/sitemap', api.sitemap.bind(api));
		this.router.get('/v1/ping',    api.ping.bind(api));
		this.router.get('/v1/plans',   api.plans.bind(api));
		this.router.get('/v1/roles',    api.auth(api.roles.bind(api), 'roles', 'list', [ Scope.ALL ]));
		this.router.get('/v1/ipdb/:id', api.auth(api.ipdbDetails.bind(api), 'ipdb', 'view', [ Scope.ALL ]));
		this.router.delete('/v1/cache', api.auth(api.invalidateCache.bind(api), 'cache', 'delete', [ Scope.ALL ]));

		if (process.env.ENABLE_KILL_SWITCH) {
			this.router.post('/v1/kill',     api.kill.bind(api));
		}
		this.router.get('index', '/v1', api.index.bind(api));
		this.router.redirect('/', 'index');

		apiCache.enable(this.router, '/v1/sitemap', { entities: [], listModels: ['game', 'release'] });
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:19,代码来源:misc.api.router.ts

示例7: async

  // TODO add PUT, PATCH routes
  if (flags & RESOURCE_DELETE) {
    router.delete(`/${resource}/:id`, async (ctx, next) => {
      const log = {
        message: `Delete ${resource}`,
        context: ctx,
        id: ctx.params.id
      };

      const authorizer = ctx.state.authorizer;
      const filter = ["=", ["PARAM", RESOURCE_IDS[resource]], ctx.params.id];
      if (!authorizer.hasAccess(resource, 3)) {
        logUnauthorizedWarning(log);
        return void next();
      }
      const res = await db.query(resource, filter);
      if (!res.length) return void next();

      const validate = authorizer.getValidator(resource, res[0]);
      if (!validate("delete")) {
        logUnauthorizedWarning(log);
        return void (ctx.status = 403);
      }

      await apiFunctions.deleteResource(resource, ctx.params.id);

      logger.accessInfo(log);

      ctx.body = "";
    });
  }
开发者ID:zaidka,项目名称:genieacs,代码行数:31,代码来源:api.ts

示例8: Router

import { getAllPeople } from './people';
import { addTodo, deleteTodo, getAllTodo, getTodo, patchTodo } from './todo';

// Tip:
// For more complex applications, consider using a dependency injection
// framework like InversifyJS. There are plugins for express and koa (see also
// e.g. https://www.npmjs.com/package/inversify-koa-utils)

// Read more about routing at https://github.com/alexmingoia/koa-router
const router = new Router({prefix: '/api'});
router.get('/people', getAllPeople);
router.get('/todos', getAllTodo);
router.get('/todos/:id', getTodo);
router.post('/todos', addTodo);
router.patch('/todos/:id', patchTodo);
router.delete('/todos/:id', deleteTodo);

// Read more about koa at http://koajs.com/
const app = new Koa();
app.use(cors());
app.use(logger());
app.use(bodyParser());
app.use(router.routes());

// Read more about koa views at https://github.com/queckezz/koa-views
// Read more about Nunjucks at https://mozilla.github.io/nunjucks/
const viewPath = path.join(__dirname, 'views');
app.use(views(viewPath, {
  map: {html: 'nunjucks'},
  options: {loader: new FileSystemLoader(viewPath)}
}));
开发者ID:,项目名称:,代码行数:31,代码来源:

示例9: async

        link.set('token', body.token);
    }
    await link.save();
    ctx.body = 'OK';
});

/**
 * @api {DELETE} /:token Delete link
 * @apiName DeleteLink
 * @apiGroup Link
 */
router.delete('/:token', auth, async (ctx) => {
    const {token} = ctx.params;
    const link = await models.link.findOne({ where: { token } });
    if (!link) {
        ctx.status = 404;
    } else {
        await link.destroy();
    }
    ctx.status = 200;
});

/**
 * @api {POST} /:token/references Create reference
 * @apiName CreateReference
 * @apiGroup Reference
 */
router.post('/:token/references', auth, async (ctx: any) => {
    const {token} = ctx.params;
    const {url, userAgent} = ctx.request.body;
    const [link, created] = await models.link.findOrCreate({ where: { token } });
    const id = uuid.v4();
开发者ID:CatchLabs,项目名称:simple-redir,代码行数:32,代码来源:index.ts

示例10: require

import * as Router from 'koa-router';
import { getManager } from 'typeorm';
import controller = require('./controller');

const router = new Router();

// GENERAL ROUTES
router.get('/', controller.general.helloWorld);
router.get('/jwt', controller.general.getJwtPayload);

// USER ROUTES
router.get('/users', controller.user.getUsers);
router.get('/user/:id', controller.user.getUser);
router.post('/user', controller.user.createUser);
router.put('/user/:id', controller.user.updateUser);
router.delete('/user/:id', controller.user.deleteUser);

export { router };
开发者ID:ryanwild,项目名称:node-typescript-koa-rest,代码行数:18,代码来源:routes.ts


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