當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Application.delete方法代碼示例

本文整理匯總了TypeScript中express.Application.delete方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Application.delete方法的具體用法?TypeScript Application.delete怎麽用?TypeScript Application.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在express.Application的用法示例。


在下文中一共展示了Application.delete方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

export default function(app: Application, apiRoot: string) {
  var id = "/:id(\\d+)";
  app.get(apiRoot, send(req => Product.findAll()));
  app.get(apiRoot + id, send(req => Product.find(+req.params.id)));
  app.post(apiRoot, send(req => {
    var data = req.body;
    delete data.id;
    return Product.create(data);
  }));
  app.put(apiRoot + id, send(req => Product.update(req.body, { where: { id: +req.params.id } }), 200));
  app.delete(apiRoot + id, send(req => Product.destroy({ where: { id: +req.params.id } }), 204));
}
開發者ID:jussik,項目名稱:ssgl,代碼行數:12,代碼來源:product-ctrl.ts

示例2: init

export default function init(app: Application) {
    app.get('/tp_oauth/:accountName/authorizations', authorizeUser, wrap(async (req: Request, res) => {
        const user = getTpUserFromRequest(req);

        const authorizations = await TokenStorage.getAuthorizationsForUser(user);
        res.json({
            items: authorizations
        });
    }));

    app.delete('/tp_oauth/:accountName/authorizations/:clientId', authorizeUser, wrap(async (req: Request, res) => {
        const user = getTpUserFromRequest(req);
        const clientId = _.trim(req.params.clientId);

        if (!_.isString(clientId)) {
            return jsonError(res, {message: 'Required clientId parameter was not specified'});
        }

        const deletedCount = await TokenStorage.deleteAuthorizationForUser(clientId, user);
        res.json({deleted: deletedCount});
    }));
}
開發者ID:itsuryev,項目名稱:tp-oauth-server,代碼行數:22,代碼來源:tpAuthorizationsApi.ts

示例3: default


//.........這裏部分代碼省略.........
    }));

    // Marks article read, requires authentication.

    app.put('/article/:uuid/read', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markRead(tx, uuid, true);
    }));

    // Marks article unread, requires authentication.

    app.put('/article/:uuid/unread', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markRead(tx, uuid, false);
    }));

    // Marks all feed articles read, requires authentication.

    app.put('/feed/:uuid/read', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markFeedRead(tx, uuid);
    }));

    // Marks all feed articles seen, requires authentication.

    app.put('/feed/:uuid/seen', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markFeedSeen(tx, uuid);
    }));

    // Marks article important, requires authentication.

    app.put('/article/:uuid/important', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markImportant(tx, uuid, true);
    }));

    // Marks article unimportant, requires authentication.

    app.put('/article/:uuid/unimportant', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markImportant(tx, uuid, false);
    }));

    // Marks batch of articles seen.
    // Needs JSON array of article uuids.

    app.put('/seen', authed, bodyParser.json(), api(async (req, tx) => {
        const uuids = req.body;
        return articleRepo.markSeen(tx, uuids);
    }));

    // Deletes the given feed.
    // Requires authentication.

    app.delete('/feed/:uuid', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        await articleRepo.removeFeed(tx, uuid);
        await feedRepo.remove(tx, uuid);
    }));

    // Marks given feed error resolved.
    // Requires authentication.

    app.put('/feed/:uuid/resolve', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return feedRepo.resolve(tx, uuid);
    }));

    // Adds all given feed URLs.
    // Requires authentication.

    app.post('/urls', authed, bodyParser.json(), api(async (req, tx) => {
        const urls = req.body;
        return feedRepo.addAll(tx, urls);
    }));

    // Authenticates and sets cookie for identification.

    app.post('/login', bodyParser.json(), api(async (req) => {
        const user = req.body.user;
        const pass = req.body.pass;
        const users = config.auth;
        const ok = users.some((u) => {
            return u.user === user && u.pass === pass;
        });
        if (ok) {
            req.setAuthenticated(true);
            return { ok: true };
        } else {
            return { ok: false };
        }
    }));

    // Deauthenticates the user.

    app.post('/logout', api(async (req) => {
        req.setAuthenticated(false);
    }));
};
開發者ID:rla,項目名稱:feeds,代碼行數:101,代碼來源:api.ts


注:本文中的express.Application.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。