SailsJs self is not defined in production.min.js - sails.js

I created a small Application using SailsJs Framework v1.2.3.
There is no issue in debug mode (sails lift). However when I lift the solution in production, the layout is displayed as well as pages with pure text (e.g. default FAQ page) but login page cannot be rendered (I still see the layout). My production is on port 80 at the moment as I'm trying to have a fully working production on my local machine before deploying it.
The browser console has the following error:
production.min.js:1 Uncaught ReferenceError: self is not defined
at production.min.js:1
at production.min.js:1
I'm using the following dependencies in my project, the rest is from the sails new project WebApp option.
"dependencies": {
"#sailshq/connect-redis": "^3.2.1",
"#sailshq/lodash": "^3.10.3",
"#sailshq/socket.io-redis": "^5.2.0",
"chart.js": "^2.9.3",
"csv-parser": "^2.3.2",
"sails": "^1.2.3",
"sails-hook-apianalytics": "^2.0.3",
"sails-hook-organics": "^0.16.0",
"sails-hook-orm": "^2.1.1",
"sails-hook-sockets": "^2.0.0",
"sails-hook-uploads": "^0.4.3"
},
Anyone could help me understanding what is wrong?

you may wanna take a look at .sailsrc the original file must be
"generators": {
"modules": {}
},
"_generatedWith": {
"sails": "1.2.3",
"sails-generate": "1.16.13"
}
}
last time i config this file to make another folder public and i have a same problem

Related

Amplify Flutter: How to connect to existing GraphQL endpoint

I'm implementing Amplify Flutter and want to connect it to our own custom GraphQL endpoint (i.e. non-AppSync). I am however having trouble getting it to work. The official documentation is not super-clear on this (at least not for those of us who are completely new to Amplify). What I have done:
In pubspec.yaml, I’ve added and installed the amplify_api package.
In main.dart, I’ve updated _configureAmplify() to add the AmplifyAPI() plugin.
In amplifyconfiguration.dart, I have manually added the following snippet:
"api": {
"plugins": {
"awsAPIPlugin": {
"xxxxxAPI": {
"endpointType": "GraphQL",
"endpoint": "http://xxxxxxxx.eba-fmuh2afu.eu-north-1.elasticbeanstalk.com/query",
"region": "[REGION]",
"authorizationType": "AMAZON_COGNITO_USER_POOLS"
}
}
}
}
But I keep getting the error "There is no API configured for this plugin with matching endpoint type." What am I doing wrong? (Note: I presume that I don't have to add any "region" value if I'm pointing to our own custom GraphQL endpoint).
I was able to fix this issue by closing the app and uninstalling it, then run again and log in to start fetching API

Consuming OData from Eclipse

