當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。