Skip to content

Commit

Permalink
feat: adds delete dist tags (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
soldair authored and bcoe committed Dec 18, 2019
1 parent c5a4fef commit 0cdbb69
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,20 @@ app.put(/^\/[^\/]+$/, wrap(async (req, res) => {
// PUT
// https://wombat-dressing-room.appspot.com/-/package/soldair-test-package/dist-tags/latest

app.put('/-/package/:package/dist-tags/:tag', wrap(async (req, res) => {
const result = await writePackage(
decodeURIComponent(req.params.package), req, res);
// the request has not been ended yet if there has been a wombat
// error.
if (result.error) {
console.log('create dist tag error ', req.url, result);
} else {
console.log('');
}
}));
const putDeleteTag = wrap(async (req, res) => {
const result = await writePackage(
decodeURIComponent(req.params.package), req, res);
// the request has not been ended yet if there has been a wombat
// error.
if (result.error) {
console.log('create dist tag error ', req.url, result);
} else {
console.log('');
}
});

app.put('/-/package/:package/dist-tags/:tag', putDeleteTag);
app.delete('/-/package/:package/dist-tags/:tag', putDeleteTag);

app.post('/_/2fa', wrap(async (req, res) => {
const packageName = req.query.packageName || '';
Expand Down Expand Up @@ -469,12 +472,6 @@ app.get('/-/package/:package/dist-tags', (req, res) => {
request('https://registry.npmjs.org' + req.url).pipe(res);
});

// for the moment we'll disallow dit tag putting.
// we need to fetch the packument and verify repo permissions just like publish.
app.put('/-/package/:package/dist-tags/:tag', (req, res) => {
res.statusCode = 405;
res.end('{}');
});

// web --------------------------------
app.use(cookieSession({
Expand Down

0 comments on commit 0cdbb69

Please sign in to comment.