@sebastián-cisneros In static:api.routes, you'll want to call controllerHelpers.setupAPIRoute to mount the route to the appropriate /api/v3/plugins mount point.
You can see an example of how we do it in the quickstart plugin
Hi,
I'm new with nodeBB and I'm writing my first plugin.
I have a question that may be simple but I just can't figure out how to use lodash or underscore inside my client side JS file.
I have the file loaded, since I put this into plugin.json:
"scripts": [
"client/index.js"
],
So in my index.js file:
...
define('forum/client/plugins/my-plugin', [], function () {
'use strict';
require(['require', 'lodash'], function (require) {
var _ = require('lodash');
var Edit = {};
Edit.init = function () {
// an exemple code from lodash usage
_.map([4, 8], function(n) {
return n * n;
});
};
...
Can someone please point me to how to use lodash on my client side scripts?
Thanks
That's close. You would actually just put it in your define call.
define('forum/client/plugins/my-plugin', ['lodash'], function (_) {
var Edit = {};
Edit.init = function () {
// an exemple code from lodash usage
var test = _.map([4, 8], function(n) {
return n * n;
});
console.log(test);
};
return Edit;
});
Assuming 'lodash'
is a url to lodash.js
That's great. Thanks @yariplus!
@marcelo-lopes you can also define modules
in plugin.json that can be required directly like define('thing', ['lodash']
instead of specifying the full url.
ahh nice! Thanks @PitaJ
I could not find any info on the docs:
https://docs.nodebb.org/en/latest/plugins/create.html
will give it a try.
Thanks