1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/flow/plugins/middleware/example.middleware.plugin.js
2018-07-18 07:52:54 +02:00

45 lines
1.7 KiB
JavaScript

// @flow
// this file is not aim to be tested, just to check flow definitions
import Config from '../../../../src/lib/config';
import {generatePackageTemplate} from '../../../../src/lib/storage-utils';
import {readFile} from '../../../functional/lib/test.utils';
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
import type {
Config as AppConfig,
IPluginMiddleware,
IStorageManager,
IBasicAuth,
} from '@verdaccio/types';
import type { IUploadTarball, IReadTarball } from '@verdaccio/streams';
export default class ExampleMiddlewarePlugin implements IPluginMiddleware {
register_middlewares(app: any, auth: IBasicAuth, storage: IStorageManager): void {
auth.authenticate('user', 'password', () => {});
auth.allow_access('packageName', 'user', () => {});
auth.add_user('user', 'password', () => {});
auth.aesEncrypt(new Buffer('pass'));
// storage
storage.addPackage('name', generatePackageTemplate('test'), () => {});
storage.addVersion('name', 'version', readMetadata(), 'tag', () => {});
storage.mergeTags('name', {'latest': '1.0.0'}, () => {});
storage.changePackage('name', readMetadata(), 'revision', () => {});
storage.removePackage('name', () => {});
storage.mergeTags('name', {'latest': '1.0.0'}, () => {});
storage.removeTarball('name', 'filename', 'revision', () => {});
/* eslint no-unused-vars: 0 */
const config1: AppConfig = new Config({
storage: './storage',
self_path: '/home/sotrage'
});
const add: IUploadTarball = storage.addTarball('name', 'filename');
storage.getTarball('name', 'filename');
const read: IReadTarball = storage.getTarball('name', 'filename');
const search: IReadTarball = storage.search('test');
/* eslint no-unused-vars: 0 */
}
}