🚀 Nano ID 0.1

I just finished building the custom module extension for nanoid

A tiny, secure, URL-friendly, unique string ID generator for JavaScript.

Think of UUID but faster.

You can grab it from the public repository (PRs accepted) and store the two files in extensions/server_connect/modules/

Feel free to fork and port to other server models. I work exclusively with nodejs so I don't have time to build and test it for the rest.

Make sure to install the package before npm i nanoid

It implements all methods from the API except for Custom Random Bytes Generator. If there is enough interest I will think about adding it although I would be surprised if anyone needs it.

It has two versions: a synchronous and an asynchronous. Just choose the one you need.

Some screenshots.

image

18 Likes

Thanks @JonL appreciate you taking the time to add something more to the community. Look forward to checking this out as I’ve yet to add a uuid. Perfect timing :slightly_smiling_face:

1 Like

silly question… but do you actually need to install nanoid first, i.e. run npm i nanoid from the terminal?

I’m just getting a error
"status":"500","message":"Module nanoid doesn't exist"

I created the folders, its available in the UI to choose, but not seeming to work. I’ll keep playing around, probably something on my end.

image

Indeed. Sorry! I forgot to mention. It was like 5am when I finished :slight_smile:

2 Likes

Were you able to make it work after installing the package?

No, just doing some more testing on my end, but i think its to something to do with not being able to ‘require’ the nanoid module.

The system error in more detail is:
{"status":"500","message":"Module nanoid doesn't exist","stack":"Error: Module nanoid doesn't exist\n at App._exec (/opt/node_app/lib/core/app.js:253:27)\n at App.exec (/opt/node_app/lib/core/app.js:205:20)\n at App.define (/opt/node_app/lib/core/app.js:188:20)\n at processTicksAndRejections (internal/process/task_queues.js:97:5)"}

Things that might be effecting it that i can think of:

General settings:

But i have tried to change the Links relative to document and also web root to the primary root but still no luck.

Does the nanoid dependency need to be added to the package.json file?

I’m still getting my head around node modules and Require etc so its a slow process.

Also, my test is simply trying to open the server action file in the browser via the Wappler UI

What command did you run to install it? Is it in your node-modules folder inside your project?

Yes it’s in the node modules. I used npm i nanoid

It should be added to package.json then. Is it not? If not try uninstalling and installing again.

No it didn’t get added to that…so presumably it’s not getting packaged up and ‘built / bundled’ when deployed/ run

1 Like

Well uninstalling and reinstalling the npm package has at least added nanoid to the package.json file but my test still isn’t working (I’ve restarted the services and redeployed the Docker image a few times)

I’m going to try on a different/new project and see if that helps. I appreciate your help Jonas, i know you didn’t post this module to troubleshoot people’s issues lol :slight_smile:

EDIT: I’ve tried on a different, mostly new project and had the same issue.

Error msg has changed slightly though and now has some references to an express/router wappler file.

{"status":"500","message":"Module nanoid doesn't exist","stack":"Error: Module nanoid doesn't exist\n at App._exec (/opt/node_app/lib/core/app.js:253:27)\n at App.exec (/opt/node_app/lib/core/app.js:205:20)\n at App.define (/opt/node_app/lib/core/app.js:188:20)\n at /opt/node_app/lib/core/middleware.js:13:40\n at Layer.handle [as handle_request] (/opt/node_app/node_modules/express/lib/router/layer.js:95:5)\n at next (/opt/node_app/node_modules/express/lib/router/route.js:137:13)\n at next (/opt/node_app/node_modules/express/lib/router/route.js:131:14)\n at next (/opt/node_app/node_modules/express/lib/router/route.js:131:14)\n at next (/opt/node_app/node_modules/express/lib/router/route.js:131:14)\n at next (/opt/node_app/node_modules/express/lib/router/route.js:131:14)"}

Thank you @JonL - very timely for me too. Will implement over weekend.

1 Like

Let me know if you get it working @mgaussie

I will check on a brand new docker project. I was using the local server so I didn’t test it with Docker.

Confirmed. There is something going on with docker and node_modules. I will open a bug report.

Well happy to hear it wasn’t just me :slight_smile:

So was yours working in just the standard local Node Dev environment?

Yep. I thought it was overkill to develop an extension in docker having a local server :smiley:

Solution for issue with nodejs docker setup. In the end it was not related at all with the node packages.

Amazing @JonL! Hopefully this will lead to an explosion of new additions to Wappler led by the community. :vulcan_salute:

2 Likes

I forgot to say. It’s a 10$/month subscription plugin.

J/K…Bubble’s old bad habits :joy:

9 Likes