Skip to content

Commit 175cfe9

Browse files
merge master
2 parents a3d8f04 + f5113a0 commit 175cfe9

21 files changed

+97
-61
lines changed

src/registry/domain/authentication.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import basicAuth from 'basic-auth-connect';
2+
import { RequestHandler } from 'express';
23
import path from 'path';
34

45
import strings from '../../resources/';
56

67
type Validate<T = unknown> = (
78
config: T
8-
) => { isValid: boolean; message: string };
9+
) => {
10+
isValid: boolean;
11+
message: string;
12+
};
913
type Middleware<T> = (config: T) => any;
1014

1115
type Authentication<T = any> = {
@@ -63,6 +67,6 @@ export function validate(authConfig: { type: string }) {
6367
return scheme.validate(authConfig);
6468
}
6569

66-
export function middleware(authConfig: any) {
70+
export function middleware(authConfig: unknown): RequestHandler {
6771
return scheme.middleware(authConfig);
6872
}

src/registry/domain/events-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import strings from '../../resources';
33
type Subscription<T = any> = (data: T) => void;
44
let subscriptions: Record<string, Array<Subscription>> = {};
55

6-
export function fire(eventName: string, eventData: any): void {
6+
export function fire(eventName: string, eventData: unknown): void {
77
if (subscriptions[eventName]) {
88
subscriptions[eventName].forEach(callback => {
99
callback(eventData);

src/registry/domain/require-wrapper.js renamed to src/registry/domain/require-wrapper.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
'use strict';
1+
import coreModules from 'builtin-modules';
2+
import path from 'path';
3+
import requirePackageName from 'require-package-name';
4+
import tryRequire from 'try-require';
5+
import _ from 'lodash';
26

3-
const coreModules = require('builtin-modules');
4-
const path = require('path');
5-
const requirePackageName = require('require-package-name');
6-
const tryRequire = require('try-require');
7-
const _ = require('lodash');
7+
import strings from '../../resources';
88

9-
const strings = require('../../resources').default;
10-
11-
const isCoreDependency = x => _.includes(coreModules, x);
12-
const requireCoreDependency = x =>
9+
const isCoreDependency = (x: string) => _.includes(coreModules, x);
10+
const requireCoreDependency = (x: string) =>
1311
(isCoreDependency(x) && tryRequire(x)) || undefined;
1412

15-
const requireDependency = requirePath => {
13+
const requireDependency = (requirePath: string) => {
1614
const nodeModulesPath = path.resolve('.', 'node_modules');
1715
const modulePath = path.resolve(nodeModulesPath, requirePath);
1816
return tryRequire(modulePath);
1917
};
2018

21-
const throwError = requirePath => {
19+
const throwError = (requirePath: string) => {
2220
throw {
2321
code: strings.errors.registry.DEPENDENCY_NOT_FOUND_CODE,
2422
missing: [requirePath]
2523
};
2624
};
2725

28-
module.exports = injectedDependencies => requirePath => {
26+
export default (injectedDependencies: string[]) => <T = unknown>(
27+
requirePath: string
28+
): T => {
2929
const moduleName = requirePackageName(requirePath);
3030
const isAllowed = _.includes(injectedDependencies, moduleName);
3131

src/registry/domain/url-builder.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ function componentForType(
2727
return href;
2828
}
2929

30-
export function component(component: Component | string, baseUrl: string) {
30+
export function component(
31+
component: Component | string,
32+
baseUrl: string
33+
): string {
3134
if (typeof component === 'string') {
3235
component = { name: component };
3336
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default function baseUrlHandler(
44
req: Request,
55
res: Response,
66
next: NextFunction
7-
) {
7+
): void {
88
res.conf.baseUrlFunc =
99
res.conf.baseUrlFunc ||
1010
(typeof res.conf.baseUrl === 'function' ? res.conf.baseUrl : undefined);

src/registry/middleware/cors.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextFunction, Request, Response } from 'express';
22

3-
export default function cors(req: Request, res: Response, next: NextFunction) {
3+
export default function cors(
4+
req: Request,
5+
res: Response,
6+
next: NextFunction
7+
): void {
48
res.removeHeader('X-Powered-By');
59
res.header('Access-Control-Allow-Credentials', 'true');
610
res.header('Access-Control-Allow-Origin', '*');

src/registry/middleware/discovery-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default function discoveryHandler(
44
req: Request,
55
res: Response,
66
next: NextFunction
7-
) {
7+
): void {
88
res.conf.discoveryFunc =
99
res.conf.discoveryFunc ||
1010
(typeof res.conf.discovery === 'function' ? res.conf.discovery : undefined);

src/registry/middleware/file-uploads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function fileUpload(
55
req: Request,
66
res: Response,
77
next: NextFunction
8-
) {
8+
): void {
99
if (res.conf.local) {
1010
return next();
1111
}

src/registry/middleware/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const bodyParserUrlEncodedArgument: { extended: boolean; limit?: number } = {
1717
extended: true
1818
};
1919

20-
export const bind = (app: Express, options: Config) => {
20+
export const bind = (app: Express, options: Config): Express => {
2121
app.set('port', options.port);
2222
app.set('json spaces', 0);
2323

src/registry/middleware/request-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Request, Response } from 'express';
1+
import { Request, RequestHandler, Response } from 'express';
22
import { IncomingHttpHeaders } from 'http';
33
import responseTime from 'response-time';
44

@@ -18,7 +18,7 @@ interface ResponseTimeData {
1818
errorCode?: string;
1919
}
2020

21-
export default function requestHandler() {
21+
export default function requestHandler(): RequestHandler {
2222
return responseTime((req: Request, res: Response, time) => {
2323
const data: ResponseTimeData = {
2424
body: req.body,

0 commit comments

Comments
 (0)