@verdaccio/api 6.0.0-6-next.33 → 6.0.0-6-next.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/star.ts DELETED
@@ -1,88 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import buildDebug from 'debug';
3
- import { Response } from 'express';
4
- import _ from 'lodash';
5
-
6
- import { HTTP_STATUS, USERS } from '@verdaccio/core';
7
- import { Storage } from '@verdaccio/store';
8
-
9
- import { $NextFunctionVer, $RequestExtend } from '../types/custom';
10
-
11
- const debug = buildDebug('verdaccio:api:publish:star');
12
-
13
- export default function (
14
- storage: Storage
15
- ): (req: $RequestExtend, res: Response, next: $NextFunctionVer) => void {
16
- const validateInputs = (newUsers, localUsers, username, isStar): boolean => {
17
- const isExistlocalUsers = _.isNil(localUsers[username]) === false;
18
- if (isStar && isExistlocalUsers && localUsers[username]) {
19
- return true;
20
- } else if (!isStar && isExistlocalUsers) {
21
- return false;
22
- } else if (!isStar && !isExistlocalUsers) {
23
- return true;
24
- }
25
- return false;
26
- };
27
-
28
- return (req: $RequestExtend, res: Response, next: $NextFunctionVer): void => {
29
- const name = req.params.package;
30
- debug('starring a package for %o', name);
31
- // const afterChangePackage = function (err?: Error) {
32
- // if (err) {
33
- // debug('error on update package for %o', name);
34
- // return next(err);
35
- // }
36
-
37
- // debug('succes update package for %o', name);
38
- // res.status(HTTP_STATUS.OK);
39
- // next({
40
- // success: true,
41
- // });
42
- // };
43
-
44
- debug('get package info package for %o', name);
45
- // @ts-ignore
46
- // storage.getPackage({
47
- // name,
48
- // req,
49
- // callback: function (err, info) {
50
- // if (err) {
51
- // debug('error on get package info package for %o', name);
52
- // return next(err);
53
- // }
54
- // const newStarUser = req.body[USERS];
55
- // const remoteUsername = req.remote_user.name;
56
- // const localStarUsers = info[USERS];
57
- // // Check is star or unstar
58
- // const isStar = Object.keys(newStarUser).includes(remoteUsername);
59
- // debug('is start? %o', isStar);
60
- // if (
61
- // _.isNil(localStarUsers) === false &&
62
- // validateInputs(newStarUser, localStarUsers, remoteUsername, isStar)
63
- // ) {
64
- // return afterChangePackage();
65
- // }
66
- // const users = isStar
67
- // ? {
68
- // ...localStarUsers,
69
- // [remoteUsername]: true,
70
- // }
71
- // : _.reduce(
72
- // localStarUsers,
73
- // (users, value, key) => {
74
- // if (key !== remoteUsername) {
75
- // users[key] = value;
76
- // }
77
- // return users;
78
- // },
79
- // {}
80
- // );
81
- // debug('update package for %o', name);
82
- // storage.changePackage(name, { ...info, users }, req.body._rev, function (err) {
83
- // afterChangePackage(err);
84
- // });
85
- // },
86
- // });
87
- };
88
- }