-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample.js
More file actions
60 lines (49 loc) · 1.45 KB
/
example.js
File metadata and controls
60 lines (49 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Example usage of the Shopify App Bridge Mock
*
* Run this example:
* 1. First build the package: pnpm build
* 2. Run the example: node example.js
* 3. Open http://localhost:3080 in your browser
*/
const { MockShopifyAdminServer } = require('./dist');
async function runExample() {
console.log('Starting Mock Shopify Admin Server...\n');
// Configure the mock server
const mockServer = new MockShopifyAdminServer({
// Your app's URL
appUrl: 'http://localhost:3044',
appPath: '/shopify', // Path where your app handles Shopify requests
// Mock development credentials
clientId: 'mock-dev-client',
clientSecret: 'mock-dev-secret-12345',
// Mock shop
shop: 'test-store.myshopify.com',
port: 3080,
debug: true,
});
// Start the server
await mockServer.start();
console.log(`
🎉 Mock Shopify Admin is running!
=================================
🌐 Open: http://localhost:3080
🎯 Embedding: http://localhost:3044/shopify
Your app should:
• Be running at http://localhost:3044
• Handle the /shopify route for embedded mode
• Use App Bridge for authentication
Press Ctrl+C to stop the server.
`);
// Keep the server running
process.on('SIGINT', async () => {
console.log('\n\nStopping Mock Shopify Admin Server...');
await mockServer.stop();
process.exit(0);
});
}
// Run the example
runExample().catch(error => {
console.error('Error:', error);
process.exit(1);
});