Related
I am currently using laravel-echo along with with pusher to set up my channel and broadcast however there seems to be some issues creating the listener onto the channel.
There should be a message on the pusher dashboard indicating that the channel is being listened to when the page is entered but nothing is being displayed
Initializing Echo Listener
$(document).ready(function() {
try{
window.Echo.channel('chat-room')
.listen('scannedQR', (e) => {
console.log("event has been triggered");
alert('event has been triggered');
});
alert('success');
}
catch(e){
console.log(e);
alert(e);
}
}
Bootstrap
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Lover = "LOVER!";
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'key',
// cluster: 'mt1',
cluster:'ap1',
encrypted: true
});
Echo Object -> console.log(JSON.safeStringify(window.Echo));
{
"options": {
"broadcaster": "pusher",
"key": key,
"cluster": cluster,
"encrypted": true
},
"connector": {
"_defaultOptions": {
"auth": {
"headers": {
"X-CSRF-TOKEN": "oIywz9kkxhVbl109qOqXMy0NVrUCR5AZlYR5apPc"
}
},
"authEndpoint": "/broadcasting/auth",
"userAuthentication": {
"endpoint": "/broadcasting/user-auth",
"headers": {
"X-CSRF-TOKEN": "oIywz9kkxhVbl109qOqXMy0NVrUCR5AZlYR5apPc"
}
},
"broadcaster": "pusher",
"csrfToken": null,
"host": null,
"key": key,
"namespace": "App.Events",
"cluster": "ap1",
"encrypted": true
},
"pusher": {
"key": key,
"config": {
"activityTimeout": 120000,
"cluster": "ap1",
"httpPath": "/pusher",
"httpPort": 80,
"httpsPort": 443,
"pongTimeout": 30000,
"statsHost": "stats.pusher.com",
"unavailableTimeout": 10000,
"wsPath": "",
"wsPort": 80,
"wssPort": 443,
"enableStats": false,
"httpHost": "sockjs-ap1.pusher.com",
"useTLS": true,
"wsHost": "ws-ap1.pusher.com"
},
"channels": {
"channels": {}
},
"global_emitter": {
"callbacks": {
"_callbacks": {}
},
"global_callbacks": []
},
"sessionID": 299457458,
"timeline": {
"key": key,
"session": 299457458,
"events": [
{
"instances": 1,
"timestamp": 1660358957487
},
{
"state": "connecting",
"timestamp": 1660358957538
},
{
"cached": true,
"transport": "xhr_streaming",
"latency": 410,
"timestamp": 1660358957539
},
{
"cid": 1,
"transport": "xhr_streamings",
"timestamp": 1660358957539
},
{
"cid": 1,
"state": "initialized",
"timestamp": 1660358957539
},
{
"cid": 1,
"state": "connecting",
"timestamp": 1660358957541
},
{
"cid": 1,
"state": "open",
"timestamp": 1660358957974
},
{
"state": "connected",
"params": {
"socket_id": "17356.8786996"
},
"timestamp": 1660358957976
}
],
"options": {
"cluster": cluster,
"features": [
"ws"
],
"params": {},
"limit": 50,
"level": 6,
"version": "7.3.0"
},
"sent": 0,
"uniqueID": 1
},
"connection": {
"callbacks": {
"_callbacks": {
"_connected": [
{},
{}
],
"_message": [
{},
{}
],
"_connecting": [
{},
{}
],
"_disconnected": [
{},
{}
],
"_error": [
{}
]
}
},
"global_callbacks": [],
"state": "connected",
"connection": {
"callbacks": {
"_callbacks": {
"_tls_only": [
{}
],
"_refused": [
{}
],
"_backoff": [
{}
],
"_retry": [
{}
],
"_message": [
{}
],
"_ping": [
{}
],
"_activity": [
{}
],
"_error": [
{}
],
"_closed": [
{}
]
}
},
"global_callbacks": [],
"id": "17356.8786996",
"transport": {
"callbacks": {
"_callbacks": {
"_error": [
{}
],
"_closed": [
{},
{}
],
"_message": [
{}
],
"_activity": [
{}
]
}
},
"global_callbacks": [],
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
},
"name": "xhr_streaming",
"priority": 1,
"key": key,
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
},
"state": "open",
"id": 1,
"socket": {
"hooks": {},
"session": "428/90n18c0a",
"location": {
"base": base,
"queryString": "?protocol=7&client=js&version=7.3.0"
},
"readyState": 1,
"stream": {
"callbacks": {
"_callbacks": {
"_chunk": [
{}
],
"_finished": [
{}
],
"_buffer_too_long": [
{}
]
}
},
"global_callbacks": [],
"hooks": {},
"method": "POST",
"url": url,
"position": 2188,
"xhr": {}
}
}
}
},
"key": key,
"options": {
"activityTimeout": 120000,
"pongTimeout": 30000,
"unavailableTimeout": 10000,
"useTLS": true
},
"usingTLS": true,
"errorCallbacks": {},
"connectionCallbacks": {},
"handshakeCallbacks": {},
"strategy": {
"strategy": {
"strategy": {
"trueBranch": {
"strategies": [
{
"strategies": [
{
"name": "ws",
"priority": 3,
"transport": {
"manager": {
"options": {
"lives": 2,
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"livesLeft": 2
},
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": false
}
},
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "ws-ap1.pusher.com:80",
"hostTLS": "ws-ap1.pusher.com:443",
"httpPath": ""
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
{
"strategy": {
"trueBranch": {
"strategies": [
{
"trueBranch": {
"strategies": [
{
"strategies": [
{
"trueBranch": {
"name": "xhr_streaming",
"priority": 1,
"transport": {
"manager": {
"options": {
"lives": 2,
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"livesLeft": 2
},
"transport": {},
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
},
"falseBranch": {
"name": "xdr_streaming",
"priority": 1,
"transport": {
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
}
},
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
{
"strategy": {
"strategies": [
{
"trueBranch": {
"name": "xhr_polling",
"priority": 1,
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
}
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
},
"falseBranch": {
"name": "xdr_polling",
"priority": 1,
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
}
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
"options": {
"delay": 4000
}
}
]
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
"falseBranch": {
"strategies": [
{
"name": "sockjs",
"priority": 1,
"transport": {
"hooks": {
"file": "sockjs",
"urls": {},
"handlesActivityChecks": true,
"supportsPing": false
}
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
}
},
"options": {
"delay": 2000
}
}
]
}
}
},
"transports": {
"wss": {
"name": "wss",
"priority": 3,
"transport": {
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "ws-ap1.pusher.com:80",
"hostTLS": "ws-ap1.pusher.com:443",
"httpPath": ""
}
}
},
"ttl": 1800000,
"usingTLS": true
},
"runner": null,
"unavailableTimer": {
"timer": null
},
"activityTimeout": 120000,
"activityTimer": {
"timer": 5
},
"socket_id": "17356.8786996"
},
"user": {
"callbacks": {
"_callbacks": {}
},
"global_callbacks": [],
"signin_requested": false,
"user_data": null,
"serverToUserChannel": null
}
},
"channels": {}
}
}
Pusher Dashboard doesn't show that channel is being listened to
EDIT
It currently shows on the pusher dashboard that the channel is being listened to but laravel-echo doesn't catch the event on the front end
I am using loadable for code splitting. The problem is all my files which are being used in more than one file are bundle into my initial bundle which is making it too large. Instead I want them to be included in my particular route bundle which is opened. How can I solve this?
I want my files to be included in route bundle only. I don't want any common bundle.
This is my webpack config
{
"cache": true,
"context": "/src/client",
"entry": {
"desktop": "./app.desktop.jsx",
"mobile": "./app.mobile.jsx"
},
"output": {
"path": "repo_name/dist/js",
"pathinfo": false,
"publicPath": "https://{url}/js/",
"chunkFilename": "[contenthash].[name].js",
"filename": "[name].bundle.[contenthash].js"
},
"resolve": {
"alias": {},
"symlinks": true,
"plugins": [{
"source": "module",
"nmPath": "node_modules",
"originDir": "repo_name/node_modules/electrode-archetype-react-app-dev",
"target": "resolve"
}],
"modules": [
"repo_name/src",
"repo_name",
"node_modules"
],
"extensions": [
".js",
".jsx",
".json"
]
},
"resolveLoader": {
"symlinks": true,
"modules": [
"repo_name/lib",
"repo_name"
],
"plugins": [{
"source": "module",
"nmPath": "node_modules",
"originDir": "repo_name/node_modules/electrode-archetype-react-app-dev",
"target": "resolve"
}]
},
"module": {
"rules": [{
"test": {},
"use": [{
"loader": "repo_name/node_modules/babel-loader/lib/index.js",
"options": {
"cacheDirectory": "repo_name/.etmp/babel-loader"
}
}]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/mini-css-extract-plugin/dist/loader.js",
"options": {
"hmr": false,
"reload": false,
"publicPath": "/js/"
}
},
{
"loader": "repo_name/node_modules/css-loader/index.js",
"options": {
"context": "repo_name/src",
"modules": true,
"localIdentName": "[hash:base64:5]"
}
},
{
"loader": "repo_name/node_modules/postcss-loader/src/index.js",
"options": {
"ident": "postcss"
}
}
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/mini-css-extract-plugin/dist/loader.js",
"options": {
"hmr": false,
"reload": false,
"publicPath": ""
}
},
{
"loader": "repo_name/node_modules/css-loader/index.js",
"options": {
"context": "repo_name/src",
"modules": true,
"localIdentName": "[hash:base64:5]"
}
},
{
"loader": "repo_name/node_modules/postcss-loader/src/index.js",
"options": {
"ident": "postcss"
}
},
{
"loader": "repo_name/node_modules/sass-loader/lib/loader.js"
}
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/mini-css-extract-plugin/dist/loader.js",
"options": {
"hmr": false,
"reload": false,
"publicPath": ""
}
},
{
"loader": "repo_name/node_modules/css-loader/index.js",
"options": {
"context": "repo_name/src",
"modules": true,
"localIdentName": "[hash:base64:5]"
}
},
{
"loader": "repo_name/node_modules/postcss-loader/src/index.js",
"options": {
"ident": "postcss"
}
},
{
"loader": "repo_name/node_modules/stylus-relative-loader/index.js"
}
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/url-loader/index.js",
"options": {
"limit": 1000,
"mimetype": "application/font-woff"
}
},
"repo_name/node_modules/isomorphic-loader/index.js"
]
},
{
"test": {},
"use": [
"repo_name/node_modules/file-loader/dist/cjs.js",
"repo_name/node_modules/isomorphic-loader/index.js"
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/electrode-cdn-file-loader/index.js",
"options": {
"limit": 10000
}
},
"repo_name/node_modules/isomorphic-loader/index.js"
]
}
]
},
"plugins": [{
"options": {
"filename": "[name].style.[contenthash].css",
"chunkFilename": "[name].style.[contenthash].css"
},
"__name": "MiniCssExtractPlugin"
},
{
"pluginDescriptor": {
"name": "OptimizeCssAssetsWebpackPlugin"
},
"options": {
"assetProcessors": [{
"phase": "compilation.optimize-chunk-assets",
"regExp": {}
}],
"assetNameRegExp": {},
"cssProcessorOptions": {
"zindex": false
},
"cssProcessorPluginOptions": {}
},
"phaseAssetProcessors": {
"compilation.optimize-chunk-assets": [{
"phase": "compilation.optimize-chunk-assets",
"regExp": {}
}],
"compilation.optimize-assets": [],
"emit": []
},
"deleteAssetsMap": {},
"__name": "OptimizeCssAssetsWebpackPlugin"
},
{
"options": {
"minimize": true,
"options": {
"context": "repo_name/src"
},
"test": {}
},
"__name": "LoaderOptionsPlugin"
},
{
"opts": {
"filename": "../server/stats.json",
"fields": [
"assetsByChunkName",
"assets",
"entrypoints",
"chunks"
]
},
"__name": "StatsWriterPlugin"
},
{
"config": {
"valid": false
},
"options": {
"assetsFile": "../isomorphic-assets.json",
"configFile": "repo_name/.isomorphic-loader-config.json",
"webpackDev": {
"url": "http://localhost:2992",
"addUrl": false
}
},
"__name": "IsomorphicLoaderPlugin"
},
{
"opts": {
"filename": "../server/loadable-stats.json",
"outputAsset": true
},
"compiler": null,
"__name": "LoadablePlugin"
},
{
"resourceRegExp": {},
"newContentRegExp": {},
"__name": "ContextReplacementPlugin"
},
{
"sourceMapFilename": "../map/[file].map",
"sourceMappingURLComment": "\n//# sourceMappingURL=/map/[url]",
"moduleFilenameTemplate": "webpack://[namespace]/[resourcePath]",
"fallbackModuleFilenameTemplate": "webpack://[namespace]/[resourcePath]?[hash]",
"namespace": "",
"options": {
"filename": "../map/[file].map",
"append": "\n//# sourceMappingURL=/map/[url]"
},
"__name": "SourceMapDevToolPlugin"
},
{
"isWatch": true,
"__name": "FailPlugin"
},
{
"__name": "DonePlugin"
},
{
"opts": {
"analyzerMode": "server",
"analyzerHost": "127.0.0.1",
"analyzerPort": 8888,
"reportFilename": "report.html",
"defaultSizes": "parsed",
"openAnalyzer": true,
"generateStatsFile": false,
"statsFilename": "stats.json",
"statsOptions": null,
"excludeAssets": null,
"logLevel": "info",
"startAnalyzer": true
},
"server": null,
"logger": {
"activeLevels": {}
}
},
{
"options": {},
"timeEventData": {},
"smpPluginAdded": true
}
],
"mode": "production",
"optimization": {
"splitChunks": {
"cacheGroups": {
"node_vendors": {
"name": "node_vendor",
"test": {},
"chunks": "initial",
"priority": 1
},
"sentry": {
"name": "sentry",
"test": {},
"chunks": "all",
"priority": 10
}
}
}
}
}
I'm trying to generate the auto update files to upload to a server. After signing and notarizing I expect the latest.yml file to be there but it's not. Not sure what I'm missing. This is the package.json build section I'm using. (electron-builder version: 22.8.1)
"build": {
"appId": "com.myorg.myapp",
"productName": "Product name",
"copyright": "",
"afterSign": "./scripts/notarize.js",
"afterAllArtifactBuild": "./scripts/afterAllArtifactBuildHook.js",
"mac": {
"category": "public.app-category.productivity",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "assets/entitlements.plist",
"entitlementsInherit": "assets/entitlements.plist",
"publish": {
"provider": "generic",
"url": "https://some-url/",
"publishAutoUpdate": true,
"channel": "latest"
},
"target": [
"zip",
"dmg"
]
},
"win": {
"icon": "assets/icon.ico",
"publish": {
"provider": "generic",
"url": "https://some-url/",
"publishAutoUpdate": true,
"channel": "latest"
},
"target": [
"nsis",
"zip"
]
},
"dmg": {
"sign": true
},
"files": [
"build/**/*",
"node_modules/**/*",
"system/**/*"
],
"directories": {
"buildResources": "assets"
},
"fileAssociations": [
{
"ext": "diagram",
"name": "Diagram.codes Project",
"mimeType": "application/json",
"role": "Editor"
}
]
},
I am trying to create a SAM template (serverless.template) in visual studio to publish my API Gateway. I have a couple of errors being produced within the template validation (in Visual Studio) that I'm unable to resolve. When published, the stack deploys, but there is no usage plan(s) or api key(s) created (or rather, they are created but not viewable in the console, they come up as 'invalid reference' if you try to view them via Cloudformation > Resources, and they don't show up at all in the API Gateway console).
The errors are:
ServerlessRestApiDeployment26aad1646f is an unknown reference
"ServerlessRestApiProdStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"DeploymentId": {
"Ref": "ServerlessRestApiDeployment26aad1646f"
},
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"StageName": "Prod"
}
},
And
ServerlessRestApiProdStage is an invalid type for this reference
"APIGatewayHeartInHandKey": {
"Type": "AWS::ApiGateway::ApiKey",
"DependsOn": [
"ServerlessRestApi",
"ServerlessRestApiProdStage"
],
"Properties": {
"Name": "HeartInHandApiKey",
"Description": "Api Key for Heart In Hand",
"Enabled": true,
"GenerateDistinctId": true,
"StageKeys": [
{
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"StageName": {
"Ref": "ServerlessRestApiProdStage"
}
}
]
}
},
The full SAM template shown below.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Description": "API Gateway to access InSite data-store",
"Resources": {
"Get": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::Get",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/",
"Method": "GET"
}
}
}
}
},
"GetTableBasic": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::GetTableBasic",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/tables/{tableid}/{columnid}",
"Method": "GET"
}
}
}
}
},
"GetColumnList": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::GetColumnList",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/list/columns/{tableid}",
"Method": "GET"
}
}
}
}
},
"GetTableList": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::GetTableList",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/list/tables",
"Method": "GET"
}
}
}
}
},
"PostClickCollectNotification": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::PostClickCollectNotification",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/datagw/general/webhook/ccnotify",
"Method": "POST"
}
}
}
}
},
"PostClickCollectStockUpdate": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::PostClickCollectStockUpdate",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/datagw/general/post/sohupdate",
"Method": "POST"
}
}
}
}
},
"GetTableResponse": {
"Type": "AWS::Serverless::Function",
"Properties": {
"VpcConfig": {
"SecurityGroupIds": [
"sg-111a1476"
],
"SubnetIds": [
"subnet-3029a769",
"subnet-5ec0b928"
]
},
"Handler": "AWSServerlessInSiteDataGw::AWSServerlessInSiteDataGw.Functions::GetTableResponse",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [
"AWSLambdaBasicExecutionRole",
"AWSLambdaVPCAccessExecutionRole",
"AmazonSSMFullAccess"
],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "datagw/general/table/get/{tableid}",
"Method": "GET"
}
}
}
}
},
"ServerlessRestApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Description":"This is a placeholder for the description of this web api",
"ApiKeySourceType":"HEADER",
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
}
},
"paths": {
"/list/tables": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetTableList.Arn}/invocations"
}
},
"responses": {}
}
},
"/list/columns/{tableid}": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetColumnList.Arn}/invocations"
}
},
"responses": {}
}
},
"datagw/general/table/get/{tableid}": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetTableResponse.Arn}/invocations"
}
},
"responses": {}
}
},
"/": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Get.Arn}/invocations"
}
},
"responses": {}
}
},
"/tables/{tableid}/{columnid}": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetTableBasic.Arn}/invocations"
}
},
"responses": {}
}
}
},
"swagger": "2.0"
}
}
},
"ServerlessRestApiProdStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"DeploymentId": {
"Ref": "ServerlessRestApiDeployment26aad1646f"
},
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"StageName": "Prod"
}
},
"CustomLambdaExecutionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Policies": [
{
"PolicyName": "lambdaAccessApiKeys",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"apigateway:GET"
],
"Resource": {
"Fn::Sub": [
"arn:aws:apigateway:ap-southeast-2::/apikeys/${__keyId__}",
{
"__keyId__": {
"Ref": "APIGatewayHeartInHandKey"
}
}
]
}
}
]
}
}
]
}
},
"GetApiKeyValueLambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": {
"Fn::Join": [
"\n",
[
"import json",
"import boto3",
"client = boto3.client('apigateway')",
"def lambda_handler(event, context):",
" response = client.get_api_key(",
" apiKey= event['apiKeyId'],",
" includeValue = True",
")",
" return {",
" 'statusCode': 200,",
" 'body': response['value']}"
]
]
}
},
"Handler": "index.lambda_handler",
"Runtime": "python3.6",
"Timeout": 30,
"Role": {
"Fn::GetAtt": [
"CustomLambdaExecutionRole",
"Arn"
]
}
}
},
"APIGatewayUsagePlanInternal": {
"Type": "AWS::ApiGateway::UsagePlan",
"Properties": {
"ApiStages": [
{
"ApiId": {
"Ref": "ServerlessRestApi"
},
"Stage": {
"Ref": "ServerlessRestApiProdStage"
}
}
],
"Description": "Internal Apps Usage Plan",
"UsagePlanName": "Insite-datagw-InternalAppPlan"
}
},
"APIGatewayUsagePlanExternal": {
"Type": "AWS::ApiGateway::UsagePlan",
"Properties": {
"ApiStages": [
{
"ApiId": {
"Ref": "ServerlessRestApi"
},
"Stage": {
"Ref": "ServerlessRestApiProdStage"
}
}
],
"Description": "External Apps Usage Plan",
"UsagePlanName": "InSite-datagw-ExternalAppPlan"
}
},
"APIGatewayHeartInHandKey": {
"Type": "AWS::ApiGateway::ApiKey",
"DependsOn": [
"ServerlessRestApi",
"ServerlessRestApiProdStage"
],
"Properties": {
"Name": "HeartInHandApiKey",
"Description": "Api Key for Heart In Hand",
"Enabled": true,
"GenerateDistinctId": true,
"StageKeys": [
{
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"StageName": {
"Ref": "ServerlessRestApiProdStage"
}
}
]
}
},
"LinkHeartInHandKey": {
"Type": "AWS::ApiGateway::UsagePlanKey",
"Properties": {
"KeyId": {
"Ref": "APIGatewayHeartInHandKey"
},
"KeyType": "API_KEY",
"UsagePlanId": {
"Ref": "APIGatewayUsagePlanInternal"
}
}
},
"APIGatewayPricelineSiteKey": {
"Type": "AWS::ApiGateway::ApiKey",
"DependsOn": [
"ServerlessRestApi",
"ServerlessRestApiProdStage"
],
"Properties": {
"Name": "PricelineSiteApiKey",
"Description": "Api Key for Priceline Website",
"Enabled": true,
"GenerateDistinctId": true,
"StageKeys": [
{
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"StageName": {
"Ref": "ServerlessRestApiProdStage"
}
}
]
}
},
"LinkPricelineSiteKey": {
"Type": "AWS::ApiGateway::UsagePlanKey",
"Properties": {
"KeyId": {
"Ref": "APIGatewayPricelineSiteKey"
},
"KeyType": "API_KEY",
"UsagePlanId": {
"Ref": "APIGatewayUsagePlanInternal"
}
}
}
},
"Outputs": {
"ApiURL": {
"Description": "API endpoint URL for Prod environment",
"Value": {
"Fn::Sub": "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
}
}
}
}
it looks like you're trying to use features of the AWS::Serverless::Api resource from SAM without defining an AWS::Serverless::Api in your template.
In order to fix the issues you've brought up, it looks like you need to:
Remove the ServerlessRestApiProdStage resource
Sam will generate this resource (and the deployment resource) for you if you use an AWS::Serverless::Api resource.
Convert your AWS::ApiGateway::RestApi resource into an AWS::Serverless::Api resource:
Remove ApiKeySourceType property and add "x-amazon-apigateway-api-key-source" : "HEADER", to the swagger,
Change the Type from AWS::ApiGateway::RestApi to AWS::Serverless::Api
"ServerlessRestApi": {
"Type": "AWS::Serverless::RestApi",
"Properties": {
"Description":"This is a placeholder for the description of this web api",
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
}
},
"x-amazon-apigateway-api-key-source" : "HEADER",
"paths": {
...
Find below my json data and suggest me how to print the tld using foreach loop in laravel. Suggest me how to declare this array structure using foreach loop.
{
"result": "success",
"currency": {
"id": "1",
"code": "INR",
"prefix": " \u20b9",
"suffix": "INR",
"format": "1",
"rate": "1.00000"
},
"pricing": {
"in": {
"categories": [
"ccTLD",
"Geography"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "704.39"
},
"transfer": {
"1": "704.39"
},
"renew": {
"1": "704.39"
}
},
"in.net": {
"categories": [
"Other"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "547.69"
},
"transfer": {
"1": "547.69"
},
"renew": {
"1": "547.69"
}
},
"info": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "861.10"
},
"transfer": {
"1": "861.10"
},
"renew": {
"1": "861.10"
}
},
"org": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "939.45"
},
"transfer": {
"1": "939.45"
},
"renew": {
"1": "939.45"
}
},
"com": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "740.43"
},
"transfer": {
"1": "740.43"
},
"renew": {
"1": "740.43"
}
},
"net": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "829.76"
},
"transfer": {
"1": "829.76"
},
"renew": {
"1": "829.76"
}
},
"biz": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "878.33"
},
"transfer": {
"1": "878.33"
},
"renew": {
"1": "878.33"
}
}
}
}
From the above data I wanted to display the tlds such as in,in.net,org,info,com,net,biz.
Use this:
$tlds = array_keys(json_decode($json, true)['pricing']);