File tree Expand file tree Collapse file tree 6 files changed +21
-10
lines changed Expand file tree Collapse file tree 6 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -133,5 +133,5 @@ jobs:
133
133
region : europe-west2
134
134
env_vars : |
135
135
MIMIC_PORT=8080
136
- MIMIC_MOCKS_DIRECTORY=/prefabs/shopfiy/mocks
137
- MIMIC_PARTIALS_DIRECTORY=/prefabs/shopfiy/partials
136
+ MIMIC_MOCKS_DIRECTORY=/app/ prefabs/shopfiy/mocks
137
+ MIMIC_PARTIALS_DIRECTORY=/app/ prefabs/shopfiy/partials
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ ADD server .
18
18
19
19
# Compile the main app so that it doesn't need to be compiled each startup/entry.
20
20
COPY --from=build-ui /app/dist /app/dashboard
21
- COPY prefabs /prefabs
21
+ COPY prefabs /app/
22
22
23
23
RUN deno compile --allow-sys \
24
24
--allow-net \
Original file line number Diff line number Diff line change @@ -2,11 +2,12 @@ import Engine from '../engine.ts';
2
2
import { createHandler as createMocksHandler } from './mocks.ts' ;
3
3
import { createHandler as createAPIHandler } from './api.ts' ;
4
4
import { createHandler as createDashboardHandler } from './dashboard.ts' ;
5
- import { logger } from '../deps.ts' ;
5
+ import { logger , MimicConfig } from '../deps.ts' ;
6
6
7
7
export interface HandlerOptions {
8
8
engine : Engine ;
9
9
cors ?: boolean ;
10
+ config : MimicConfig ;
10
11
}
11
12
12
13
export const createHandlers = ( opts : HandlerOptions ) => {
@@ -32,8 +33,8 @@ export const createHandlers = (opts: HandlerOptions) => {
32
33
return new Response ( ) ;
33
34
}
34
35
35
- else if ( url . pathname . includes ( 'status' ) ) {
36
- return new Response ( 'ok' )
36
+ if ( url . pathname . includes ( 'status' ) ) {
37
+ return new Response ( 'ok' ) ;
37
38
}
38
39
39
40
if ( url . pathname . startsWith ( '/_/api' ) ) {
@@ -44,6 +45,15 @@ export const createHandlers = (opts: HandlerOptions) => {
44
45
return dashboardHandler ( request ) ;
45
46
}
46
47
48
+ if ( url . pathname . startsWith ( '/_/config' ) ) {
49
+ return new Response ( JSON . stringify ( opts . config ) , {
50
+ status : 200 ,
51
+ headers : {
52
+ 'content-type' : 'application/json' ,
53
+ } ,
54
+ } ) ;
55
+ }
56
+
47
57
logger . info ( `${ request . method } - ${ request . url } ` ) ;
48
58
return mockHandler ( request ) ;
49
59
} ;
Original file line number Diff line number Diff line change 1
1
import { logger , MimicConfig , parse } from './deps.ts' ;
2
- import { startServers } from './start.ts' ;
2
+ import { startServer } from './start.ts' ;
3
3
4
4
const flags = parse ( Deno . args ) ;
5
5
@@ -36,7 +36,7 @@ const config: MimicConfig = {
36
36
} ;
37
37
38
38
logger . info ( '**** Mimic Server ****' ) ;
39
- startServers ( config ) ;
39
+ startServer ( config ) ;
40
40
41
41
Deno . addSignalListener ( 'SIGINT' , ( ) => {
42
42
logger . info ( 'Exited' ) ;
Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ const defaultConfig = {
9
9
mocksDirectory : 'mocks' ,
10
10
} ;
11
11
12
- export const startServers = async ( config : MimicConfig ) => {
12
+ export const startServer = async ( config : MimicConfig ) => {
13
13
const fullConfig = Object . assign ( { } , defaultConfig , config ) ;
14
14
const { tlsCertFile, tlsKeyFile, port } = fullConfig ;
15
15
const engine = await createMemoryEngine (
16
16
fullConfig ,
17
17
fullConfig . mocksDirectory ,
18
18
) ;
19
- const requestHandler = createHandlers ( { engine, cors : true } ) ;
19
+ const requestHandler = createHandlers ( { engine, cors : true , config } ) ;
20
20
const wsHandler = createWsHandler ( { storage : engine . storage } ) ;
21
21
22
22
await registerPartials ( fullConfig . partialsDirectory ) ;
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export class MemoryStorage implements RecordStorage {
112
112
const mocks : any [ ] = [ ] ;
113
113
try {
114
114
if ( ! fs . existsSync ( mocksDirectory ) ) {
115
+ logger . warning ( `${ mocksDirectory } not found. No mocks loaded` ) ;
115
116
return Promise . resolve ( [ ] ) ;
116
117
}
117
118
You can’t perform that action at this time.
0 commit comments