How to actually run mozilla openbadges - node.js

I'm following this tutorial here.
https://github.com/mozilla/openbadges-badgekit/wiki/BadgeKit-Self-Hosting-Guide#badgekit-api-configuration
It says, when you run the API use this command source env_local
The problem is, I'm new to node and not really sure how I run the API. I've downloaded all the stuff, installed node, and got a simple hello world program working with node. I just don't know how I actually run the API. I thought I had to run the procfile, but when I do node procfile I get an error saying cannot find module badegkit\badgekit-api\start
As a hacky ass solution, I figured this out. I tried setting PATH in environment variables to env_local, as well as doing SET path = env_local in the command window and neither worked. However, if you browse to the badgekit api folder then app then lib, there's a db.js file in there.
Here's what I did, their stuff is commented out.
var options = {
driver: 'mysql',
// host: process.env.DB_HOST,
// user: process.env.DB_USER,
// password: process.env.DB_PASSWORD,
// database: process.env.DB_NAME,
host: "127.0.0.1",
user: "username",
password: "password",
database: "dbname",
}
Just put in your mysql creds and then you can run the db migrate. Obviously this isn't ideal as anywhere else that uses env is still going to be screwy, but it got me to step 2.
2014-09-29 Edit
For all those curious, as of right now, node isn't really supported on windows per se. I ran into so many issues with python and gyp, that I ended up just spinning up a linux box in hyper v and hosting it there.

The idea behind that command is to load the environment variables setup in env_local. By deafult, they are set up as a few export commands, which should put the key=value pairs into your running environment.
I actually removed the export strings and stored them as .env_dev, so a file with:
DB_HOST=localhost
DB_NAME=badgekitapi
...etc...
And the command I used to run things was: nf start -e .env_dev
With the API running, and able to store badges, you can now follow the tutorials to run openbadges-badgekit - so you can actually make and issue some badges ; )
Good luck!

Related

"error: Grunt :: Starting inspector on 127.0.0.1:xxxx failed: address already in use"

am trying to run two separate projects at the same time.
two separate projects are sailsjs applications.
using visual studio code.
i would like to start each of these projects in vscode "debug mode".
each of these projects need to run on different ports.
In the local.js of each of these projects I have mentioned:
module.exports = {
port: xx
}
yet only one of my projects seems to run correctly.
i did a bit of looking around. i think i have to add some kind of arguments to my launch.json, which I did so:
"runtimeArgs": ["--inspect=9230"]
but still i get the error:
"2019-03-05T11:31:25.085Z - error: Grunt :: Starting inspector on 127.0.0.1:9985 failed: address already in use"
when i restart one of the applications. the other application seem to be running fine.
from this error, i understand there is some kind of grunt module that generates a random port to the debugging host.
Port defined in local.js is project port, sails inspect use default port for debug 127.0.0.1:9229.
So when u try sails inspect in both project, first project will take default port, and then second will fail.
Sails documentation say "To use the standard (command-line) node debugger with sails, you can always just run node inspect app.js", then u can use command node inspect --port=xxxx app.js.
Example:
Project A:
module.exports = {
port: 2000
}
node inspect --port=9980 app.js
Project B:
module.exports = {
port: 2001
}
node inspect --port=9981 app.js
I hope this is what u need.

strapi start: "url is not defined" - using mlab mongo DB

When I run 'strapi start' I get the following output in my terminal:
debug ⛔️ Server wasn't able to start properly.
Error URL is not defined
Any solutions? I have recreated my mlab DB 3 times and when I enter all the values in the terminal to create the new strapi server I double check my values and everything from GitHub issues and strapi documentations say I'm doing the correct thing, but not able to figure out why this is happening! Appreciate any help!
As #soupette have said in the comment:
Strapi needs Node v10 to be installed in order to work. If you upgrade
your node version it should be working properly
I can confirm the same error on my end with NodeJS 8.11.1
Strapi's GitHub page confirms that minimum NodeJS version is 10.x
Ok when you create a Mondo db on mlab you get this information:
mongo ds129484.mlab.com:29484/blog -u <dbuser> -p <dbpassword>
mongodb://<dbuser>:<dbpassword>#ds129484.mlab.com:29484/blog
When you start a strapi project, you make this
strapi new blog
cd blog
strapi start
So you select mondodb how to default db and the cli show the follow questions, and you would be add the following answers, supposing that you have the db data showed before:
DBname: blog
host: ds129484.mlab.com
srv connection: false
port: 29484
username: username created on mlab for your db
password: username password created on mlab for your db
authentication db: blog (you have put the name of your db)
enable ssl: false
You press Enter and you project would be run perfectly
First of all you must have Node 10 or above. If you still getting error edit the following file:
config/host.json
Use an higher timeout value.
{
"timeout": 60000,
......
}
Assuming you are on the correct node version, goto the configuration.js found in node_modules/strapi/lib/core/configurations.js and update lines 331-333.
Replace
this.config.admin.url = this.config.admin.devMode ?
(new URL(adminPath, `http://${this.config.host}:4000`)).toString():
(new URL(adminPath, url)).toString();
With
this.config.admin.url = this.config.admin.devMode ? `http://${this.config.host}:4000/admin`:`http://${this.config.host}:1337/admin`
Thanks
Here is what worked for me:
Just upgrade your node js installation to version 10

