Documentation
    Preparing search index...

    Variable generatorsConst

    generators: {
        singularControllerNames: string[];
        createEntity(entityName: string): { path: string; name: string };
        importPath(...paths: string[]): string;
        tableName(entityName: string): string;
        modelName(entityName: string): string;
        modelFileName(entityName: string): string;
        controllerName(entityName: string, singular?: boolean): string;
        controllerFileName(entityName: string, singular?: boolean): string;
        eventName(entityName: string): string;
        eventFileName(entityName: string): string;
        listenerName(entityName: string): string;
        listenerFileName(entityName: string): string;
        middlewareName(entityName: string): string;
        middlewareFileName(entityName: string): string;
        providerName(entityName: string): string;
        providerFileName(entityName: string): string;
        policyName(entityName: string): string;
        policyFileName(entityName: string): string;
        factoryName(entityName: string): string;
        factoryFileName(entityName: string): string;
        serviceName(entityName: string): string;
        serviceFileName(entityName: string): string;
        seederName(entityName: string): string;
        seederFileName(entityName: string): string;
        commandTerminalName(entityName: string): string;
        commandName(entityName: string): string;
        commandFileName(entityName: string): string;
        validatorName(entityName: string): string;
        validatorActionName(entityName: string, action: string): string;
        validatorFileName(entityName: string): string;
        exceptionName(entityName: string): string;
        exceptionFileName(entityName: string): string;
        mailerName(entityName: string, type?: "notification" | "provision"): string;
        mailerFileName(
            entityName: string,
            type?: "notification" | "provision",
        ): string;
        mailName(entityName: string, type?: string): string;
        mailFileName(entityName: string, type?: string): string;
        testGroupName(entity: { path: string; name: string }): string;
        testFileName(entityName: string): string;
        viewFileName(entityName: string): string;
    } = ...

    Generators used for scaffolding various AdonisJS entities. Provides utilities for creating standardized names, file names, and paths for models, controllers, middleware, and other framework components.

    Type Declaration

    • singularControllerNames: string[]

      List of controller names that should always be generated in singular form. These are typically system/admin controllers or special-purpose controllers that don't represent plural resources.

      // These will remain singular:
      // 'home' -> 'HomeController'
      // 'admin' -> 'AdminController'
      // 'auth' -> 'AuthController'
    • createEntity: function
      • Creates the entity path and name from user input. Parses the entity name to separate directory path from the actual name, handling file extensions and nested paths.

        Parameters

        • entityName: string

          The entity name which may include path and extension

        Returns { path: string; name: string }

        Object containing the parsed path and name

        createEntity('admin/users') // { path: 'admin', name: 'users' }
        createEntity('user.ts') // { path: './', name: 'user' }
        createEntity('profile') // { path: './', name: 'profile' }
    • importPath: function
      • Constructs a Unix-style import path from given path segments. Ensures consistent path separators regardless of the operating system.

        Parameters

        • ...paths: string[]

          Path segments to join

        Returns string

        Unix-style path string

        importPath('app', 'models', 'user') // 'app/models/user'
        
    • tableName: function
      • Converts an entity name to a database table name. Removes 'table' suffix, converts to model name format, then pluralizes and converts to snake_case.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Database table name in snake_case plural form

        tableName('User') // 'users'
        tableName('BlogPost') // 'blog_posts'
        tableName('UserTable') // 'users'
    • modelName: function
      • Converts an entity name to a model class name. Removes file extension and 'model' suffix, singularizes, and converts to PascalCase.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Model class name in PascalCase singular form

        modelName('users') // 'User'
        modelName('blog-posts') // 'BlogPost'
        modelName('user.model.ts') // 'User'
    • modelFileName: function
      • Converts an entity name to a model file name. Uses the model name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Model file name in snake_case with .ts extension

        modelFileName('User') // 'user.ts'
        modelFileName('BlogPost') // 'blog_post.ts'
    • controllerName: function
      • Converts an entity name to a controller class name. Removes file extension and 'controller' suffix, then applies singularization rules based on special names list or parameter.

        Parameters

        • entityName: string

          The entity name to convert

        • singular: boolean = false

          Force singular form regardless of special names

        Returns string

        Controller class name in PascalCase with 'Controller' suffix

        controllerName('users') // 'UsersController'
        controllerName('admin') // 'AdminController' (from singular list)
        controllerName('posts', true) // 'PostController' (forced singular)
    • controllerFileName: function
      • Converts an entity name to a controller file name. Uses the controller name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        • singular: boolean = false

          Force singular form for the controller name

        Returns string

        Controller file name in snake_case with .ts extension

        controllerFileName('users') // 'users_controller.ts'
        controllerFileName('admin') // 'admin_controller.ts'
    • eventName: function
      • Converts an entity name to an event class name. Removes file extension and 'event' suffix, then converts to PascalCase.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Event class name in PascalCase

        eventName('user-registered') // 'UserRegistered'
        eventName('order.event.ts') // 'Order'
    • eventFileName: function
      • Converts an entity name to an event file name. Uses the event name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Event file name in snake_case with .ts extension

        eventFileName('UserRegistered') // 'user_registered.ts'
        
    • listenerName: function
      • Converts an entity name to a listener class name. Removes file extension and 'listener' suffix, then converts to PascalCase.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Listener class name in PascalCase

        listenerName('send-email') // 'SendEmail'
        listenerName('notification.listener.ts') // 'Notification'
    • listenerFileName: function
      • Converts an entity name to a listener file name. Uses the listener name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Listener file name in snake_case with .ts extension

        listenerFileName('SendEmail') // 'send_email.ts'
        
    • middlewareName: function
      • Converts an entity name to a middleware class name. Removes file extension and 'middleware' suffix, then converts to PascalCase with 'Middleware' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Middleware class name in PascalCase with 'Middleware' suffix

        middlewareName('auth') // 'AuthMiddleware'
        middlewareName('cors.middleware.ts') // 'CorsMiddleware'
    • middlewareFileName: function
      • Converts an entity name to a middleware file name. Uses the middleware name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Middleware file name in snake_case with .ts extension

        middlewareFileName('Auth') // 'auth_middleware.ts'
        
    • providerName: function
      • Converts an entity name to a provider class name. Removes file extension and 'provider' suffix, singularizes, then converts to PascalCase with 'Provider' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Provider class name in PascalCase with 'Provider' suffix

        providerName('database') // 'DatabaseProvider'
        providerName('redis.provider.ts') // 'RedisProvider'
    • providerFileName: function
      • Converts an entity name to a provider file name. Uses the provider name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Provider file name in snake_case with .ts extension

        providerFileName('Database') // 'database_provider.ts'
        
    • policyName: function
      • Converts an entity name to a policy class name. Removes file extension, 'policy' and 'model' suffixes, singularizes, then converts to PascalCase with 'Policy' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Policy class name in PascalCase with 'Policy' suffix

        policyName('users') // 'UserPolicy'
        policyName('post.policy.ts') // 'PostPolicy'
    • policyFileName: function
      • Converts an entity name to a policy file name. Uses the policy name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Policy file name in snake_case with .ts extension

        policyFileName('User') // 'user_policy.ts'
        
    • factoryName: function
      • Converts an entity name to a factory class name. Removes file extension, 'factory' and 'model' suffixes, singularizes, then converts to PascalCase with 'Factory' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Factory class name in PascalCase with 'Factory' suffix

        factoryName('users') // 'UserFactory'
        factoryName('post.factory.ts') // 'PostFactory'
    • factoryFileName: function
      • Converts an entity name to a factory file name. Uses the factory name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Factory file name in snake_case with .ts extension

        factoryFileName('User') // 'user_factory.ts'
        
    • serviceName: function
      • Converts an entity name to a service class name. Removes file extension, 'service' and 'model' suffixes, singularizes, then converts to PascalCase with 'Service' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Service class name in PascalCase with 'Service' suffix

        serviceName('users') // 'UserService'
        serviceName('email.service.ts') // 'EmailService'
    • serviceFileName: function
      • Converts an entity name to a service file name. Uses the service name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Service file name in snake_case with .ts extension

        serviceFileName('User') // 'user_service.ts'
        
    • seederName: function
      • Converts an entity name to a seeder class name. Removes file extension, 'seeder' and 'model' suffixes, singularizes, then converts to PascalCase with 'Seeder' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Seeder class name in PascalCase with 'Seeder' suffix

        seederName('users') // 'UserSeeder'
        seederName('post.seeder.ts') // 'PostSeeder'
    • seederFileName: function
      • Converts an entity name to a seeder file name. Uses the seeder name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Seeder file name in snake_case with .ts extension

        seederFileName('User') // 'user_seeder.ts'
        
    • commandTerminalName: function
      • Converts an entity name to a command terminal name. Creates a namespaced command name using dash-case format, where the first part becomes the namespace and remaining parts are joined with colons.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Command terminal name in namespace:command format

        commandTerminalName('MakeUser') // 'make:user'
        commandTerminalName('DbSeed') // 'db:seed'
        commandTerminalName('Clear') // 'clear'
    • commandName: function
      • Converts an entity name to a command class name. Removes file extension and 'command' suffix, then converts to PascalCase.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Command class name in PascalCase

        commandName('make-user') // 'MakeUser'
        commandName('db.seed.command.ts') // 'DbSeed'
    • commandFileName: function
      • Converts an entity name to a command file name. Uses the command name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Command file name in snake_case with .ts extension

        commandFileName('MakeUser') // 'make_user.ts'
        
    • validatorName: function
      • Converts an entity name to a validator class name. Removes file extension and 'validator' suffix, singularizes, then converts to PascalCase.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Validator class name in PascalCase

        validatorName('users') // 'User'
        validatorName('create-post.validator.ts') // 'CreatePost'
    • validatorActionName: function
      • Converts an entity name and action to a validator action name. Creates a camelCase name by prefixing with action and suffixing with 'validator'.

        Parameters

        • entityName: string

          The entity name to convert

        • action: string

          The action name (e.g., 'create', 'update')

        Returns string

        Validator action name in camelCase

        validatorActionName('User', 'create') // 'createUserValidator'
        validatorActionName('BlogPost', 'update') // 'updateBlogPostValidator'
    • validatorFileName: function
      • Converts an entity name to a validator file name. Uses the validator name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Validator file name in snake_case with .ts extension

        validatorFileName('User') // 'user.ts'
        
    • exceptionName: function
      • Converts an entity name to an exception class name. Removes file extension and 'exception' suffix, then converts to PascalCase with 'Exception' suffix.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Exception class name in PascalCase with 'Exception' suffix

        exceptionName('validation-error') // 'ValidationErrorException'
        exceptionName('not-found.exception.ts') // 'NotFoundException'
    • exceptionFileName: function
      • Converts an entity name to an exception file name. Uses the exception name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Exception file name in snake_case with .ts extension

        exceptionFileName('ValidationError') // 'validation_error_exception.ts'
        
    • mailerName: function
      • Converts an entity name to a mailer class name. Removes file extension and various suffixes, then converts to PascalCase with the specified type suffix.

        Parameters

        • entityName: string

          The entity name to convert

        • type: "notification" | "provision" = 'notification'

          The mailer type ('notification' or 'provision')

        Returns string

        Mailer class name in PascalCase with type suffix

        mailerName('welcome-email') // 'WelcomeEmailNotification'
        mailerName('user-signup', 'provision') // 'UserSignupProvision'
    • mailerFileName: function
      • Converts an entity name to a mailer file name. Uses the mailer name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        • type: "notification" | "provision" = 'notification'

          The mailer type ('notification' or 'provision')

        Returns string

        Mailer file name in snake_case with .ts extension

        mailerFileName('WelcomeEmail') // 'welcome_email_notification.ts'
        
    • mailName: function
      • Converts an entity name to a class-based mail name. Removes file extension and various suffixes, then converts to PascalCase with the specified type suffix. Similar to mailerName but with more flexible type.

        Parameters

        • entityName: string

          The entity name to convert

        • type: string = 'notification'

          The mail type (default: 'notification')

        Returns string

        Mail class name in PascalCase with type suffix

        mailName('welcome') // 'WelcomeNotification'
        mailName('password-reset', 'email') // 'PasswordResetEmail'
    • mailFileName: function
      • Converts an entity name to a class-based mail file name. Uses the mail name and converts to snake_case with .ts extension.

        Parameters

        • entityName: string

          The entity name to convert

        • type: string = 'notification'

          The mail type (default: 'notification')

        Returns string

        Mail file name in snake_case with .ts extension

        mailFileName('Welcome') // 'welcome_notification.ts'
        mailFileName('PasswordReset', 'email') // 'password_reset_email.ts'
    • testGroupName: function
      • Converts an entity to a test group name. Creates a human-readable test group name by combining path and name, removing extensions and converting to sentence case.

        Parameters

        • entity: { path: string; name: string }

          Object containing path and name properties

        Returns string

        Test group name in sentence case

        testGroupName({ path: 'controllers', name: 'users' }) // 'Controllers users'
        testGroupName({ path: 'models', name: 'user.spec' }) // 'Models user'
    • testFileName: function
      • Converts an entity name to a test file name. Removes file extension and '.spec' suffix, converts to snake_case, then adds '.spec.ts' extension.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        Test file name in snake_case with .spec.ts extension

        testFileName('UserController') // 'user_controller.spec.ts'
        testFileName('auth-service.spec') // 'auth_service.spec.ts'
    • viewFileName: function
      • Converts an entity name to a view template file name. Removes file extension, converts to snake_case, and adds '.edge' extension for Edge template files.

        Parameters

        • entityName: string

          The entity name to convert

        Returns string

        View file name in snake_case with .edge extension

        viewFileName('UserProfile') // 'user_profile.edge'
        viewFileName('admin-dashboard') // 'admin_dashboard.edge'