ale
ale copied to clipboard
ALE_CONNECTION
Can someone please show how to set this up and in which file? I installed MySQL js then in connection.js exports.ALE_CONNECTION=mysql.createConnection({ ....... });
But i still get AleError: ALE_CONNECTION envar is not set, cannot connect to database
please advise
Could you try installing dotenv (npm install dotenv or yarn add dotenv) and use it to make the env available as in line 15 and 16 of the attached. Let me know if it works.
![Screenshot 2019-06-04 at 9 58 48 PM](https://user-images.githubusercontent.com/42445456/58913420-11d86200-8714-11e9-9678-eee907e79149.png)
i did this and i think am getting connected to the DB
const Sequelize = require('sequelize');
const mysql = require('mysql');
exports.ALE_CONNECTION=process.env.ALE_CONNECTION= mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'booklet'
});
const conn = process.env.ALE_CONNECTION;
but i get this
nf start
[WARN] ENOENT: no such file or directory, open 'Procfile'
[OKAY] package.json file found - trying 'npm start'
9:20:13 PM web.1 | > [email protected] start /home/martin/Downloads/Compressed/ale-master/ale-master
9:20:14 PM web.1 | > node server
9:20:18 PM web.1 | connection == "[object Object]" /*this is the conn object i log to the console in connecion.js*/
9:20:18 PM web.1 | /home/martin/Downloads/Compressed/ale-master/ale-master/node_modules/swagger-routes/src/routeBuilder.js:42
9:20:18 PM web.1 | else throw e
9:20:18 PM web.1 | ^
9:20:18 PM web.1 | TypeError: Cannot read property 'replace' of null
9:20:18 PM web.1 | at new Sequelize (/home/martin/Downloads/Compressed/ale-master/ale-master/node_modules/sequelize/lib/sequelize.js:117:43)
9:20:18 PM web.1 | at Object.<anonymous> (/home/martin/Downloads/Compressed/ale-master/ale-master/models/connection.js:32:19)
9:20:18 PM web.1 | at Module._compile (internal/modules/cjs/loader.js:689:30)
9:20:18 PM web.1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
9:20:18 PM web.1 | at Module.load (internal/modules/cjs/loader.js:599:32)
9:20:18 PM web.1 | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
9:20:18 PM web.1 | at Function.Module._load (internal/modules/cjs/loader.js:530:3)
9:20:18 PM web.1 | at Module.require (internal/modules/cjs/loader.js:637:17)
9:20:18 PM web.1 | at require (internal/modules/cjs/helpers.js:22:18)
9:20:18 PM web.1 | at Object.<anonymous> (/home/martin/Downloads/Compressed/ale-master/ale-master/models/book.js:17:19)
9:20:18 PM web.1 | at Module._compile (internal/modules/cjs/loader.js:689:30)
9:20:18 PM web.1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
9:20:18 PM web.1 | at Module.load (internal/modules/cjs/loader.js:599:32)
9:20:18 PM web.1 | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
9:20:18 PM web.1 | at Function.Module._load (internal/modules/cjs/loader.js:530:3)
9:20:18 PM web.1 | at Module.require (internal/modules/cjs/loader.js:637:17)
9:20:18 PM web.1 | at require (internal/modules/cjs/helpers.js:22:18)
9:20:18 PM web.1 | at Object.<anonymous> (/home/martin/Downloads/Compressed/ale-master/ale-master/lib/handlers/getBooks.js:7:14)
9:20:18 PM web.1 | at Module._compile (internal/modules/cjs/loader.js:689:30)
9:20:18 PM web.1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
9:20:18 PM web.1 | at Module.load (internal/modules/cjs/loader.js:599:32)
9:20:18 PM web.1 | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
9:20:18 PM web.1 | npm
9:20:18 PM web.1 | ERR! code ELIFECYCLE
9:20:18 PM web.1 | npm
9:20:18 PM web.1 | ERR! errno 1
9:20:18 PM web.1 | npm
9:20:18 PM web.1 | ERR! [email protected] start: `node server`
9:20:18 PM web.1 | npm ERR! Exit status 1
9:20:18 PM web.1 | npm ERR!
9:20:18 PM web.1 | npm ERR! Failed at the [email protected] start script.
9:20:18 PM web.1 | npm ERR!
9:20:18 PM web.1 | This is probably not a problem with npm. There is likely additional logging output above.
[DONE] Killing all processes with signal SIGINT
9:20:18 PM web.1 Exited with exit code null
but i think sequelize gets a null object from DB ! i really want to use this with mysql.js but its so painstakingly tough
is there a running example(demo) to learn from? using one of the other Db's
I currently use it with PostgreSQL/Sequelize. You can check my working repo here: https://github.com/olajide1234/ale. Let me know if you can pick up a thing or two from there. If not, you can share your codebase, i'll try to replicate the error and take a look at it.
Make sure you have the user and database setup. Check these files 'ale/test/testDB.js' and 'ale/models/' for instructions.