本文整理汇总了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));
}
示例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});
}));
}
示例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);
}));
};