@@ -10,7 +10,7 @@ const {
1010 deleteModels,
1111 initCache,
1212 getConfig,
13- http
13+ http,
1414} = controllers
1515
1616const { close, find, save } = storageAdapter
@@ -22,22 +22,13 @@ import ModelFactory from '../../src/domain'
2222const apiRoot = process . env . API_ROOT || '/aegis/api'
2323const modelPath = `${ apiRoot } /models`
2424
25- const idRoute = route =>
26- route
27- . split ( '/' )
28- . splice ( 0 , 5 )
29- . concat ( [ ':id' ] )
30- . join ( '/' )
25+ const idRoute = route => route . split ( '/' ) . splice ( 0 , 5 ) . concat ( [ ':id' ] ) . join ( '/' )
3126
3227const cmdRoute = route =>
33- route
34- . split ( '/' )
35- . splice ( 0 , 6 )
36- . concat ( [ ':id' , ':command' ] )
37- . join ( '/' )
28+ route . split ( '/' ) . splice ( 0 , 6 ) . concat ( [ ':id' , ':command' ] ) . join ( '/' )
3829
3930class RouteMap extends Map {
40- has ( route ) {
31+ has ( route ) {
4132 if ( ! route ) {
4233 console . warn ( 'route is ' , typeof route )
4334 return false
@@ -62,7 +53,7 @@ class RouteMap extends Map {
6253 return false
6354 }
6455
65- get ( route ) {
56+ get ( route ) {
6657 return this . route ? this . route : super . get ( route )
6758 }
6859}
@@ -93,7 +84,7 @@ const Server = (() => {
9384 * @param {* } method
9485 * @param {* } controllers
9586 */
96- webserver ( path , method , controllers , app ) {
87+ webserver ( path , method , controllers , app ) {
9788 controllers ( ) . forEach ( ctlr => {
9889 console . info ( ctlr )
9990 app [ method ] ( path ( ctlr . endpoint ) , http ( ctlr . fn ) )
@@ -106,22 +97,22 @@ const Server = (() => {
10697 * @param {* } method
10798 * @param {* } controllers
10899 */
109- serverless ( path , method , controllers ) {
100+ serverless ( path , method , controllers ) {
110101 controllers ( ) . forEach ( ctlr => {
111102 const route = path ( ctlr . endpoint )
112103 if ( routes . has ( route ) ) {
113104 routes . set ( route , {
114105 ...routes . get ( route ) ,
115- [ method ] : http ( ctlr . fn )
106+ [ method ] : http ( ctlr . fn ) ,
116107 } )
117108 return
118109 }
119110 routes . set ( route , { [ method ] : http ( ctlr . fn ) } )
120111 } )
121- }
112+ } ,
122113 }
123114
124- function makeAdmin ( app , adapter , serverMode ) {
115+ function makeAdmin ( app , adapter , serverMode ) {
125116 if ( serverMode === make . webserver . name ) {
126117 app . get ( `${ apiRoot } /config` , adapter ( getConfig ( ) ) )
127118 } else if ( serverMode === make . serverless . name ) {
@@ -132,7 +123,7 @@ const Server = (() => {
132123 /**
133124 * Call controllers directly in serverless mode.
134125 */
135- async function invoke ( path , method , req , res ) {
126+ async function invoke ( path , method , req , res ) {
136127 if ( routes . has ( path ) ) {
137128 try {
138129 console . debug ( 'path match: ' , path )
@@ -149,7 +140,7 @@ const Server = (() => {
149140 console . warn ( 'potential config issue' , path , method )
150141 }
151142
152- function shutdown ( shutdownTasks ) {
143+ function shutdown ( shutdownTasks ) {
153144 console . warn ( 'Received SIGTERM - system shutdown in progress' )
154145 shutdownTasks ( )
155146 }
@@ -161,7 +152,7 @@ const Server = (() => {
161152 * user code downloaded from the remote. This is
162153 * the code that needs to be disposed of & reimported.
163154 */
164- function clear ( ) {
155+ function clear ( ) {
165156 try {
166157 close ( )
167158 routes . clear ( )
@@ -186,7 +177,7 @@ const Server = (() => {
186177 * @param {boolean } serverless - set to true if running as a servless function
187178 * @returns
188179 */
189- async function start ( router , serverless = false ) {
180+ async function start ( router , serverless = false ) {
190181 const serverMode = serverless ? make . serverless . name : make . webserver . name
191182 const overrides = { save, find, Persistence }
192183
@@ -222,7 +213,7 @@ const Server = (() => {
222213 return {
223214 clear,
224215 start,
225- invoke
216+ invoke,
226217 }
227218} ) ( )
228219
0 commit comments