Can anyone please help me install keystone.js on my openshift app?
I've pushed all my files to the remote, but get a 503 error when I browse to my page. I'm quite new to Openshift, can anyone please point me in the right direction?
I have tried changing keystone.init to:
var connectionString = process.env.OPENSHIFT_MONGODB_DB_USERNAME + ":" + process.env.OPENSHIFT_MONGODB_DB_PASSWORD + "#" + process.env.OPENSHIFT_MONGODB_DB_HOST + dbName;
console.log(connectionString);
keystone.set('mongo', connectionString);
keystone.init({
'mongo': connectionString,
Still no joy, I dont get any console errors either.
Any advice much appreciated.
UPDATE: checked logs and found the following:
SyntaxError: Unexpected end of input
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/5501b0c04382ecfefe0000a2/app-root/runtime/repo/node_modules/keystone/index.js:3:6)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
DEBUG: Program node keystone.js exited with code 8
DEBUG: Starting child process with 'node keystone.js'
hit me
/var/lib/openshift/5501b0c04382ecfefe0000a2/app-root/runtime/repo/node_modules/underscore/underscore.js:561
});
SyntaxError: Unexpected end of input
at Module._compile (module.js:439:25)
Keystone.js
// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
// Require keystone
var keystone = require('keystone');
// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.
var dbName = "node";
var connectionString = process.env.OPENSHIFT_MONGODB_DB_USERNAME + ":" + process.env.OPENSHIFT_MONGODB_DB_PASSWORD + "#" + process.env.OPENSHIFT_MONGODB_DB_HOST + dbName;
console.log(connectionString);
keystone.set('mongo', connectionString);
keystone.init({
'mongo': connectionString,
'name': 'node',
'brand': 'node',
'sass': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'jade',
'auto update': true,
'session': true,
'auth': true,
'user model': 'User',
'cookie secret': '^<S0$!?a778,)~[Fx4wQvgcTw]fWq.)<s`cAJc:bExU*(L&ty9;mSV?`am:*7f.P'
});
// Load your project's Models
keystone.import('models');
// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js
keystone.set('locals', {
_: require('underscore'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable
});
// Load your project's Routes
keystone.set('routes', require('./routes'));
// Setup common locals for your emails. The following are required by Keystone's
// default email templates, you may remove them if you're using your own.
// Configure the navigation bar in Keystone's Admin UI
keystone.set('nav', {
'posts': ['posts', 'post-categories'],
'enquiries': 'enquiries',
'users': 'users'
});
// Start Keystone to connect to your database and initialise the web server
keystone.start();
Fixed this by making sure all node modules were on the server, pushing to the repo using sourcetree kept timing out, so the modules weren't there. I FTP'd them instead.
Related
I am new to Postgresql (more familiar with Mongo) but our DevOps want me to transition a KeystoneJS project from Mongo to Postgresql. I followed the KeystoneJS instructions and all went fine until I tried adding the 'atCreated' plugin, specifically the 'createdAtField' plugin, to get a created date in my list. I started getting DB errors, and, thinking that I needed to rebuild the database, I ran the KeystoneJS init script to drop the database and rebuild it. Since then, I've gotten the following error:
$ tsc && cross-env NODE_ENV=development DISABLE_LOGGING=true keystone --entry=tsout/index.js dev --port=4545
ℹ Command: keystone dev --entry=tsout/index.js --port=4545
✔ Validated project entry file ./tsout/index.js
✔ Keystone server listening on port 4545
✔ Initialised Keystone instance
⠋ Connecting to databaseType "OEmbed" is missing a "__resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
setting up cron job
⠙ Connecting to database knex:query select 1+1 as result undefined +0ms
⠹ Connecting to database knex:query SHOW server_version; undefined +65ms
✖ Connecting to database
Error: Cannot read property 'find' of undefined
at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/utils/dist/utils.cjs.dev.js:57:21
at async executeDefaultServer (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/keystone/bin/utils.js:114:3) {
errors: {
KnexAdapter: TypeError: Cannot read property 'find' of undefined
at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:258:31
at Array.forEach (<anonymous>)
at KnexListAdapter._postConnect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:257:24)
at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:73:19
at Array.forEach (<anonymous>)
at KnexAdapter.postConnect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:72:38)
at KnexAdapter.connect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/node_modules/#keystonejs/keystone/lib/adapters/index.js:29:38)
at async pReflect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/p-reflect/index.js:5:17)
at async Promise.all (index 0)
at async executeDefaultServer (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/keystone/bin/utils.js:114:3)
}
}
The DB is obviously empty, but KeystoneJS allows you to set up a new database based on the current lists using
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new KnexAdapter({ dropDatabase: true })
});
I went back to a prior branch, hoping to undo the errors (except the dropped DB of course), but the error persists.
For what it's worth, these are the KeystoneJS versions I'm using:
"#keystonejs/adapter-knex": "^7.0.0",
"#keystonejs/adapter-mongoose": "^5.2.0",
"#keystonejs/app-admin-ui": "^5.8.0",
"#keystonejs/app-graphql": "^5.1.0",
"#keystonejs/app-next": "^5.1.0",
"#keystonejs/app-static": "^5.1.0",
"#keystonejs/auth-password": "^5.1.0",
"#keystonejs/field-content": "^5.4.0",
"#keystonejs/fields": "^6.3.0",
"#keystonejs/fields-markdown": "^5.1.0",
"#keystonejs/fields-wysiwyg-tinymce": "^5.2.0",
"#keystonejs/file-adapters": "^5.5.0",
"#keystonejs/keystone": "^5.5.0",
"#keystonejs/list-plugins": "^5.1.2",
"#keystonejs/oembed-adapters": "^5.1.0",
Your knex adapter also needs the connection string:
const { KnexAdapter: Adapter } = require('#keystonejs/adapter-knex');
const adapterConfig = { knexOptions:{
connection: 'postgres://<your-user>:<your-paswrd>#<your-host>:<your-port>/<your-db>'
},
dropDatabase:true
};
and then call the adapter when creating your keystone project
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new Adapter(adapterConfig),
});
I am writing a protractor test for login for an AngularJS app and want to verify that the login is successful and the url changes after login. I tried to use Expected condition with urlContains() and also tried with browser.getCurrentUrl().toContain() but I am getting error in both.
exports.config = {
seleniumAddress : 'http://localhost:4444/wd/hub',
specs: ['login.spec.js'],
};
Expected condition passes the test when the url is correct. But when the url is different then it throws timeout error
"Failed: Wait timed out after 5013ms".
expect(browser.getCurrentUrl()).toContain('/dashboard') fails always with below error
Stack:
ScriptTimeoutError: script timeout: result was not received in 11 seconds
(Session info: chrome=75.0.3770.142)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.3', java.version: '12.0.1'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Protractor.waitForAngular()
at thenableWebDriverProxy.schedule (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at ProtractorBrowser.executeAsyncScript_ (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/built/browser.js:425:28)
at angularAppRoot.then (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/built/browser.js:456:33)
at ManagedPromise.invokeCallback_ (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:668:7
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Run it("should login successfully") in control flow
at UserContext.<anonymous> (/Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:19)
From asynchronous test:
Error
at Object.<anonymous> (/Users/ProtractorTest/Tests/login.spec.js:17:3)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at /Users/.nvm/versions/node/v8.9.4/lib/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:93:5
Below is my code
it('should login successfully', function () {
browser.get("https://example.com/");
loginobj.username.sendKeys(logindata.email);
loginobj.password.sendKeys(logindata.password);
loginobj.loginbtn.click().then(function(){
browser.getCurrentUrl().then(url => expect(url).toContain('/dashboard'));
//var EC = protractor.ExpectedConditions;
//browser.wait(EC.urlContains('/dashboard'), 5000);
})
I expect that when the url is different than the expected one, it should display a valid error message instead of timeout error.
By default protractor handles all the asynchrony for you. Looking at your code you are relying on default protractor behaviour i.e. not setting SELENIUM_PROMISE_MANAGER to false.
In that case, why do you want to do something inside click().then() ? It can be as simple and plain as
loginobj.loginbtn.click();
expect(browser.getCurrentUrl()).toContain('/dashboard');
One theory with your code: once you have something inside click().then(), its out of place from the promise queue that protractor is handling for you. Unless it is absolutely necessary, for ex get value from an element for later use in the spec, I would suggest not to meddle with protractor asynchronous handling as much as possible.
Hope that helps.
I have something similar
const currentUrl = await browser.getCurrentUrl().then(url => url);
expect(currentUrl).toContain('/dashboard')
Try it out maybe it will help, just without await as i see you don't use async functions
or like this
await browser.getCurrentUrl().then(url => expect(url).toContain('/dashboard'));
In protractor default script time out is 11 seconds,
In above code snippet,
browser.getCurrentUrl().then(url => expect(url).toContain('/dashboard'));
statement takes more than 11 seconds to resolve promise.
Solution: In Protractor configuration file, add below statements
allScriptsTimeout: timeout_in_millis.
e.g for 30 second timeout
allScriptsTimeout: 30000
Edited Configuration File:
exports.config = {
allScriptsTimeout: 30000,
seleniumAddress : 'http://localhost:4444/wd/hub',
specs: ['login.spec.js'],
};
I'm facing two issues while using ES6 class export and import. First, while import, methods cannot be accessible from imported class. Second, while executing the code through visual studio code im facing the following error "SyntaxError: Unexpected token import". Please provide correction or suggestion.
Below are my my class file "Login_pageobj.js"
export default class Login_pageobj {
constructor() {
//userName
this.enterUserName = element(by.xpath('//input[#id="username"]'));
//Password
this.enterPassword = element(by.xpath('//input[#id="password"]'));
//Login Button
this.clickLoginBtn = element(by.buttonText('LOGIN'));
//invalid UserName Password Error
this.inValErrMsg = element(by.xpath('//div[#class="subtext"]'));
}
//Please enter a user name (required). method
isDisplyedUserNameErrorMsg() {...}
This below code is My Protractor spec file Login_spec.js
import Login_pageobj from '../ES6_pageobj/login_pageobj';
describe('Login Page Validation', function() {
it('Launch Commercial URL',function(){
browser.get('http://applicationurl');
browser.manage().window().maximize();
expect(browser.getTitle()).toBe('LoginWeb');
});
it('Login Button should Disabled',function(){
console.log('----------------------------------------------------');
let lgin_pgobj = new login_pageobj();
lgin_pgobj.verifyLgnBtnEnabled();//***unable to access this method***
});
});
While run this code through Visual studio code debugger i'm getting following error.
Debugging with inspector protocol because Node.js v8.9.1 was detected.
node --inspect-brk=23169 node_modules\protractor\bin\protractor
e:\CommercialPOC/conf.js --suite es6
Debugger listening on ws://127.0.0.1:23169/e3dfd326-8468-4a3a-a2e3-3094d97c5571
(node:4708) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
(node:4708) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
warning.js:18
[22:00:06] I/launcher - Running 1 instances of WebDriver
logger.js:155
[22:00:06] I/direct - Using ChromeDriver directly...
logger.js:155
null
conf.js:48
[22:00:25] E/launcher - Error:
e:\commercialPOC\ES6_moduleScenarios\0Login_spec.js:1
logger.js:155
(function (exports, require, module, __filename, __dirname) { import
Login_pageobj from '../ES6_pageobj/login_pageobj';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at e:\CommercialPOC\node_modules\jasmine\lib\jasmine.js:93:5
[22:00:25] E/launcher - Process exited with error code 100
You should use such import constructure:
const Login_pageobj = require('../ES6_pageobj/login_pageobj')
I am trying to Implement this simple typescript code. But having weird error while running through node command. Can someone please help?
Main.ts
class Wedding {
bond:string;
money:number;
isWeddingPossible() {
if(this.bond === 'Strong' && this.money > 10000 ){
console.log('Wedding can be done.');
}
else{
console.log("Go to hell");
}
}
}
let wedding = new Wedding();
wedding.bond = 'Not Strong';
wedding.money = 500;
wedding.isWeddingPossible();
Run commands : tsc main.ts && node main.ts
Error :
/ts-hello/main.ts:3
bond:string;
^
SyntaxError: Unexpected token :
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
You should run node main.js instead of main.ts. You compile your .ts file and it creates it's .js file. So you need to run that compiled .js file via node.
I have been trying to run my hello-worlds.js file on my intel Edison (shown below):
var five = require("johnny-five");
var Edison = require("galileo-io");
var board = new five.Board({
io: new Edison()
});
board.on("ready", function() {
var led = new five.Led(13);
led.blink(500);
});
I have installed Node.js, I also used npm install galileo-io johnny-five and downloaded files to my file directory of folder my-robotics-project.
When i execute using node hello-worlds.js, I get the following error:
This OS image is no longer supported.
Please upgrade to IoTkit Image with libmraa0 support
c:\User\Mohamed\my-robotics-project\node_modules\galileo\lib\galileo.js:66
if <Pin.IO.getPlatformType<> === 2> {
TypeError: Cannot read property 'getPlatformType' of undefined
at Object.<anonymous> <c:\User\Mohamed\my-robotics-
project\node_modules\galileo\lib\galileo.js:66:11>
at Module._compile <module.js:435:26>
at Object.Module.extensions..js <module.js:442:10>
at Module.load <module.js:356:32>
at function.Module._load <module.js:311:12>
at Module.require <module.js:366:17>
at require <module.js:385:17>
at Object.<anonymous> <c:\User\Mohamed\my-robotics-project\hello-
worlds.js:2:14>
at Module._compile <module.js:435:26>
at Object.Module._extensions..js <module.js:442:10>