Skip to content

Commit a5b8449

Browse files
Type better baseUrlFunc and discoveryFunc
1 parent 183fc20 commit a5b8449

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

src/registry/middleware/base-url-handler.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ export default function baseUrlHandler(
55
res: Response,
66
next: NextFunction
77
): void {
8-
res.conf.baseUrlFunc =
9-
res.conf.baseUrlFunc ||
10-
(typeof res.conf.baseUrl === 'function' ? res.conf.baseUrl : undefined);
11-
128
if (res.conf.baseUrlFunc) {
139
res.conf.baseUrl = res.conf.baseUrlFunc({
1410
host: req.headers.host,

src/registry/routes/dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import getAvailableDependencies from './helpers/get-available-dependencies';
44

55
export default function dependencies(conf: Config) {
66
return function (req: Request, res: Response): void {
7-
if (conf.discovery) {
7+
if (res.conf.discovery) {
88
const dependencies = getAvailableDependencies(conf.dependencies).map(
99
({ core, name, version }) => {
1010
const dep: { name: string; core: boolean; versions?: string[] } = {

src/registry/routes/plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Config } from '../../types';
33

44
export default function plugins(conf: Config) {
55
return (req: Request, res: Response): void => {
6-
if (conf.discovery) {
6+
if (res.conf.discovery) {
77
const plugins = Object.entries(conf.plugins).map(
88
([pluginName, pluginFn]) => ({
99
name: pluginName,

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ export interface VM {
116116
export interface Config {
117117
beforePublish: (req: Request, res: Response, next: NextFunction) => void;
118118
baseUrl: string;
119-
baseUrlFunc: (opts: { host?: string; secure: boolean }) => string;
119+
baseUrlFunc?: (opts: { host?: string; secure: boolean }) => string;
120120
discovery: boolean;
121-
discoveryFunc: (opts: { host?: string; secure: boolean }) => boolean;
121+
discoveryFunc?: (opts: { host?: string; secure: boolean }) => boolean;
122122
plugins: Record<string, (...args: unknown[]) => void>;
123123
local: boolean;
124124
tempDir: string;

0 commit comments

Comments
 (0)