I've been practicing SAPUI5 with the documentation but they use SAP Web IDE to consume OData services. However, because my company won't expose their server to the cloud, I can't use SAP Web IDE so I need to use eclipse. I need a tutorial step by step (for dummies) for consuming OData with SAPUI5 from eclipse. I already know how to create them but not how to use them from eclipse.
I use the OData service from Northwind but with SAP, I'll need credentials and other things.
"dataSources": {
"invoiceRemote": {
"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
[...] because they won't expose their server to the cloud, I can't use SAP Web IDE
An alternative to the clould based Web IDE is the Web IDE Personal Edition which you can deploy on your local machine but still runs in the browser (localhost). Create a corresponding destination file to connect to remote systems and the rest is pretty much the same as the old Orion-based Web IDE on the cloud.
Here is the destination file for the services from odata.org (e.g. Northwind)
Description=OData service from odata.org for testing, tutorials, demos, etc.
Type=HTTP
Authentication=NoAuthentication
WebIDEUsage=odata_gen
Name=odata_org
WebIDEEnabled=true
URL=http\://services.odata.org/
ProxyType=Internet
WebIDESystem=odata_org
Otherwise, if you want to stick with eclipse, take a look at the documentation topic
App Development Using SAPUI5 Tools for Eclipse
and its underlying topic Use a SimpleProxyServlet for Testing to
Avoid Cross-domain Requests
An exmaple using th OData of northwind: (this i made it in eclipse but the only differece with sap web ide personal edition (i haven't try this yet but it should work) you must configure the destination file for the services)
manifest.json
//between sap.app key you put this:
"dataSources": {
"mainService": {
"uri": "/northwind/V2/OData/OData.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
...
// this can be empty the if your using more than two just one can be empty
"": {
"dataSource": "mainService",
"preload": true
}
In my view that i'm going to use the data:
<List
id="list"
items="{
path: '/Categories',
sorter: {
path: 'Name',
descending: false
},
groupHeaderFactory: '.createGroupHeader'
}"
busyIndicatorDelay="{masterView>/delay}"
noDataText="{masterView>/noDataText}"
mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"
growing="true"
growingScrollToLoad="true"
updateFinished="onUpdateFinished"
selectionChange="onSelectionChange">
<infoToolbar>
<Toolbar
active="true"
id="filterBar"
visible="{masterView>/isFilterBarVisible}"
press="onOpenViewSettings">
<Title
id="filterBarLabel"
text="{masterView>/filterBarLabel}" />
</Toolbar>
</infoToolbar>
<items>
<ObjectListItem
type="Active"
press="onSelectionChange"
title="{Name}">
</ObjectListItem>
</items>
</List>
If you're going to use and odata made for you or consume just paste the url in the propertie "uri" of yo key dataSource (something like this: "https://proxy/name:port/sap/opu/odata/SAP/ZNAME_OF_YOUR_CREATED_ODATA_SRV" don't worry this url is you could see it when yo /IWFND/MAINT_SERVICE ) and when is already to deploy it just leave the uri like this /sap/opu/odata/SAP/ZNAME_OF_YOUR_CREATED_ODATA_SRV
I'll give you some lights, but not a full tutorial.
Working in eclipse is not that different from working with WEB IDE.
First you need to use JSONModel(). You can find reference here.
Create a JSONModel object and then use the method loadData.
For the sURL use (in your example):
"https://services.odata.org/V2/Northwind/Northwind.svc/?$format=json"
Then, you will have your oData in your front end. Now you just need to learn how to use it in your view elements. That you can learn it here.
If you want further explanations, please make small and specific questions, so it is easier to answer directed to your needs.

App works locally but not on Heroku (Application Error); Using Nodemon and Webpack

Alright, I've tried to look up my question on StackOverflow but I can't find something that helps me since everything I've tried doesn't have any effect on the result (Application error).
So I'm really stumped because the app works perfectly fine on my localhost, but I can't get it to work on Heroku, it just gives me a Application error so I have no idea what the issue is.
So on my package.JSON file looks like this:
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --use_strict index.js",
"bundle": "webpack"
},
And I've already tried to change "nodemon" to "node" and gotten rid of --use_strict and ran it on local host and it still works perfectly fine but the Heroku app still gives me a Application Error.
index.js the only thing that I can think of being bad (changed it and it runs here):
// start the server
app.listen(3000, () => {
console.log('Server is running.');
});
webpack.config.js:
const path = require('path');
module.exports = {
// the entry file for the bundle
entry: path.join(__dirname, '/client/src/app.jsx'),
// the bundle file we will get in the result
output: {
path: path.join(__dirname, '/client/dist/js'),
filename: 'app.js',
},
module: {
// apply loaders to files that meet given conditions
loaders: [{
test: /\.jsx?$/,
include: path.join(__dirname, '/client/src'),
loader: 'babel-loader',
query: {
presets: ["react", "es2015"]
}
}],
},
// start Webpack in a watch mode, so Webpack will rebuild the bundle on changes
watch: true
};
It deployed properly after git push heroku master:
https://c1.staticflickr.com/3/2873/33519283263_3d9a711311_z.jpg
I'm pretty much trying to make this app work on Heroku:
https://vladimirponomarev.com/blog/authentication-in-react-apps-creating-components
I think a possible problem might be that you have to run "run bundle" on one shell and "npm start" in the other shell.
Another thing, this app had a lot of things that were npm installed manually in node_modules, which Heroku does not accept if I try to push it on github and will crash, so I'm thinking that might be an issue as well, though I have no idea how to get around that.
This also uses Express and Mongodb, and I added my mongodb info into the index.json file and ran the application, and it worked perfectly fine and after checking the db, the correct info was also inside it, so it's not that either.
You should use process.env.PORT instead of custom port 3000.
Check that you have a mongodb addon purchased, you can get one for free but for limited spacing!
And use the config vars of that database, if you haven't done that already!

Extended application descriptor file and invalid datasource

I have two applications:
hrportalcore: The core application with BaseController, ...
hrportalrequestleave: A sample application extended from the hrportalcore application
The hrportalcore has the namespace de.example.core and there are the dataSources also maintained. (sap.app.dataSources in manifest.json). The datasource is:
[...]
"HRPOJavaLeave": {
"uri": "<path>",
"type": "OData",
"settings": {
"annotations": [],
"odataVersion": "2.0",
"localUri": ""
}
}
[...]
The datasources can be used without any problems in the extended application but the console brings the following errors:
It says the datasource contains errors, but it can be used (strange?).
Another thing is, that the Component-preload.js file is loaded from a wrong place once a time. The application works without problems, but it is - as said - loaded once from a wrong location?
My manifest.json of the hrportalrequestleave looks like in the extension part (sap.ui5.extends):
[...]
"extends": {
"component": "de.example.core",
"extensions": {}
},
[...]
The parent is defined rightly in the neo-app.json as /parent to show to hrportalcore.
jQuery.sap.declare("de.example.request.leave.Component");
// use the load function for getting the optimized preload file if present
if (!jQuery.sap.isDeclared("de.example.core.Component")) {
sap.ui.component.load({
name: "de.example.core",
// Use the below URL to run the extended application when SAP-delivered application is deployed on cloud
url: jQuery.sap.getModulePath("de.example.request.leave") + "/parent"
// we use a URL relative to our own component
// extension application is deployed with customer namespace
});
}
this.de.example.core.Component.extend("de.example.request.leave.Component", {
metadata: {
manifest: "json"
}
});
This all happens in the Fiori Launchpad of HANA Cloud Platform
Solution
manifest.json of hrportalcore: Always use the up-to-date version which you have deployed on your HCP in the applicationVersion property:
{
"_version": "1.2.0",
"sap.app": {
"_version": "1.2.0",
"applicationVersion": {
"version": "1.6.2"
},
...
manifest.json of hrportalrequestleave (Extension project): As above, always use the up-to-date version which you have deployed on your HCP in the applicationVersion property.
DataSource not found?!
If you have a extension project (like hrportalrequestleave < hrportalcore), then the manifest.json of both applications are merged like jQuery.extend(...). All properties, expect the sap.app tree, because it describes really the application and can not be copied from parent extension.
Now, when you use a dataSource from the parent extension, it will not be found. That means for you, you must define the sap.app.dataSources in the extension project manifest.json.
The error in the log
"Error in application dependency de.example.core.Component: No descriptor was found"
suggests that the manifest.json contains a dependency to "de.example.core.Component" instead of "de.example.core". According to your code snippets, the "extends" dependency is correct. Do you have other dependencies?
The AppIndex in the backend calculates the transitive closure of dependencies and if it can't find an installation with that ID, the above error is created and logged on the client side.
If your manifest.json looks okay but might have contained a wrong dependency in the past, then it might be necessary to re-run the AppIndex (or schedule it for a regular run).
The fact that the app works despite the config error is caused by the code that you've shown above. It explicitly loads the de.example.core component from an explicitly calculated URL. But before that step, the framework already tries to load it, based on the information in the manifest.json and there the information about the explicit URL is missing.
BTW: the code that calculates the URL suggests that even after fixing the manifest.json, the AppIndex might not find the component as it seems to be stored in a sub package of the de.example.request.leave app. Not sure if the AppIndex can handle this (it can handle nested components if they are listed as embedded components in the top level manifest.json, but I'm not sure if it recognizes such embedded components in the dependencies section. As a result it might try to load the embedded component although it has been loaded together with the enclosing component already.

typings.json - GitHub vs Registry

I'm used to Maven and trying to make sense of package management in this side of the world.
Could some one please help me understand the difference between:
This:
"ambientDependencies": {
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438"
}
and this:
{
"ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#5c182b9af717f73146399c2485f70f1e2ac0ff2b"
}
}
Is registry pointing to an npm repository?
Is there any difference and which is the preferred method?
I couldn't get registry:dt/es6-shim to work. Kept on getting following error(even though I configured my proxy settings):
https://api.typings.org/entries/dt/jasmine/tags/2.2.0%2B20160412134438
responded with 403, expected it to equal 200