Node script that has access of Strapi instance

Hello,

I created a Node.js script that interacts with a Strapi instance. This script could be useful, for example, for seeding data or setting default permissions. (Make sure you have built your Strapi project using yarn build). It’s currently working for me.

Any further improvements or suggestions?

/scripts/myScript.js

const Strapi = require("@strapi/strapi");

async function init()
{
  const strapi = await Strapi({ distDir: "./dist" }).load();
  const appLink = await strapi.entityService.findOne('api::app-link.app-link',1)
  console.log('appLink',appLink)
}

init()

package.json

  "scripts": {
      //....
      "myScript": "node ./scripts/myScript.js",
      //...
},

cli:
yarn run myScript

Sources: