Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 1.91 KB

1. app folder structure.md

File metadata and controls

56 lines (43 loc) · 1.91 KB

App folder structure

Bootstrap file

This is the content of the index.js bootstrap file. The path given to the boot function is the path to the main app directory.

import { join as pathJoin } from 'path';
import { boot } from '@mighty-multitask-server/boot';

if (import.meta.filename !== process.argv[1]) {
    console.error('This file should only be used as the main entry point');
    process.exit(1);
}
boot(pathJoin(import.meta.dirname, 'src/app'));

See App loading flow for more information.

Main app directory structure

  • config/: A directory that contains core configuration files.
  • code/: A directory that contains app modules.
  • lib/: A directory that contains libraries that can be used in the app modules.

Config folder

  • All .js files are sorted by name and loaded in that order. If a setting is defined in multiple files, the last one will be used.
  • env.js: Contains config settings that are machine/environment specific.

The config file structure will be explained in Global config settings.

Code folder

  • Contains vendor folder (folders that represent a vendor or a third-party library).
  • Each vendor folder contains modules that contain a part of the app logic/configuration.
  • Other than a few mandatory files, the structure of the module is up to the developer.

Example structure

app/
    code/
        vendorName/
            moduleName/
                config/
                    webserver_config.js
                    api_config.js
                    ...

Mandatory files and folders

  • module.js: Contains the module definition.
  • config/: Contains configuration files. Each type of configuration has their own name. When a setting of a certain name is collected, it is done through all modules. The order of the modules depends on the loading order of the modules.