Skip to main content

Server

Backend and API Development.

Server Folder​

The πŸ“‚ server folder contains a set of files and folders that make up the application's backend.

Everything in the πŸ“‚ server folder is used for backend server processing, such as integrations, API, database, security and authentication, Cron Jobs, and much more.

Folder Structure​

The πŸ“‚ server folder has the following structure:

./server/ Β β”œβ”€ ./actions/ Β β”œβ”€ ./components/ Β β”œβ”€ ./core/ Β β”‚ β”œβ”€ ./_config.js Β β”‚ β”œβ”€ ./_init.js Β β”‚ β”œβ”€ ./_request_close.js Β β”‚ β”œβ”€ ./_request_end.js Β β”‚ β”œβ”€ ./_request_error.js Β β”‚ β”œβ”€ ./_request_start.js Β β”‚ β”œβ”€ ./_request_url.js Β β”‚ β”œβ”€ ./_service_config.js Β β”‚ β”œβ”€ ./_service_end.js Β β”‚ β”œβ”€ ./_service_error.js Β β”‚ └─ ./_service_start.js Β β”œβ”€ ./reports/ Β β”œβ”€ ./services/ Β β”œβ”€ ./setup/ Β β”‚ β”œβ”€ ./_end.js Β β”‚ └─ ./_start.js  └─ ./templates/ Β  β”œβ”€ ./_/ Β  β”œβ”€ ./dev/ Β  β”‚ └─ ./dashboard.html Β  β”œβ”€ ./dashboard.html Β  β”œβ”€ ./scripts.html Β  β”œβ”€ ./scripts_dev.html Β  β”œβ”€ ./scripts_login.html Β  β”œβ”€ ./styles.html Β  β”œβ”€ ./styles_dev.html Β  └─ ./styles_login.html

Actions​

In πŸ“‚ actions, you can add custom actions (hooks) to the CRUD operations of forms automatically generated for the back office. Depending on the data structure, many data interventions can be performed here.

For example, when reviewing a customer, it is necessary to delete all their orders, or when creating a new product, it must be integrated with another system. In short, any development directly related to data can be done here.

Actions are inspired by database triggers, but at the code execution level.

Therefore, specific operations can be programmed for creating, modifying, and deleting data.

Components​

πŸ“‚ components are used to define custom field types in back office forms, which can perform data manipulation themselves.

Components can be created through scripts to provide a new, specific field type in the application.

Core​

The πŸ“‚ core folder allows code injection into the HTTP request processing flow.

It is also used to share code between different services and others.

_config.js is executed after the configuration is loaded for each HTTP request. It is executed after the environment configuration script found in the application's πŸ“‚ config folder.

_init.js is used to inject instructions when the application is initialized for the first time.

HTTP Request Processing​

The corresponding scripts are executed in the HTTP request processing flow for any URL in the application:

  • _request_start.js is executed when the HTTP request arrives at the Netuno server.
  • _request_url.js is executed when the URL is processed by Netuno; the URL can be changed to another destination.
  • _request_close.js is executed when the HTTP request response is closed. - _request_end.js is executed when the HTTP request is definitively completed.
  • _request_error.js is executed when an error occurs while processing the HTTP request.

API Service Processing​

The following scripts are executed in the processing flow of any application's API service:

  • _service_config.js is executed before starting the service execution. It is used to define the service execution settings, among other things. It can be used to define whether or not the service can be executed, i.e., a security control over access to the API service.
  • _service_start.js is executed as soon as a service begins processing.
  • _service_end.js is executed after a service has finished processing.
  • _service_error.js is executed when an error occurs while processing a service.

Services - API​

The services that make up the application API are created in the πŸ“‚ services folder.

Services can be written in various languages: Javascript, Python, Java, Kotlin, Ruby, or Groovy.

Since Netuno is polyglot, any script file can be modified to another supported programming language; the file extension simply matches the language.

No additional configuration is required depending on the programming language used; simply create the service file with the correct extension corresponding to the programming language.

Setup​

The πŸ“‚ setup folder contains the code automatically generated by the Netuno engine that defines the database schemas.

It is also where we can place the data loading, which is essential for the application to function.

The _start.js script is executed before the database construction process begins.

The _end.js script is executed after the database construction process is complete.

As the data structure is built, Netuno automatically creates the code in the πŸ“‚ setup folder necessary for the entire data structure to be recreated in a new database, or to recreate any missing code in another database where the application may eventually run.

Templates​

The πŸ“‚ templates folder contains the HTML content of the application's backoffice pages, which are generated by the Netuno server.

The πŸ“‚ dev folder contains the dashboard.html file, which allows you to change the workspace in developer build mode.

The dashboard.html folder, located in the templates root, contains the HTML for the general backoffice workspace.

Native Templates​

In the πŸ“‚ _ folder, any general template can be replaced, meaning Netuno's default templates can be changed.

If the folder and/or file names match those of the native templates within this folder, then the template found in this folder will be used instead of the native template.

In other words, simply replicate the same structure of the native template within the πŸ“‚ _ folder to replace it.