Running Ghost in IIS with Iisnode

I have a problem getting iisnode and ghost to play together.
I can run the samples supplied with iisnode fine and I can get ghost up and running fine through the node command line. I have followed every blog post written online I can find to get them set up together. The frustrating thing is the blogs make this process look extremely straightforward.
From looking at "ETW" logs it looks like iisnode cannot communicate with the node process using named pipes ("iisnode scheduled a retry of a named pipe connection to the node.exe process" x20+), and then the node process terminates.
The problem may not lie with ghost, tbh I cannot work out what to do or which part to tweak next. My best guess at this point is some sort of permissions issue, but I've spent hours setting permissions all over my development machine to no avail.
If it helps, the error message I get back in the browser is: ERROR: (Code: EACCES) There was an error starting your server.
To answer my own question, I examined the Process Monitor output for node.exe, line by line to see if I could see anything strange. I'm no expert at analysing the output from Process Monitor and there are a tonne of "Buffer Overflow" messages and other things that could be errors, but then I happened to stumble upon the following line:
Node.exe CreatePipe \MyProjects\WebsiteName\process.env.port\ INVALIDDEVICEREQUEST
Invalid device?
Then the penny finally dropped. In config.js you do not want to set your port to 'process.env.port' (as is suggested in the config.js file itself as a comment) you want to set the port to process.env.port.
No quotes.
Just to clarify what ruethewhirl551 said, here is an excerpt from my working "config.js":
config = {
production: {
url: 'http://my-blog.com',
mail: {
transport: 'SMTP',
options: {
service: 'Mailgun',
auth: {
user: 'postmaster#my-blog.com',
pass: '9ed512da012cd454376947365xd71793'
}
}
},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: process.env.PORT // <-- HERE
}
},
// ...
Please notice the line port: process.env.PORT at the bottom.
You can also search for "iisnode" through the "config.example.js" file for more information.

How to show queries in console log using sails?

I am starting a project with sails and mysql, and I do'nt know how configurate it to show the queries executed in the console.
The mysql adapter has a debug variable LOG_QUERIES to send all queries to the console.
LOG_QUERIES=true node myFile.js
Unfortunately this isn't possible with Sails at this time, although the feature has been requested. Your best bet is to inspect the log file provided by your database:
Postgres: How to log PostgreSQL queries?
MySQL: Log all queries in mysql
MongoDB: MongoDB logging all queries
This solution works for sails >= 1.1.
The sails-mysql (as of v1.0.0) adapter uses the machinepack-mysql driver which logs queries to debug. So all that's needed to log all native queries is to enable the debug flag:
DEBUG=query node app.js
If you're doing Sails.js development on Mac OS with Postgresql.app, you can enable all query logging as follows:
In a new Terminal, edit ~/Library/Application Support/Postgres/var/postgresql.conf and set:
logging_collector = on
log_directory = 'pg_log'
log_statement = 'all'
Then restart Postgresql.app (click on menubar icon, Quit, then use Spotlight to relaunch).
Then tail the log with:
tail -F ~/Library/Application\ Support/Postgres/var/pg_log/postgresql-2014-10-30_104957.log
You'll have to find the newest postgresql-*log to tail and substitute that above.
My answer might me very late but just found a solution which might help people
sails version = 0.12.14
to log quires do following
navigate to
node_modules\sails-mysql\lib\adapter.js
locate variable declaration of "log"
then change "process.env.LOG_QUERIES" to "sails.config.LOG_QUERIES"
navigate to
[sails root]/config/env/[development or production].js
add
LOG_QUERIES = 'true',
NOTE :- remember to put ""or '' for true
Or add log to sql module.
In mysql this is:
working_dir/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js
function **createQuery** (33)
Put
LOG_QUERIES = 'true'
in sails lift command
Just add this to your datastore
debug: ["ComQueryPacket"]
config/datastores.js should be look like this
module.exports.datastores = {
default: {
adapter: 'sails-mysql',
user: '*****',
password: "****",
host: '*****',
database: '****',
debug: ["ComQueryPacket"]
}
}

backbone boilerplate: How to start the development server

I've cloned Backbone boilerplate which comes with an example Todo app. I have also read that the boilerplate comes with a development server, but I don't know how to start it. In the tutorial, it says you can run this command
node build/server
but I get an error saying that it can't find the module /build/server
Can anyone explain?
If you've installed nodejs it should be as simple as changing directory to the root of the TODO application and running the following command (although you may also need to add the path to node to your environment settings):
bbb server
You should then be able to access the example on localhost:8000.
Just as an FYI, you can change the server values in grunt.js to run bbb on a specific host and port.
server: {
host: "10.111.X.1", port: 3303,
...
}

Resources