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:
133133 region : europe-west2
134134 env_vars : |
135135 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 .
1818
1919# Compile the main app so that it doesn't need to be compiled each startup/entry.
2020COPY --from=build-ui /app/dist /app/dashboard
21- COPY prefabs /prefabs
21+ COPY prefabs /app/
2222
2323RUN deno compile --allow-sys \
2424 --allow-net \
Original file line number Diff line number Diff line change @@ -2,11 +2,12 @@ import Engine from '../engine.ts';
22import { createHandler as createMocksHandler } from './mocks.ts' ;
33import { createHandler as createAPIHandler } from './api.ts' ;
44import { createHandler as createDashboardHandler } from './dashboard.ts' ;
5- import { logger } from '../deps.ts' ;
5+ import { logger , MimicConfig } from '../deps.ts' ;
66
77export interface HandlerOptions {
88 engine : Engine ;
99 cors ?: boolean ;
10+ config : MimicConfig ;
1011}
1112
1213export const createHandlers = ( opts : HandlerOptions ) => {
@@ -32,8 +33,8 @@ export const createHandlers = (opts: HandlerOptions) => {
3233 return new Response ( ) ;
3334 }
3435
35- else if ( url . pathname . includes ( 'status' ) ) {
36- return new Response ( 'ok' )
36+ if ( url . pathname . includes ( 'status' ) ) {
37+ return new Response ( 'ok' ) ;
3738 }
3839
3940 if ( url . pathname . startsWith ( '/_/api' ) ) {
@@ -44,6 +45,15 @@ export const createHandlers = (opts: HandlerOptions) => {
4445 return dashboardHandler ( request ) ;
4546 }
4647
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+
4757 logger . info ( `${ request . method } - ${ request . url } ` ) ;
4858 return mockHandler ( request ) ;
4959 } ;
Original file line number Diff line number Diff line change 11import { logger , MimicConfig , parse } from './deps.ts' ;
2- import { startServers } from './start.ts' ;
2+ import { startServer } from './start.ts' ;
33
44const flags = parse ( Deno . args ) ;
55
@@ -36,7 +36,7 @@ const config: MimicConfig = {
3636} ;
3737
3838logger . info ( '**** Mimic Server ****' ) ;
39- startServers ( config ) ;
39+ startServer ( config ) ;
4040
4141Deno . addSignalListener ( 'SIGINT' , ( ) => {
4242 logger . info ( 'Exited' ) ;
Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ const defaultConfig = {
99 mocksDirectory : 'mocks' ,
1010} ;
1111
12- export const startServers = async ( config : MimicConfig ) => {
12+ export const startServer = async ( config : MimicConfig ) => {
1313 const fullConfig = Object . assign ( { } , defaultConfig , config ) ;
1414 const { tlsCertFile, tlsKeyFile, port } = fullConfig ;
1515 const engine = await createMemoryEngine (
1616 fullConfig ,
1717 fullConfig . mocksDirectory ,
1818 ) ;
19- const requestHandler = createHandlers ( { engine, cors : true } ) ;
19+ const requestHandler = createHandlers ( { engine, cors : true , config } ) ;
2020 const wsHandler = createWsHandler ( { storage : engine . storage } ) ;
2121
2222 await registerPartials ( fullConfig . partialsDirectory ) ;
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export class MemoryStorage implements RecordStorage {
112112 const mocks : any [ ] = [ ] ;
113113 try {
114114 if ( ! fs . existsSync ( mocksDirectory ) ) {
115+ logger . warning ( `${ mocksDirectory } not found. No mocks loaded` ) ;
115116 return Promise . resolve ( [ ] ) ;
116117 }
117118
You can’t perform that action at this time.
0 commit comments