@@ -2,7 +2,7 @@ import { PluginLoader } from '../plugin';
2
2
import { Action } from './actions' ;
3
3
import * as proc from './processors' ;
4
4
5
- const pushActionChain = [
5
+ const pushActionChain : ( ( req : any , action : Action ) => Promise < Action > ) [ ] = [
6
6
proc . push . parsePush ,
7
7
proc . push . checkRepoInAuthorisedList ,
8
8
proc . push . checkCommitMessages ,
@@ -18,19 +18,17 @@ const pushActionChain = [
18
18
proc . push . blockForAuth ,
19
19
] ;
20
20
21
- const pullActionChain = [ proc . push . checkRepoInAuthorisedList ] ;
21
+ const pullActionChain : ( ( req : any , action : Action ) => Promise < Action > ) [ ] = [ proc . push . checkRepoInAuthorisedList ] ;
22
22
23
23
let pluginsInserted = false ;
24
24
25
25
export const executeChain = async ( req : any , res : any ) : Promise < Action > => {
26
26
let action : Action ;
27
27
try {
28
28
action = await proc . pre . parseAction ( req ) ;
29
- const actions = await getChain ( action ) ;
30
- for ( const i in actions ) {
31
- if ( ! i ) continue ;
32
- const fn = actions [ i as any ] ;
29
+ const actionFns = await getChain ( action ) ;
33
30
31
+ for ( const fn of actionFns ) {
34
32
action = await fn ( req , action ) ;
35
33
if ( ! action . continue ( ) ) {
36
34
return action ;
@@ -53,7 +51,7 @@ export const executeChain = async (req: any, res: any): Promise<Action> => {
53
51
*/
54
52
let chainPluginLoader : PluginLoader ;
55
53
56
- const getChain = async ( action : Action ) => {
54
+ const getChain = async ( action : Action ) : Promise < ( ( req : any , action : Action ) => Promise < Action > ) [ ] > => {
57
55
if ( chainPluginLoader === undefined ) {
58
56
console . error (
59
57
'Plugin loader was not initialized! This is an application error. Please report it to the GitProxy maintainers. Skipping plugins...' ,
@@ -77,13 +75,9 @@ const getChain = async (action: Action) => {
77
75
// This is set to true so that we don't re-insert the plugins into the chain
78
76
pluginsInserted = true ;
79
77
}
80
- if ( action . type === 'pull' ) {
81
- return pullActionChain ;
82
- }
83
- if ( action . type === 'push' ) {
84
- return pushActionChain ;
85
- }
86
- if ( action . type === 'default' ) return [ ] ;
78
+ if ( action . type === 'pull' ) return pullActionChain ;
79
+ if ( action . type === 'push' ) return pushActionChain ;
80
+ return [ ] ;
87
81
} ;
88
82
89
83
export default {
0 commit comments