Backend code files are useful for accessing server-based functions and also for keeping prying eyes away from sensitive code, but did you know that there are two types of backend files ?
.js files are for code that is not accessible to the front end. You can't import functions into your page code from a .js file. (Well, actually you can but you’ll get a runtime error.)
.jsw files are accessible to your front end, and you can import functions from them into your page code. By the way, you can import functions from a .js file into a .jsw file and call them, just don’t forget your await statement or your .then clause.
Did you know that .jsw files come with permissions ?
You can set the permissions for each function in your .jsw file to control who can call the function - Admin, Site member, or Anyone.
To set the permissions, go to the Backend Files section of the sidebar and click on the options icon to the right of your jsw file. Select Edit Web Module Permissions.
You’ll get a dialog that lets you to set the permissions for who can call each of the function in the file.