├── .editorconfig ├── .github ├── CODE_OF_CONDUCT.md ├── COMMIT_CONVENTION.md ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── bun-core-test.yml │ ├── bun-e2e-test.yml │ ├── nodejs-automated.yml │ ├── nodejs-core-test.yml │ ├── nodejs-e2e-test.yml │ └── package-test.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bin ├── formidablejs │ ├── Commands │ │ ├── Build.js │ │ └── Start.js │ ├── ext.js │ ├── index.js │ └── runtime.js ├── imba │ └── server.imba └── jest │ └── preprocessor.js ├── formidable ├── Package.js ├── auth-emails │ ├── ResetPassword.imba │ └── VerifyEmail.imba ├── auth │ ├── imba │ │ ├── app │ │ │ ├── Http │ │ │ │ └── Controllers │ │ │ │ │ └── AuthController.imba │ │ │ └── Resolvers │ │ │ │ └── AuthServiceResolver.imba │ │ ├── resources │ │ │ └── views │ │ │ │ ├── Auth │ │ │ │ ├── EmailUnverified.imba │ │ │ │ ├── EmailVerification.imba │ │ │ │ ├── ForgotPassword.imba │ │ │ │ ├── Login.imba │ │ │ │ ├── PasswordReset.imba │ │ │ │ └── Register.imba │ │ │ │ └── welcome.imba │ │ ├── routes │ │ │ └── web.imba │ │ └── test │ │ │ └── app.e2e.test.imba │ └── ts │ │ ├── app │ │ ├── Http │ │ │ └── Controllers │ │ │ │ └── AuthController.ts │ │ └── Resolvers │ │ │ └── AuthServiceResolver.ts │ │ ├── resources │ │ └── views │ │ │ ├── Auth │ │ │ ├── EmailUnverified.imba │ │ │ ├── EmailVerification.imba │ │ │ ├── ForgotPassword.imba │ │ │ ├── Login.imba │ │ │ ├── PasswordReset.imba │ │ │ └── Register.imba │ │ │ └── welcome.imba │ │ ├── routes │ │ └── web.ts │ │ └── test │ │ └── app.e2e.test.ts └── web │ ├── config │ ├── imba │ │ └── auth.imba │ └── ts │ │ └── auth.ts │ ├── public │ ├── favicon.ico │ └── formidable.png │ ├── resolvers │ ├── imba │ │ └── RouterServiceResolver.imba │ └── ts │ │ └── RouterServiceResolver.ts │ ├── routes │ ├── imba │ │ ├── api.imba │ │ └── web.imba │ └── ts │ │ ├── api.ts │ │ └── web.ts │ ├── test │ ├── imba │ │ └── app.e2e.test.imba │ └── ts │ │ └── app.e2e.test.ts │ └── views │ └── welcome.imba ├── package-lock.json ├── package.json ├── scripts ├── 0-package.sh ├── 1-fetch.sh ├── 2-install.sh ├── 3-copy-test-files.sh ├── 4-prepare.sh ├── 5-clean-up.sh ├── e2e │ ├── app │ │ ├── Http │ │ │ ├── Controllers │ │ │ │ └── PostController.imba │ │ │ └── Request │ │ │ │ └── StorePostRequest.imba │ │ └── Resolvers │ │ │ └── AppServiceResolver.imba │ ├── config │ │ └── database.imba │ ├── database │ │ └── migrations │ │ │ └── 20211126141343_create_posts_table.js │ ├── ecosystem.config.js │ ├── routes │ │ └── api.imba │ └── test │ │ ├── app.e2e.test.imba │ │ ├── auth.test.imba │ │ ├── database.test.imba │ │ ├── language.test.imba │ │ ├── responses.test.imba │ │ ├── routes.test.imba │ │ └── validation.test.imba └── server-command-replace.sh ├── src ├── Auth │ ├── Auth.imba │ ├── AuthService.imba │ ├── AuthenticationServiceResolver.imba │ ├── Authorize.imba │ ├── DriverManager.imba │ ├── Drivers │ │ ├── Driver.imba │ │ ├── JwtDriver.imba │ │ └── SessionDriver.imba │ ├── Exceptions │ │ ├── AuthenticationException.imba │ │ ├── AuthorizationException.imba │ │ ├── EmailNotVerifiedException.imba │ │ ├── EmailVerifiedException.imba │ │ ├── UnauthenticatedException.imba │ │ ├── UnsupportedAuthDriverException.imba │ │ └── index.imba │ ├── Http │ │ ├── Controllers │ │ │ ├── EmailVerificationController.imba │ │ │ ├── LoginController.imba │ │ │ ├── LogoutController.imba │ │ │ ├── PasswordController.imba │ │ │ └── RegisterController.imba │ │ ├── Middleware │ │ │ ├── Authenticate.imba │ │ │ ├── BeforeForgot.imba │ │ │ ├── BeforeLogin.imba │ │ │ ├── BeforeLogout.imba │ │ │ ├── BeforeRegister.imba │ │ │ ├── BeforeResend.imba │ │ │ ├── BeforeReset.imba │ │ │ ├── BeforeVerify.imba │ │ │ └── ErrorIfAuthenticated.imba │ │ └── Requests │ │ │ ├── EmailResendRequest.imba │ │ │ ├── ForgotPasswordRequest.imba │ │ │ ├── LoginRequest.imba │ │ │ ├── LogoutRequest.imba │ │ │ ├── RegisterRequest.imba │ │ │ ├── ResetPasswordRequest.imba │ │ │ └── VerifyEmailRequest.imba │ ├── Mail │ │ ├── ResetPassword.imba │ │ ├── VerifyEmail.imba │ │ └── index.imba │ ├── Protocol.imba │ └── Tokens │ │ ├── PersonalAccessToken.imba │ │ └── PersonalAccessTokenServiceResolver.imba ├── Config │ └── Repository.imba ├── Database │ ├── Bind.imba │ ├── Config.imba │ ├── Database.imba │ ├── Factory.imba │ ├── Migration.imba │ ├── Repository.imba │ └── Seeder.imba ├── Environment │ └── Repository.imba ├── Foundation │ ├── Application.imba │ ├── Bootstrap.imba │ ├── Console.imba │ ├── Console │ │ ├── Command.imba │ │ ├── Commands │ │ │ ├── CacheCommand.imba │ │ │ ├── ConfigCacheCommand.imba │ │ │ ├── ConfigClearCommand.imba │ │ │ ├── DbSeedCommand.imba │ │ │ ├── DownCommand.imba │ │ │ ├── EnvironmentCommand.imba │ │ │ ├── GenerateKeyCommand.imba │ │ │ ├── InspireCommand.imba │ │ │ ├── MaintenanceCommand.imba │ │ │ ├── MakeCommandCommand.imba │ │ │ ├── MakeConfigCommand.imba │ │ │ ├── MakeControllerCommand.imba │ │ │ ├── MakeCrudCommand.imba │ │ │ ├── MakeExceptionCommand.imba │ │ │ ├── MakeFactoryCommand.imba │ │ │ ├── MakeMailCommand.imba │ │ │ ├── MakeMiddlewareCommand.imba │ │ │ ├── MakeMigrationCommand.imba │ │ │ ├── MakeRepositoryCommand.imba │ │ │ ├── MakeRequestCommand.imba │ │ │ ├── MakeResolverCommand.imba │ │ │ ├── MakeResourceCommand.imba │ │ │ ├── MakeSeederCommand.imba │ │ │ ├── MakeTagCommand.imba │ │ │ ├── MakeViewCommand.imba │ │ │ ├── MigrateCommand.imba │ │ │ ├── MigrateDownCommand.imba │ │ │ ├── MigrateFreshCommand.imba │ │ │ ├── MigrateLatestCommand.imba │ │ │ ├── MigrateRollbackCommand.imba │ │ │ ├── MigrateUpCommand.imba │ │ │ ├── MigrationCommand.imba │ │ │ ├── PackagePublishCommand.imba │ │ │ ├── RouteListCommand.imba │ │ │ ├── ServeCommand.imba │ │ │ ├── SessionPruneExpiredCommand.imba │ │ │ ├── ShellCommand.imba │ │ │ └── UpCommand.imba │ │ ├── ServeEvents.imba │ │ └── verifyPort.imba │ ├── ConsoleKernel.imba │ ├── Context.imba │ ├── Encrypter.imba │ ├── Exceptions │ │ ├── ApplicationException.imba │ │ ├── DecryptException.imba │ │ ├── EncryptException.imba │ │ ├── ExitHandlerException.imba │ │ ├── Handler.imba │ │ ├── Handler │ │ │ └── handleException.imba │ │ ├── InvalidAppKeyException.imba │ │ ├── InvalidEncryptionKeyTypeException.imba │ │ ├── InvalidServiceResolver.imba │ │ ├── MaintenanceModeException.imba │ │ └── UnserializedEncryptValueException.imba │ ├── Inspiring.imba │ ├── MaintenanceServiceResolver.imba │ └── Server.imba ├── Hashing │ ├── Exceptions │ │ ├── InvalidHashConfigurationException.imba │ │ └── InvalidHashDriverException.imba │ ├── Hash.imba │ └── HashServiceResolver.imba ├── Http │ ├── Controller.imba │ ├── Cookie │ │ └── CookieServiceResolver.imba │ ├── Cors │ │ └── CorsServiceResolver.imba │ ├── Exceptions │ │ ├── BadRequestException.imba │ │ ├── ForbiddenException.imba │ │ ├── HttpException.imba │ │ ├── InvalidRouteActionException.imba │ │ ├── InvalidSignatureException.imba │ │ ├── NotFoundException.imba │ │ ├── UndefinedMiddlewareException.imba │ │ ├── UnsupportedSessionDriverException.imba │ │ └── index.imba │ ├── Kernel.imba │ ├── Kernel │ │ ├── getResponse.imba │ │ ├── handleNotFound.imba │ │ ├── hasContentTypes.imba │ │ └── resolveResponse.imba │ ├── Middleware.imba │ ├── Middleware │ │ ├── ConvertEmptyStringsToNull.imba │ │ ├── EnsureEmailIsVerified.imba │ │ ├── EnsureStateless.imba │ │ ├── ExitMiddleware.imba │ │ ├── TransformsRequest.imba │ │ ├── TrimStrings.imba │ │ ├── ValidateSignature.imba │ │ └── VerifyCsrfToken.imba │ ├── Redirect │ │ └── Redirect.imba │ ├── Request │ │ ├── Cookies.imba │ │ ├── Exceptions │ │ │ └── DestinationExistsException.imba │ │ ├── File.imba │ │ ├── FileCollection.imba │ │ ├── FormRequest.imba │ │ ├── FormValidation.imba │ │ ├── MultipartServiceResolver.imba │ │ ├── Request.imba │ │ └── Session.imba │ ├── Response │ │ ├── JsonResponse.imba │ │ ├── Response.imba │ │ └── ViewResponse.imba │ ├── Router │ │ ├── Exceptions │ │ │ └── InvalidRouteActionException.imba │ │ ├── Path.imba │ │ └── Route.imba │ ├── Session │ │ ├── DriverManager.imba │ │ ├── Exceptions │ │ │ ├── TokenMismatchException.imba │ │ │ └── UnsupportedSessionDriverException.imba │ │ ├── SessionFileStoreServiceResolver.imba │ │ ├── SessionMemoryStoreServiceResolver.imba │ │ └── SessionServiceResolver.imba │ ├── Static │ │ └── StaticContentServiceResolver.imba │ ├── URL │ │ ├── Exceptions │ │ │ ├── MissingRouteParamException.imba │ │ │ └── UnregisteredRouteException.imba │ │ └── URL.imba │ └── View │ │ ├── Exceptions │ │ └── UndefinedDataPropException.imba │ │ └── View.imba ├── Mail │ └── Mailable.imba ├── Mix │ └── Repository.imba ├── Redis │ ├── Redis.imba │ ├── RedisFactory.imba │ └── RedisServiceResolver.imba ├── Support │ ├── Decorators │ │ ├── context.imba │ │ └── use.imba │ ├── Encryption │ │ ├── Exceptions │ │ │ └── MissingAppKeyException.imba │ │ └── HasEncryptionKey.imba │ ├── Helpers │ │ ├── Error │ │ │ ├── BooleanCastError.imba │ │ │ ├── ConfigNotCachedError.imba │ │ │ └── InvalidExitFunction.imba │ │ ├── asObject.imba │ │ ├── bind.imba │ │ ├── config.imba │ │ ├── decrypt.imba │ │ ├── die.imba │ │ ├── dotNotation.imba │ │ ├── encrypt.imba │ │ ├── env.imba │ │ ├── expiresIn.imba │ │ ├── hashEquals.imba │ │ ├── imbaEnv.imba │ │ ├── index.imba │ │ ├── isArray.imba │ │ ├── isBoolean.imba │ │ ├── isClass.imba │ │ ├── isEmpty.imba │ │ ├── isFunction.imba │ │ ├── isNumber.imba │ │ ├── isObject.imba │ │ ├── isString.imba │ │ ├── loadHelpers.imba │ │ ├── location.imba │ │ ├── mix.imba │ │ ├── multitap.imba │ │ ├── now.imba │ │ ├── response.imba │ │ ├── route.imba │ │ ├── signedRoute.imba │ │ ├── singularize.imba │ │ ├── slug.imba │ │ ├── strRandom.imba │ │ ├── tap.imba │ │ ├── temporarySignedRoute.imba │ │ ├── toBoolean.imba │ │ ├── updateLine.imba │ │ ├── version.imba │ │ ├── view.imba │ │ ├── wildcard.imba │ │ └── without.imba │ ├── HigherOrderTapProxy.imba │ ├── InfiniteHigherOrderTapProxy.imba │ ├── Language │ │ ├── Language.imba │ │ ├── LanguageServiceResolver.imba │ │ └── Middleware │ │ │ └── AcceptLanguage.imba │ └── ServiceResolver.imba ├── Validator │ ├── Exceptions │ │ └── ValidationException.imba │ ├── ValidationServiceResolver.imba │ └── Validator.imba └── index.imba ├── test ├── config │ ├── Config.js │ └── repository.test.js ├── encrypter │ ├── encrypter.exceptions.test.js │ ├── encrypter.test.js │ └── setup │ │ └── Encrypter.js ├── environment │ ├── .env │ └── repository.test.js ├── hashing │ └── hash.test.js ├── helpers │ ├── asObject.test.js │ ├── config.test.js │ ├── dotNotation.test.js │ ├── env.test.js │ ├── isArray.test.js │ ├── isBoolean.test.js │ ├── isClass.test.js │ ├── isEmpty.test.js │ ├── isFunction.test.js │ ├── isNumber.test.js │ ├── isObject.test.js │ ├── isString.test.js │ ├── multitap.test.js │ ├── route.test.js │ ├── signedRoute.test.js │ ├── slug.test.js │ ├── strRandom.test.js │ ├── tap.test.js │ ├── temporarySignedRoute.test.js │ ├── toBoolean.test.js │ ├── wildcard.test.js │ └── without.test.js ├── http │ ├── redirect │ │ └── redirect.test.js │ ├── router │ │ └── route.test.js │ └── url │ │ └── url.test.js ├── jwt │ ├── personalAccessToken.test.js │ └── setup │ │ ├── Config.js │ │ ├── Database.js │ │ ├── db-config.js │ │ ├── knexfile.js │ │ ├── migrations │ │ ├── 20210724082462-create_users_table.js │ │ └── 20210820161410_create_personal_access_tokens_table.js │ │ └── seeds │ │ └── users.js └── redis │ ├── redis.test.js │ └── setup │ └── Config.js ├── tsconfig.json └── types ├── Auth ├── Auth.d.ts ├── AuthService.d.ts ├── AuthenticationServiceResolver.d.ts ├── Authorize.d.ts ├── DriverManager.d.ts ├── Drivers │ ├── Driver.d.ts │ ├── JwtDriver.d.ts │ └── SessionDriver.d.ts ├── Exceptions │ ├── AuthorizationException.d.ts │ ├── EmailNotVerifiedException.d.ts │ ├── EmailVerifiedException.d.ts │ └── UnsupportedAuthDriverException.d.ts ├── Http │ ├── Controllers │ │ ├── EmailVerificationController.d.ts │ │ ├── LoginController.d.ts │ │ ├── LogoutController.d.ts │ │ ├── PasswordController.d.ts │ │ └── RegisterController.d.ts │ ├── Middleware │ │ ├── Authenticate.d.ts │ │ ├── BeforeForgot.d.ts │ │ ├── BeforeLogin.d.ts │ │ ├── BeforeLogout.d.ts │ │ ├── BeforeRegister.d.ts │ │ ├── BeforeResend.d.ts │ │ ├── BeforeReset.d.ts │ │ ├── BeforeVerify.d.ts │ │ └── ErrorIfAuthenticated.d.ts │ └── Requests │ │ ├── EmailResendRequest.d.ts │ │ ├── ForgotPasswordRequest.d.ts │ │ ├── LoginRequest.d.ts │ │ ├── LogoutRequest.d.ts │ │ ├── RegisterRequest.d.ts │ │ ├── ResetPasswordRequest.d.ts │ │ └── VerifyEmailRequest.d.ts ├── Mail │ ├── ResetPassword.d.ts │ ├── VerifyEmail.d.ts │ └── index.d.ts ├── Protocol.d.ts └── Tokens │ ├── PersonalAccessToken.d.ts │ └── PersonalAccessTokenServiceResolver.d.ts ├── Config └── Repository.d.ts ├── Database ├── Bind.d.ts ├── Config.d.ts ├── Database.d.ts ├── Factory.d.ts ├── IContextual.d.ts ├── Migration.d.ts ├── Repository.d.ts ├── Seeder.d.ts └── result.d.ts ├── Environment └── Repository.d.ts ├── Foundation ├── Application.d.ts ├── Bootstrap.d.ts ├── Console.d.ts ├── Console │ ├── Command.d.ts │ ├── Commands │ │ ├── CacheCommand.d.ts │ │ ├── ConfigCacheCommand.d.ts │ │ ├── ConfigClearCommand.d.ts │ │ ├── DbSeedCommand.d.ts │ │ ├── DownCommand.d.ts │ │ ├── EnvironmentCommand.d.ts │ │ ├── GenerateKeyCommand.d.ts │ │ ├── InspireCommand.d.ts │ │ ├── MaintenanceCommand.d.ts │ │ ├── MakeCommandCommand.d.ts │ │ ├── MakeConfigCommand.d.ts │ │ ├── MakeControllerCommand.d.ts │ │ ├── MakeCrudCommand.d.ts │ │ ├── MakeExceptionCommand.d.ts │ │ ├── MakeMailCommand.d.ts │ │ ├── MakeMiddlewareCommand.d.ts │ │ ├── MakeMigrationCommand.d.ts │ │ ├── MakeRepositoryCommand.d.ts │ │ ├── MakeRequestCommand.d.ts │ │ ├── MakeResolverCommand.d.ts │ │ ├── MakeResourceCommand.d.ts │ │ ├── MakeSeederCommand.d.ts │ │ ├── MakeTagCommand.d.ts │ │ ├── MakeViewCommand.d.ts │ │ ├── MigrateDownCommand.d.ts │ │ ├── MigrateFreshCommand.d.ts │ │ ├── MigrateLatestCommand.d.ts │ │ ├── MigrateRollbackCommand.d.ts │ │ ├── MigrateUpCommand.d.ts │ │ ├── MigrationCommand.d.ts │ │ ├── PackagePublishCommand.d.ts │ │ ├── RouteListCommand.d.ts │ │ ├── ServeCommand.d.ts │ │ ├── SessionPruneExpiredCommand.d.ts │ │ ├── ShellCommand.d.ts │ │ └── UpCommand.d.ts │ └── verifyPort.ts ├── ConsoleKernel.d.ts ├── Context.d.ts ├── Encrypter.d.ts ├── Exceptions │ ├── ApplicationException.d.ts │ ├── DecryptException.d.ts │ ├── EncryptException.d.ts │ ├── ExitHandlerException.d.ts │ ├── Handler.d.ts │ ├── Handler │ │ └── handleException.d.ts │ ├── InvalidAppKeyException.d.ts │ ├── InvalidEncryptionKeyTypeException.d.ts │ ├── InvalidServiceResolver.d.ts │ └── MaintenanceModeException.d.ts ├── Inspiring.d.ts ├── MaintenanceServiceResolver.d.ts └── Server.d.ts ├── Hashing ├── Exceptions │ ├── InvalidHashConfigurationException.d.ts │ └── InvalidHashDriverException.d.ts ├── Hash.d.ts └── HashServiceResolver.d.ts ├── Http ├── Controller.d.ts ├── Cookie │ └── CookieServiceResolver.d.ts ├── Cors │ └── CorsServiceResolver.d.ts ├── Exceptions │ ├── BadRequestException.d.ts │ ├── ForbiddenException.d.ts │ ├── HttpException.d.ts │ ├── InvalidSignatureException.d.ts │ ├── NotFoundException.d.ts │ └── UndefinedMiddlewareException.d.ts ├── Kernel.d.ts ├── Kernel │ ├── getResponse.d.ts │ ├── handleNotFound.d.ts │ ├── hasContentTypes.d.ts │ └── resolveResponse.d.ts ├── Middleware.d.ts ├── Middleware │ ├── ConvertEmptyStringsToNull.d.ts │ ├── EnsureEmailIsVerified.d.ts │ ├── EnsureStateless.d.ts │ ├── IMiddleware.d.ts │ ├── MiddlewareAliases.d.ts │ ├── MiddlewareGroups.d.ts │ ├── TransformsRequest.d.ts │ ├── TrimStrings.d.ts │ ├── ValidateSignature.d.ts │ └── VerifyCsrfToken.d.ts ├── Redirect │ └── Redirect.d.ts ├── Request │ ├── Cookies.d.ts │ ├── Exceptions │ │ └── DestinationExistsException.d.ts │ ├── File.d.ts │ ├── FileCollection.d.ts │ ├── FormRequest.d.ts │ ├── FormValidation.d.ts │ ├── MultipartServiceResolver.d.ts │ ├── Request.d.ts │ ├── Session.d.ts │ └── ValidationRules.d.ts ├── Response │ ├── JsonResponse.d.ts │ ├── Response.d.ts │ └── ViewResponse.d.ts ├── Router │ ├── Exceptions │ │ └── InvalidRouteActionException.d.ts │ ├── Path.d.ts │ └── Route.d.ts ├── Session │ ├── DriverManager.d.ts │ ├── Exceptions │ │ ├── TokenMismatchException.d.ts │ │ └── UnsupportedSessionDriverException.d.ts │ ├── SessionFileStoreServiceResolver.d.ts │ ├── SessionMemoryStoreServiceResolver.d.ts │ └── SessionServiceResolver.d.ts ├── Static │ └── StaticContentServiceResolver.d.ts ├── URL │ ├── Exceptions │ │ ├── MissingRouteParamException.d.ts │ │ └── UnregisteredRouteException.d.ts │ └── URL.d.ts └── View │ ├── Exceptions │ └── UndefinedDataPropException.d.ts │ └── View.d.ts ├── Mail └── Mailable.d.ts ├── Mix └── Repository.d.ts ├── Redis ├── Redis.d.ts └── RedisServiceResolver.d.ts ├── Support ├── Decorators │ ├── context.d.ts │ └── use.d.ts ├── Encryption │ ├── Exceptions │ │ └── MissingAppKeyException.d.ts │ └── HasEncryptionKey.d.ts ├── Helpers │ ├── Error │ │ ├── BooleanCastError.d.ts │ │ ├── ConfigNotCachedError.d.ts │ │ └── InvalidExitFunction.d.ts │ ├── asObject.d.ts │ ├── bind.d.ts │ ├── config.d.ts │ ├── decrypt.d.ts │ ├── die.d.ts │ ├── dotNotation.d.ts │ ├── encrypt.d.ts │ ├── env.d.ts │ ├── expiresIn.d.ts │ ├── hashEquals.d.ts │ ├── imbaEnv.d.ts │ ├── index.d.ts │ ├── isArray.d.ts │ ├── isBoolean.d.ts │ ├── isClass.d.ts │ ├── isEmpty.d.ts │ ├── isFunction.d.ts │ ├── isNumber.d.ts │ ├── isObject.d.ts │ ├── isString.d.ts │ ├── loadHelpers.d.ts │ ├── location.d.ts │ ├── mix.d.ts │ ├── multitap.d.ts │ ├── now.d.ts │ ├── response.d.ts │ ├── route.d.ts │ ├── signedRoute.d.ts │ ├── singularize.d.ts │ ├── slug.d.ts │ ├── strRandom.d.ts │ ├── tap.d.ts │ ├── temporarySignedRoute.d.ts │ ├── toBoolean.d.ts │ ├── updateLine.d.ts │ ├── version.d.ts │ ├── view.d.ts │ ├── wildcard.d.ts │ └── without.d.ts ├── HigherOrderTapProxy.d.ts ├── InfiniteHigherOrderTapProxy.d.ts ├── Language │ ├── Language.d.ts │ ├── LanguageServiceResolver.d.ts │ └── Middleware │ │ └── AcceptLanguage.d.ts └── ServiceResolver.d.ts ├── Validator ├── Exceptions │ └── ValidationException.d.ts ├── ValidationServiceResolver.d.ts └── Validator.d.ts └── index.d.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | 11 | [*.imba] 12 | charset = utf-8 13 | end_of_line = lf 14 | insert_final_newline = true 15 | indent_style = tab 16 | indent_size = 4 17 | trim_trailing_whitespace = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [*.{yml,yaml}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | The Formidable Code of Conduct can be found in the [Formidable documentation](https://www.formidablejs.org/docs/contributions#code-of-conduct). -------------------------------------------------------------------------------- /.github/COMMIT_CONVENTION.md: -------------------------------------------------------------------------------- 1 | # Commit Convention 2 | 3 | The Formidable Commit Convention can be found in the [Formidable documentation](https://www.formidablejs.org/docs/contributions#git-commit-message-convention). -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | The Formidable Contribution Guidelines can be found in the [Formidable documentation](https://www.formidablejs.org/docs/contributions). -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: donaldp -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680Feature request" 3 | about: Suggest an idea for Formidable 4 | --- 5 | 6 | 7 | 8 | ### Description 9 | 10 | 11 | 12 | ### Why 13 | 14 | 15 | 16 | 17 | 18 | ### Possible Implementation & Open Questions 19 | 20 | 21 | 22 | 23 | 24 | ### Is this something you're interested in working on? 25 | 26 | 27 | -------------------------------------------------------------------------------- /.github/workflows/bun-core-test.yml: -------------------------------------------------------------------------------- 1 | name: Bun - Core Tests 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: oven-sh/setup-bun@v2 12 | - name: Log in to Docker Hub 13 | uses: docker/login-action@v3 14 | with: 15 | username: ${{ secrets.DOCKERHUB_USERNAME }} 16 | password: ${{ secrets.DOCKERHUB_TOKEN }} 17 | - name: Start Redis 18 | uses: supercharge/redis-github-action@1.4.0 19 | - name: Install dependencies 20 | run: bun install 21 | - name: Build 22 | run: bun run build 23 | - name: Run tests 24 | run: bun run test 25 | -------------------------------------------------------------------------------- /.github/workflows/bun-e2e-test.yml: -------------------------------------------------------------------------------- 1 | name: Bun - E2E Tests 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: oven-sh/setup-bun@v2 13 | - name: Install modules 14 | run: bun install --frozen-lockfile 15 | - name: Build 16 | run: bun run build 17 | - name: Prepare e2e tests 18 | run: RUNTIME=bun bun run pre-test 19 | - name: Run e2e tests 20 | run: bun run test:e2e 21 | - name: Clean up 22 | run: ./scripts/5-clean-up.sh 23 | -------------------------------------------------------------------------------- /.github/workflows/nodejs-automated.yml: -------------------------------------------------------------------------------- 1 | name: Node.js - Automated Tests 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | if: github.ref == 'refs/heads/main' 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Log in to Docker Hub 15 | uses: docker/login-action@v3 16 | with: 17 | username: ${{ secrets.DOCKERHUB_USERNAME }} 18 | password: ${{ secrets.DOCKERHUB_TOKEN }} 19 | - name: Start Redis 20 | uses: supercharge/redis-github-action@1.4.0 21 | - name: Use Node.js 22 22 | uses: actions/setup-node@v3 23 | with: 24 | node-version: 22 25 | cache: 'npm' 26 | - run: npm ci 27 | - run: npm run build 28 | - run: npm test 29 | - run: npm run pre-test 30 | - run: npm run test:e2e 31 | - run: ./scripts/5-clean-up.sh 32 | -------------------------------------------------------------------------------- /.github/workflows/nodejs-core-test.yml: -------------------------------------------------------------------------------- 1 | name: Node.js - Core Tests 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [20.x, 22.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-node@v3 17 | with: 18 | node-version: ${{ matrix.node-version }} 19 | cache: 'npm' 20 | - name: Log in to Docker Hub 21 | uses: docker/login-action@v3 22 | with: 23 | username: ${{ secrets.DOCKERHUB_USERNAME }} 24 | password: ${{ secrets.DOCKERHUB_TOKEN }} 25 | - name: Start Redis 26 | uses: supercharge/redis-github-action@1.4.0 27 | - name: Install modules 28 | run: npm ci 29 | - name: Build 30 | run: npm run build 31 | - name: Run tests 32 | run: npm test 33 | -------------------------------------------------------------------------------- /.github/workflows/nodejs-e2e-test.yml: -------------------------------------------------------------------------------- 1 | name: Node.js - E2E Tests 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [20.x, 22.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-node@v3 17 | with: 18 | node-version: ${{ matrix.node-version }} 19 | cache: 'npm' 20 | - name: Install modules 21 | run: npm ci 22 | - name: Build 23 | run: npm run build 24 | - name: Prepare e2e tests 25 | run: npm run pre-test 26 | - name: Run e2e tests 27 | run: npm run test:e2e 28 | - name: Clean up 29 | run: ./scripts/5-clean-up.sh 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public 3 | /.temp 4 | /lib 5 | /output 6 | /test/e2e 7 | .env 8 | .env.backup 9 | npm-debug.log 10 | yarn-error.log 11 | *.tgz -------------------------------------------------------------------------------- /bin/formidablejs/Commands/Start.js: -------------------------------------------------------------------------------- 1 | const { Command } = require("@formidablejs/console"); 2 | const { execSync } = require("child_process"); 3 | const { getRuntime } = require("../runtime"); 4 | 5 | class Start extends Command { 6 | get signature() { 7 | return "start"; 8 | } 9 | 10 | get description() { 11 | return "Start the Application Server"; 12 | } 13 | 14 | handle() { 15 | const runtime = getRuntime(); 16 | 17 | execSync(`${runtime} server`, { 18 | stdio: "inherit", 19 | cwd: process.cwd(), 20 | }); 21 | } 22 | } 23 | 24 | module.exports = { Start }; 25 | -------------------------------------------------------------------------------- /bin/formidablejs/ext.js: -------------------------------------------------------------------------------- 1 | const { existsSync } = require('fs-extra') 2 | const { join } = require('path') 3 | 4 | const getExt = () => { 5 | const appPackage = join(process.cwd(), 'package.json') 6 | 7 | if (!existsSync(appPackage)) { 8 | return '.imba' 9 | } 10 | 11 | return (require(appPackage).language || 'imba').toLowerCase() == 'typescript' ? 12 | '.ts' : 13 | '.imba' 14 | } 15 | 16 | module.exports = { getExt } 17 | -------------------------------------------------------------------------------- /bin/formidablejs/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { Application, Command } = require('@formidablejs/console') 4 | const { Build } = require('./Commands/Build') 5 | const { Start } = require('./Commands/Start') 6 | const { default: version } = require('../../lib/Support/Helpers/version') 7 | 8 | const app = new Application('The Formidable Framework Internal Build Tool', version()) 9 | 10 | app.register(Build) 11 | app.register(Start) 12 | 13 | app.run() 14 | -------------------------------------------------------------------------------- /bin/formidablejs/runtime.js: -------------------------------------------------------------------------------- 1 | const getRuntime = () => { 2 | const args = process.argv; 3 | let runtime = 'node'; 4 | 5 | if (args) { 6 | const executor = args[0].split('/').pop(); 7 | 8 | if (executor != undefined) { 9 | runtime = executor; 10 | } 11 | } 12 | 13 | return runtime; 14 | } 15 | 16 | module.exports = { getRuntime } 17 | -------------------------------------------------------------------------------- /bin/jest/preprocessor.js: -------------------------------------------------------------------------------- 1 | const { join } = require('path') 2 | const { spawnSync } = require('child_process') 3 | 4 | module.exports = { 5 | process(src, fileName, config, options) { 6 | const imbac = join('node_modules', '.bin', 'imbac') 7 | 8 | const data = spawnSync(imbac, [fileName, '--platform=node', '--format=cjs', '--print'], { 9 | cwd: process.cwd(), 10 | env: process.env, 11 | stdio: 'pipe', 12 | encoding: 'utf-8' 13 | }) 14 | 15 | return { code: data.stdout } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /formidable/auth/imba/test/app.e2e.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Application (e2e)', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (GET: Welcome)', do 18 | supertest(app.server) 19 | .get('/') 20 | .expect(200) 21 | .expect(do(res) 22 | expect(res.text).toContain('Your app is ready with Auth scaffolding') 23 | ) 24 | -------------------------------------------------------------------------------- /formidable/auth/ts/test/app.e2e.test.ts: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe('Application (e2e)', () => { 5 | let app 6 | 7 | beforeAll(async () => { 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | }) 14 | 15 | afterAll(async () => { 16 | await app.close() 17 | }) 18 | 19 | it('/ (GET: Welcome)', async () => { 20 | supertest(app.server) 21 | .get('/') 22 | .expect(200) 23 | .expect((res) => { 24 | expect(res.text).toContain('Your app is ready with Auth scaffolding') 25 | }) 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /formidable/web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/formidablejs/framework/686da7aaa9bc155851ebd04e4d89999742c97ad1/formidable/web/public/favicon.ico -------------------------------------------------------------------------------- /formidable/web/public/formidable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/formidablejs/framework/686da7aaa9bc155851ebd04e4d89999742c97ad1/formidable/web/public/formidable.png -------------------------------------------------------------------------------- /formidable/web/resolvers/imba/RouterServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import { AuthService as Auth } from '@formidablejs/framework' 2 | import { Route } from '@formidablejs/framework' 3 | import { ServiceResolver } from '@formidablejs/framework' 4 | 5 | export class RouterServiceResolver < ServiceResolver 6 | 7 | def boot 8 | Route.group { middleware: ['session'] }, do 9 | Auth.routes! 10 | 11 | require '../../routes/web' 12 | 13 | Route.group { prefix: 'api', middleware: ['jwt'] }, do 14 | require '../../routes/api' 15 | 16 | self 17 | -------------------------------------------------------------------------------- /formidable/web/resolvers/ts/RouterServiceResolver.ts: -------------------------------------------------------------------------------- 1 | import { AuthService as Auth } from '@formidablejs/framework' 2 | import { Route } from '@formidablejs/framework' 3 | import { ServiceResolver } from '@formidablejs/framework' 4 | 5 | export class RouterServiceResolver extends ServiceResolver { 6 | boot(): RouterServiceResolver { 7 | Route.group({ middleware: ['session'] }, () => { 8 | Auth.routes() 9 | 10 | require('../../routes/web') 11 | }) 12 | 13 | Route.group({ prefix: 'api', middleware: ['jwt'] }, () => { 14 | require('../../routes/api') 15 | }) 16 | 17 | return this 18 | } 19 | } -------------------------------------------------------------------------------- /formidable/web/routes/imba/api.imba: -------------------------------------------------------------------------------- 1 | import { Request } from '@formidablejs/framework' 2 | import { Route } from '@formidablejs/framework' 3 | 4 | # -------------------------------------------------------------------------- 5 | # API Routes 6 | # -------------------------------------------------------------------------- 7 | # 8 | # Here is where you can register API routes for your application. These 9 | # routes are loaded by the RouteServiceResolver within a group which 10 | # is assigned the "jwt" middleware group. 11 | 12 | Route.get('/user', do(request\Request) 13 | without(request.auth!.user!, [ 14 | 'password', 'remember_token' 15 | ]) 16 | ).middleware(['auth']) 17 | -------------------------------------------------------------------------------- /formidable/web/routes/imba/web.imba: -------------------------------------------------------------------------------- 1 | import { Request } from '@formidablejs/framework' 2 | import { Route } from '@formidablejs/framework' 3 | import { Welcome } from '../resources/views/welcome' 4 | 5 | # -------------------------------------------------------------------------- 6 | # Web Routes 7 | # -------------------------------------------------------------------------- 8 | # 9 | # Here is where you can register web routes for your application. These 10 | # routes are loaded by the RouteServiceResolver within a group which 11 | # is assigned the "session" middleware group. 12 | 13 | Route.get '/', do(request\Request) 14 | view(Welcome, { 15 | locale: request.locale! 16 | formidableVersion: request.version 17 | nodeVersion: process.version 18 | }) 19 | -------------------------------------------------------------------------------- /formidable/web/routes/ts/api.ts: -------------------------------------------------------------------------------- 1 | import { Request } from '@formidablejs/framework' 2 | import { Route } from '@formidablejs/framework' 3 | 4 | /** 5 | * -------------------------------------------------------------------------- 6 | * API Routes 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Here is where you can register API routes for your application. These 10 | * routes are loaded by the RouteServiceResolver within a group which 11 | * is assigned the "jwt" middleware group. 12 | */ 13 | 14 | Route.get('/user', (request: Request) => { 15 | return without(request.user(), [ 16 | 'password', 'remember_token' 17 | ]) 18 | }).middleware(['auth']) 19 | -------------------------------------------------------------------------------- /formidable/web/routes/ts/web.ts: -------------------------------------------------------------------------------- 1 | import { Request } from '@formidablejs/framework' 2 | import { Route } from '@formidablejs/framework' 3 | import { Welcome } from '../resources/views/welcome' 4 | 5 | /** 6 | * -------------------------------------------------------------------------- 7 | * Web Routes 8 | * -------------------------------------------------------------------------- 9 | * 10 | * Here is where you can register web routes for your application. These 11 | * routes are loaded by the RouteServiceResolver within a group which 12 | * is assigned the "session" middleware group. 13 | */ 14 | 15 | Route.get('/', (request: Request) => { 16 | return view(Welcome, { 17 | locale: request.locale(), 18 | formidableVersion: request.version, 19 | nodeVersion: process.version 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /formidable/web/test/imba/app.e2e.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Application (e2e)', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (GET: Welcome)', do 18 | supertest(app.server) 19 | .get('/') 20 | .expect(200) 21 | .expect(do(res) 22 | expect(res.text).toContain('Yey! You have successfully created a new Formidable project') 23 | ) 24 | -------------------------------------------------------------------------------- /formidable/web/test/ts/app.e2e.test.ts: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe('Application (e2e)', () => { 5 | let app 6 | 7 | beforeAll(async () => { 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | }) 14 | 15 | afterAll(async () => { 16 | await app.close() 17 | }) 18 | 19 | it('/ (GET: Welcome)', async () => { 20 | supertest(app.server) 21 | .get('/') 22 | .expect(200) 23 | .expect((res) => { 24 | expect(res.text).toContain('Yey! You have successfully created a new Formidable project') 25 | }) 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /scripts/0-package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | OUTPUT=${PWD}/output 4 | 5 | echo "Create npm ackage..." 6 | echo 7 | 8 | if [ ! -d $OUTPUT ] 9 | then 10 | mkdir $OUTPUT 11 | fi 12 | 13 | cd $OUTPUT && \ 14 | mv ${PWD}/$(npm pack ../ | tail -n 1) package.tgz 15 | -------------------------------------------------------------------------------- /scripts/1-fetch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | E2E=${PWD}/test/e2e 4 | TEST=${PWD}/test 5 | 6 | echo 7 | echo "Fetch Formidable Skeleton..." 8 | echo 9 | 10 | if [ -d $E2E ] 11 | then 12 | rm $E2E 13 | fi 14 | 15 | cd $TEST && \ 16 | curl -L -O https://github.com/formidablejs/formidablejs/archive/refs/heads/dev.zip && \ 17 | unzip dev.zip -d . && \ 18 | rm -rf e2e && \ 19 | mv formidablejs-dev e2e && \ 20 | rm dev.zip 21 | -------------------------------------------------------------------------------- /scripts/3-copy-test-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | E2E=${PWD}/test/e2e 4 | 5 | if [ ! -d $E2E ] 6 | then 7 | echo "e2e test app does not exist." 8 | exit 1 9 | fi 10 | 11 | echo 12 | echo "Copy files..." 13 | echo 14 | 15 | cp -r ./scripts/e2e ./test 16 | -------------------------------------------------------------------------------- /scripts/5-clean-up.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Clean up..." 4 | 5 | OUTPUT=${PWD}/output 6 | E2E=${PWD}/test/e2e 7 | 8 | if [ -f $OUTPUT ] 9 | then 10 | rm $OUTPUT 11 | fi 12 | 13 | if [ -f $E2E ] 14 | then 15 | rm $E2E 16 | fi 17 | -------------------------------------------------------------------------------- /scripts/e2e/app/Http/Controllers/PostController.imba: -------------------------------------------------------------------------------- 1 | import { @use } from '@formidablejs/framework' 2 | import { Request } from '@formidablejs/framework' 3 | import { Controller } from './Controller' 4 | import { DB } from '@formidablejs/framework' 5 | import { StorePostRequest } from '../Request/StorePostRequest' 6 | 7 | export class PostController < Controller 8 | 9 | def index 10 | await DB.table('posts') 11 | 12 | @use(Request) 13 | def show request\Request 14 | const post = await DB.table('posts').where('id', request.param('id')).first! 15 | 16 | if !post then self.notFound 'Post not found.' 17 | 18 | post 19 | 20 | @use(StorePostRequest) 21 | def store request\StorePostRequest 22 | request.persist! 23 | -------------------------------------------------------------------------------- /scripts/e2e/app/Http/Request/StorePostRequest.imba: -------------------------------------------------------------------------------- 1 | import { DB } from '@formidablejs/framework' 2 | import { FormRequest } from '@formidablejs/framework' 3 | 4 | export class StorePostRequest < FormRequest 5 | 6 | def authorize 7 | true 8 | 9 | def rules 10 | { 11 | body: 'string|min:4|required' 12 | } 13 | 14 | def persist 15 | DB.table('posts').insert({ 16 | body: this.input('body') 17 | }) 18 | -------------------------------------------------------------------------------- /scripts/e2e/app/Resolvers/AppServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import { AuthService as Auth } from '@formidablejs/framework' 2 | import { ServiceResolver } from '@formidablejs/framework' 3 | 4 | export class AppServiceResolver < ServiceResolver 5 | 6 | def boot 7 | self 8 | -------------------------------------------------------------------------------- /scripts/e2e/database/migrations/20211126141343_create_posts_table.js: -------------------------------------------------------------------------------- 1 | exports.up = (knex) => { 2 | return knex.schema.createTable('posts', (table) => { 3 | table.increments('id').primary(); 4 | table.string('body'); 5 | table.timestamps(true, true); 6 | }); 7 | }; 8 | 9 | exports.down = (knex) => knex.schema.dropTable('posts'); 10 | -------------------------------------------------------------------------------- /scripts/e2e/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | const runtime = () => { 2 | const isInstalled = (cmd) => { 3 | try { 4 | execSync(`${cmd} -v`, { stdio: 'ignore' }); 5 | return true; 6 | } catch { 7 | return false; 8 | } 9 | }; 10 | 11 | if (isInstalled('bun')) return 'bun'; 12 | if (isInstalled('node')) return 'node'; 13 | 14 | throw new Error('Neither Node.js nor Bun is installed. Please install one of them.'); 15 | }; 16 | 17 | console.log(`Using runtime: ${runtime()}\n`); 18 | 19 | module.exports = { 20 | apps: [ 21 | { 22 | name: 'app', 23 | script: `${runtime} craftsman serve --port=3000 --addr`, 24 | time: true, 25 | error_file: "./error.log", 26 | out_file: "./log.log" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /scripts/e2e/routes/api.imba: -------------------------------------------------------------------------------- 1 | import { PostController } from '../app/Http/Controllers/PostController' 2 | import { Request } from '@formidablejs/framework' 3 | import { Route } from '@formidablejs/framework' 4 | import { response } from '@formidablejs/framework' 5 | 6 | Route.get('/', do(request\Request) 7 | request.translate 'index.hello', 'Hello World' 8 | ).name('hello').middleware(['lang']) 9 | 10 | # add posts routes. 11 | Route.group { prefix: 'posts' }, do 12 | Route.get '/', [PostController, 'index'] 13 | Route.get '/:id', [PostController, 'show'] 14 | Route.put '/', [PostController, 'store'] 15 | 16 | Route.group { prefix: 'routes' }, do 17 | Route.get 'invoke', class invokable 18 | def __invoke 19 | 'hello' 20 | 21 | Route.get 'function', do 22 | 'hello' 23 | 24 | Route.get '/json-response', do 25 | response().json({ 26 | message: "Hello world" 27 | }, 201) -------------------------------------------------------------------------------- /scripts/e2e/test/app.e2e.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Application (e2e)', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (GET: Hello World)', do 18 | supertest(app.server) 19 | .get('/') 20 | .set('Accept-Language', 'en') 21 | .expect(200) 22 | .expect('Hello World') 23 | 24 | it '/ (GET: Hola Mundo)', do 25 | supertest(app.server) 26 | .get('/') 27 | .set('Accept-Language', 'es') 28 | .expect(200) 29 | .expect('Hola Mundo') 30 | -------------------------------------------------------------------------------- /scripts/e2e/test/database.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Database', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (PUT: Create Post)', do 18 | supertest(app.server) 19 | .put('/posts') 20 | .send({ body: 'hello world' }) 21 | .expect(200) 22 | 23 | it '/ (GET: Fetch all posts)', do 24 | supertest(app.server) 25 | .get('/posts') 26 | .expect(200) 27 | 28 | it '/ (GET: Fetch 1 post)', do 29 | supertest(app.server) 30 | .get('/posts/1') 31 | .expect(200) 32 | 33 | it '/ (GET: Fetch 1 post) - throw error', do 34 | supertest(app.server) 35 | .get('/posts/100000') 36 | .expect(404) 37 | -------------------------------------------------------------------------------- /scripts/e2e/test/language.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Language', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (GET: Hello World)', do 18 | supertest(app.server) 19 | .get('/') 20 | .set('Accept-Language', 'en') 21 | .expect(200) 22 | .expect('Hello World') 23 | 24 | it '/ (GET: Hola Mundo)', do 25 | supertest(app.server) 26 | .get('/') 27 | .set('Accept-Language', 'es') 28 | .expect(200) 29 | .expect('Hola Mundo') 30 | -------------------------------------------------------------------------------- /scripts/e2e/test/responses.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Responses', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/json-response (GET)', do 18 | supertest(app.server) 19 | .get('/json-response') 20 | .expect(201) 21 | .expect({ 22 | message: "Hello world" 23 | }) 24 | -------------------------------------------------------------------------------- /scripts/e2e/test/routes.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Routes', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (GET: hello)', do 18 | supertest(app.server) 19 | .get('/routes/invoke') 20 | .expect(200) 21 | .expect('hello') 22 | 23 | it '/ (GET: hello)', do 24 | supertest(app.server) 25 | .get('/routes/function') 26 | .expect(200) 27 | .expect('hello') 28 | -------------------------------------------------------------------------------- /scripts/e2e/test/validation.test.imba: -------------------------------------------------------------------------------- 1 | const formidable = require('../.formidable/build').default 2 | const supertest = require('supertest') 3 | 4 | describe 'Validation', do 5 | let app 6 | 7 | beforeAll do 8 | const application = await formidable 9 | 10 | app = application.fastify() 11 | 12 | await app.ready() 13 | 14 | afterAll do 15 | await app.close() 16 | 17 | it '/ (PUT: Create Post: throw 422) - no body', do 18 | supertest(app.server) 19 | .put('/posts') 20 | .send() 21 | .expect(422) 22 | 23 | it '/ (PUT: Create Post: throw 422) - min error', do 24 | supertest(app.server) 25 | .put('/posts') 26 | .send({ body: 'str' }) 27 | .expect(422) 28 | -------------------------------------------------------------------------------- /scripts/server-command-replace.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FILE=${PWD}/lib/Foundation/Console/Commands/ServeCommand.js 4 | 5 | if [[ $OSTYPE == 'darwin'* ]]; then 6 | sed -i '' -e 's/return self.gracefulShutdown/gracefulShutdown/g' $FILE 7 | else 8 | sed -i -e 's/return self.gracefulShutdown/gracefulShutdown/g' $FILE 9 | fi 10 | -------------------------------------------------------------------------------- /src/Auth/AuthenticationServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import Auth from './Auth' 2 | import ConfigRepository from '../Config/Repository' 3 | import ServiceResolver from '../Support/ServiceResolver' 4 | 5 | export default class AuthenticationServiceResolver < ServiceResolver 6 | 7 | static get runInCli 8 | false 9 | 10 | get protocol 11 | const default = self.app.make(ConfigRepository).get 'auth.defaults.protocol' 12 | 13 | self.app.make(ConfigRepository).get "auth.protocols.{default}.provider" 14 | 15 | get provider 16 | self.app.make(ConfigRepository).get "auth.providers.{self.protocol}" 17 | 18 | def boot 19 | Auth.setProvider self.provider 20 | -------------------------------------------------------------------------------- /src/Auth/Authorize.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from './DriverManager' 2 | 3 | export default class Authorize 4 | 5 | def constructor user 6 | self._user = user 7 | 8 | static def user user 9 | new self(user) 10 | 11 | def on protocol 12 | self._protocol = protocol 13 | 14 | self 15 | 16 | def using request 17 | self._request = request 18 | 19 | self 20 | 21 | def for duration, abilities = ['*'] 22 | let provider = 'manual' 23 | 24 | try 25 | provider = this._request.config.get "auth.protocols.{protocol}.provider" 26 | 27 | const date = new Date() 28 | const ttl = new Date(date.valueOf() + this._request.config.get('session.lifetime', duration)) 29 | 30 | self.getDriver().attempt("auth:{provider}", this._user, ttl.valueOf(), abilities) 31 | 32 | def getDriver 33 | DriverManager.get(this._protocol, this._request, this._request.reply, null, this._request.config) 34 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/AuthenticationException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class AuthenticationException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/AuthorizationException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from '../../Http/Exceptions/HttpException' 2 | 3 | class AuthorizationException < HttpException 4 | 5 | prop status = 401 6 | 7 | export default AuthorizationException 8 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/EmailNotVerifiedException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from '../../Http/Exceptions/HttpException' 2 | 3 | class EmailNotVerifiedException < HttpException 4 | 5 | prop status = 403 6 | 7 | export default EmailNotVerifiedException 8 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/EmailVerifiedException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from '../../Http/Exceptions/HttpException' 2 | 3 | class EmailVerifiedException < HttpException 4 | 5 | prop status = 403 6 | 7 | export default EmailVerifiedException 8 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/UnauthenticatedException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UnauthenticatedException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/UnsupportedAuthDriverException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UnsupportedAuthDriverException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Auth/Exceptions/index.imba: -------------------------------------------------------------------------------- 1 | import AuthenticationException from './AuthenticationException' 2 | import AuthorizationException from './AuthorizationException' 3 | import EmailNotVerifiedException from './EmailNotVerifiedException' 4 | import EmailVerifiedException from './EmailVerifiedException' 5 | import UnauthenticatedException from './UnauthenticatedException' 6 | import UnsupportedAuthDriverException from './UnsupportedAuthDriverException' 7 | 8 | export { 9 | AuthenticationException 10 | AuthorizationException 11 | EmailNotVerifiedException 12 | EmailVerifiedException 13 | UnauthenticatedException 14 | UnsupportedAuthDriverException 15 | } 16 | -------------------------------------------------------------------------------- /src/Auth/Http/Controllers/LoginController.imba: -------------------------------------------------------------------------------- 1 | import LoginRequest from '../Requests/LoginRequest' 2 | import Controller from '../../../Http/Controller' 3 | import { @use } from '../../../Support/Decorators/use' 4 | 5 | const loginAuth = { 6 | onLogin: null 7 | } 8 | 9 | class LoginController < Controller 10 | 11 | @use(LoginRequest) 12 | def login request\LoginRequest, reply 13 | const handler = loginAuth.onLogin 14 | 15 | if handler then return handler(request, reply) 16 | 17 | request.persist! 18 | 19 | static def onLogin handler\function 20 | if loginAuth.onLogin !== null 21 | throw new Error 'onLogin handler is already set.' 22 | 23 | return 24 | 25 | loginAuth.onLogin = handler 26 | 27 | export default LoginController 28 | -------------------------------------------------------------------------------- /src/Auth/Http/Controllers/LogoutController.imba: -------------------------------------------------------------------------------- 1 | import LogoutRequest from '../Requests/LogoutRequest' 2 | import Controller from '../../../Http/Controller' 3 | import { @use } from '../../../Support/Decorators/use' 4 | 5 | const logoutAuth = { 6 | onLogout: null 7 | } 8 | 9 | class LogoutController < Controller 10 | 11 | @use(LogoutRequest) 12 | def logout request\LogoutRequest, reply 13 | const handler = logoutAuth.onLogout 14 | 15 | if handler then return handler(request, reply) 16 | 17 | request.persist! 18 | 19 | static def onLogout handler\function 20 | if logoutAuth.onLogout !== null 21 | throw new Error 'onLogout handler is already set.' 22 | 23 | return 24 | 25 | logoutAuth.onLogout = handler 26 | 27 | export default LogoutController 28 | -------------------------------------------------------------------------------- /src/Auth/Http/Controllers/RegisterController.imba: -------------------------------------------------------------------------------- 1 | import RegisterRequest from '../Requests/RegisterRequest' 2 | import Controller from '../../../Http/Controller' 3 | import { @use } from '../../../Support/Decorators/use' 4 | 5 | const registerAuth = { 6 | onRegister: null 7 | onRegistered: null 8 | } 9 | 10 | class RegisterController < Controller 11 | 12 | @use(RegisterRequest) 13 | def register request\RegisterRequest, reply 14 | const handler = registerAuth.onRegister 15 | 16 | if handler then return handler(request, reply) 17 | 18 | request.persist! 19 | 20 | static def onRegister handler\function 21 | if registerAuth.onRegister !== null 22 | throw new Error 'onRegister handler is already set.' 23 | 24 | return 25 | 26 | registerAuth.onRegister = handler 27 | 28 | export default RegisterController 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeForgot.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const password = { 4 | beforeForgot: null 5 | } 6 | 7 | export default class BeforeForgot 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = password.beforeForgot 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeForgot handler\function 25 | if password.beforeForgot !== null 26 | throw new Error 'beforeForgot handler is already set.' 27 | 28 | password.beforeForgot = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeLogin.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const loginAuth = { 4 | beforeLogin: null 5 | } 6 | 7 | export default class BeforeLogin 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = loginAuth.beforeLogin 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeLogin handler\function 25 | if loginAuth.beforeLogin !== null 26 | throw new Error 'beforeLogin handler is already set.' 27 | 28 | loginAuth.beforeLogin = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeLogout.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const logoutAuth = { 4 | beforeLogout: null 5 | } 6 | 7 | export default class BeforeLogout 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = logoutAuth.beforeLogout 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeLogout handler\function 25 | if logoutAuth.beforeLogout !== null 26 | throw new Error 'beforeLogout handler is already set.' 27 | 28 | logoutAuth.beforeLogout = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeRegister.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const registerAuth = { 4 | beforeRegister: null 5 | } 6 | 7 | export default class BeforeRegister 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = registerAuth.beforeRegister 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeRegister handler\function 25 | if registerAuth.beforeRegister !== null 26 | throw new Error 'beforeRegister handler is already set' 27 | 28 | registerAuth.beforeRegister = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeResend.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const emailVerification = { 4 | beforeResend: null 5 | } 6 | 7 | export default class BeforeResend 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = emailVerification.beforeResend 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeResend handler\function 25 | if emailVerification.beforeResend !== null 26 | throw new Error 'beforeResend handler is already set' 27 | 28 | emailVerification.beforeResend = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeReset.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const password = { 4 | beforeReset: null 5 | } 6 | 7 | export default class BeforeReset 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = password.beforeReset 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeReset handler\function 25 | if password.beforeReset !== null 26 | throw new Error 'beforeReset handler is already set.' 27 | 28 | password.beforeReset = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Middleware/BeforeVerify.imba: -------------------------------------------------------------------------------- 1 | import DriverManager from '../../DriverManager' 2 | 3 | const emailVerification = { 4 | beforeVerify: null 5 | } 6 | 7 | export default class BeforeVerify 8 | 9 | def constructor config 10 | this.config = config 11 | 12 | def handle request, reply, params\any[] 13 | const handler = emailVerification.beforeVerify 14 | 15 | if handler then handler(request,reply,params, self.config) 16 | 17 | const [ protocol ] = params[0] != undefined ? params : [ self.defaultProtocol ] 18 | 19 | request.authDriver = DriverManager.get(protocol, request, reply, params, self.config) 20 | 21 | get defaultProtocol 22 | self.config.get('auth.defaults.protocol', 'api') 23 | 24 | static def beforeVerify handler\function 25 | if emailVerification.beforeVerify !== null 26 | throw new Error 'beforeVerify handler is already set' 27 | 28 | emailVerification.beforeVerify = handler 29 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/EmailResendRequest.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from '../../../Http/Request/FormRequest' 2 | 3 | export default class EmailResendRequest < FormRequest 4 | 5 | def authorize 6 | true 7 | 8 | def rules 9 | { 10 | email: 'required|email' 11 | } 12 | 13 | def persist 14 | await self.authDriver.requestEmailVerificationUrl(self.body!) 15 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/ForgotPasswordRequest.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from '../../../Http/Request/FormRequest' 2 | 3 | export default class ForgotPasswordRequest < FormRequest 4 | 5 | def authorize 6 | true 7 | 8 | def rules 9 | { 10 | email: 'required|email' 11 | } 12 | 13 | def persist 14 | await self.authDriver.requestForgotPasswordUrl(self.body!) 15 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/LoginRequest.imba: -------------------------------------------------------------------------------- 1 | import type Driver from '../../Drivers/Driver' 2 | import type JwtDriver from '../../Drivers/JwtDriver' 3 | import type SessionDriver from '../../Drivers/SessionDriver' 4 | import FormRequest from '../../../Http/Request/FormRequest' 5 | 6 | export default class LoginRequest < FormRequest 7 | 8 | prop authDriver\Driver|SessionDriver|JwtDriver 9 | 10 | def authorize 11 | true 12 | 13 | def rules 14 | const identifier = this.authDriver.getProvider.identifier ?? 'email' 15 | 16 | let rules = { 17 | email: 'required|email' 18 | password: 'required' 19 | remember_me: 'boolean' 20 | } 21 | 22 | if identifier != 'email' 23 | rules = { 24 | username: 'required' 25 | password: 'required' 26 | remember_me: 'boolean' 27 | } 28 | 29 | rules 30 | 31 | def persist 32 | await self.authDriver.authenticate(self.body!) 33 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/LogoutRequest.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from '../../../Http/Request/FormRequest' 2 | 3 | export default class LogoutRequest < FormRequest 4 | 5 | def authorize 6 | true 7 | 8 | def rules 9 | { 10 | # nothing to validate 11 | } 12 | 13 | def persist 14 | await self.authDriver.logout(self.body!) 15 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/RegisterRequest.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from '../../../Http/Request/FormRequest' 2 | import type Driver from '../../Drivers/Driver' 3 | import type JwtDriver from '../../Drivers/JwtDriver' 4 | import type SessionDriver from '../../Drivers/SessionDriver' 5 | 6 | export default class RegisterRequest < FormRequest 7 | 8 | prop authDriver\Driver|SessionDriver|JwtDriver 9 | 10 | def authorize 11 | true 12 | 13 | def rules 14 | const identifier = this.authDriver.getProvider.identifier ?? 'email' 15 | 16 | let rules = { 17 | name: 'required' 18 | email: 'required|email' 19 | password: 'required|min:8|confirmed' 20 | password_confirmation: 'required' 21 | } 22 | 23 | if identifier != 'email' 24 | rules.username = 'required|alpha_dash|min:3' 25 | 26 | rules 27 | 28 | def persist 29 | await self.authDriver.register(self.body!) 30 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/ResetPasswordRequest.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from '../../../Http/Request/FormRequest' 2 | 3 | export default class ResetPasswordRequest < FormRequest 4 | 5 | def authorize 6 | true 7 | 8 | def rules 9 | { 10 | password: 'required|min:8|confirmed' 11 | password_confirmation: 'required' 12 | } 13 | 14 | def persist 15 | await self.authDriver.updatePassword(self.body!) 16 | -------------------------------------------------------------------------------- /src/Auth/Http/Requests/VerifyEmailRequest.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from '../../../Http/Request/FormRequest' 2 | 3 | export default class VerifyEmailRequest < FormRequest 4 | 5 | def authorize 6 | true 7 | 8 | def rules 9 | { 10 | # Validation rules 11 | } 12 | 13 | def persist 14 | await self.authDriver.verifyEmail! 15 | -------------------------------------------------------------------------------- /src/Auth/Mail/ResetPassword.imba: -------------------------------------------------------------------------------- 1 | import { Mailable } from '../../Mail/Mailable' 2 | import FormRequest from '../../Http/Request/FormRequest' 3 | 4 | export default class ResetPassword < Mailable 5 | 6 | prop subject\string 7 | prop request\object 8 | 9 | def constructor request\FormRequest 10 | super() 11 | 12 | self.request = request 13 | self.subject = "Forgot Password" 14 | 15 | def render 16 | 'publish @formidablejs/framework and @formidablejs/mailer' 17 | -------------------------------------------------------------------------------- /src/Auth/Mail/VerifyEmail.imba: -------------------------------------------------------------------------------- 1 | import { Mailable } from '../../Mail/Mailable' 2 | import FormRequest from '../../Http/Request/FormRequest' 3 | 4 | export default class VerifyEmail < Mailable 5 | 6 | prop subject\string 7 | prop request\FormRequest 8 | prop user\object 9 | 10 | def constructor request\FormRequest, user\object 11 | super() 12 | 13 | self.request = request 14 | self.subject = request.t('auth.email.verify.subject', 'Verify Email Address') 15 | self.user = user 16 | 17 | def render 18 | 'publish @formidablejs/framework and @formidablejs/mailer' 19 | -------------------------------------------------------------------------------- /src/Auth/Mail/index.imba: -------------------------------------------------------------------------------- 1 | import ResetPassword from './ResetPassword' 2 | import VerifyEmail from './VerifyEmail' 3 | 4 | export { 5 | ResetPassword 6 | VerifyEmail 7 | } 8 | -------------------------------------------------------------------------------- /src/Auth/Protocol.imba: -------------------------------------------------------------------------------- 1 | import isEmpty from '../Support/Helpers/isEmpty' 2 | import Auth from './Auth' 3 | import Repository from '../Config/Repository' 4 | 5 | export default class Protocol 6 | 7 | prop config\Repository 8 | 9 | def constructor config\Repository 10 | self.config = config 11 | 12 | static def make config\Repository 13 | new self(config) 14 | 15 | def configure protocol\string 16 | const fetchedProtocol = self.config.get "auth.protocols.{protocol}.provider" 17 | 18 | if isEmpty(fetchedProtocol) 19 | throw new Error "{protocol} is not a valid authentication protocol" 20 | 21 | const provider = self.config.get "auth.providers.{fetchedProtocol}" 22 | 23 | Auth.setProvider provider 24 | -------------------------------------------------------------------------------- /src/Auth/Tokens/PersonalAccessTokenServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import Encrypter from '../../Foundation/Encrypter' 2 | import PersonalAccessToken from './PersonalAccessToken' 3 | import ServiceResolver from '../../Support/ServiceResolver' 4 | 5 | export default class PersonalAccessTokenServiceResolver < ServiceResolver 6 | 7 | def boot 8 | PersonalAccessToken 9 | .setConfig(self.app.config) 10 | .setEncrypter(Encrypter) 11 | -------------------------------------------------------------------------------- /src/Database/Bind.imba: -------------------------------------------------------------------------------- 1 | import isEmpty from '../Support/Helpers/isEmpty' 2 | import Database from './Database' 3 | import type Request from '../Http/Request/Request' 4 | 5 | export default class Bind 6 | prop table\string 7 | prop first\boolean 8 | 9 | def constructor table\string, first\boolean = false 10 | self.table = table 11 | self.first = first 12 | 13 | def handle request\Request, key\number 14 | const param = Object.keys(request.request.params)[key] 15 | 16 | const value = Object.values(request.request.params)[key] 17 | const column = param.split(':')[1] ?? 'id' 18 | 19 | const query = Database.table(table).where(column, value) 20 | 21 | first ? query.first! : query 22 | -------------------------------------------------------------------------------- /src/Database/Seeder.imba: -------------------------------------------------------------------------------- 1 | import Database from './Database' 2 | import isEmpty from '../Support/Helpers/isEmpty' 3 | 4 | export default class Seeder 5 | 6 | def make name\string 7 | if isEmpty(Database) then return false 8 | 9 | Database.seed.make name 10 | 11 | def run config\object = {} 12 | if isEmpty(Database) then return false 13 | 14 | Database.seed.run config 15 | -------------------------------------------------------------------------------- /src/Foundation/Bootstrap.imba: -------------------------------------------------------------------------------- 1 | import fs from 'fs' 2 | import path from 'path' 3 | 4 | export default class Bootstrap 5 | 6 | static def cache location\string, config\object 7 | location = path.join process.cwd!, location 8 | 9 | const directory = path.dirname(location) 10 | 11 | if !fs.existsSync(directory) then fs.mkdirSync(directory, { recursive: true }) 12 | 13 | fs.writeFileSync location, JSON.stringify(config), do(error) 14 | if error then console.warn error 15 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/CacheCommand.imba: -------------------------------------------------------------------------------- 1 | import { unlinkSync, existsSync } from 'fs-extra' 2 | import { Command } from '../Command' 3 | import { join } from 'path' 4 | 5 | export class CacheCommand < Command 6 | 7 | get config 8 | join process.cwd!, 'bootstrap', 'cache', 'config.json' 9 | 10 | get address 11 | join process.cwd!, 'storage', 'framework', 'address.json' 12 | 13 | def cache 14 | self.clear false 15 | 16 | app.cache! 17 | 18 | self.message 'info', 'Configuration cached successfully!' 19 | 20 | self.exit! 21 | 22 | def clear newLine\boolean = true 23 | if existsSync(self.config) then unlinkSync(self.config) 24 | 25 | if existsSync(self.address) then unlinkSync(self.address) 26 | 27 | self.message 'info', 'Configuration address cleared!', false 28 | self.message 'info', 'Configuration cache cleared!', newLine 29 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/ConfigCacheCommand.imba: -------------------------------------------------------------------------------- 1 | import { CacheCommand } from './CacheCommand' 2 | 3 | export class ConfigCacheCommand < CacheCommand 4 | 5 | get signature 6 | 'config:cache' 7 | 8 | get description 9 | 'Create a cache file for faster configuration loading' 10 | 11 | def handle 12 | self.cache! 13 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/ConfigClearCommand.imba: -------------------------------------------------------------------------------- 1 | import { CacheCommand } from './CacheCommand' 2 | 3 | export class ConfigClearCommand < CacheCommand 4 | 5 | get signature 6 | 'config:clear' 7 | 8 | get description 9 | 'Remove the configuration cache file' 10 | 11 | def handle 12 | self.clear! 13 | 14 | self.exit! 15 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/EnvironmentCommand.imba: -------------------------------------------------------------------------------- 1 | import { Command } from '../Command' 2 | import type Application from '../../Application' 3 | 4 | export class EnvironmentCommand < Command 5 | 6 | get signature 7 | 'env' 8 | 9 | get description 10 | 'Display the current framework environment' 11 | 12 | def handle 13 | self.message 'info', "Current application environment: {app.config.get('app.env', 'development')}" 14 | 15 | self.exit! 16 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/InspireCommand.imba: -------------------------------------------------------------------------------- 1 | import { Command } from '../Command' 2 | import { Inspiring } from '../../Inspiring' 3 | 4 | export class InspireCommand < Command 5 | 6 | get signature 7 | 'inspire' 8 | 9 | get description 10 | 'Display an inspiring quote' 11 | 12 | def handle 13 | self.write(Inspiring.formatForConsole(Inspiring.quote)) 14 | 15 | self.exit! 16 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeCommandCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Command from '@formidablejs/stubs/src/stubs/command/command' 4 | 5 | export class MakeCommandCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:command {name} {?--domain}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | domain: Prop.string!.nullable!.description('Domain name') 14 | } 15 | 16 | get description 17 | 'Create a new command class' 18 | 19 | get resource 20 | 'Command' 21 | 22 | get stub 23 | new Command(self.argument('name'), { 24 | domain: self.option('domain', null) 25 | }, 'command', self.language.toLowerCase!) 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeConfigCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Config from '@formidablejs/stubs/src/stubs/config/config' 4 | 5 | export class MakeConfigCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:config {name}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the file') 13 | } 14 | 15 | get description 16 | 'Create a new config file' 17 | 18 | get resource 19 | 'Config' 20 | 21 | get stub 22 | new Config(self.argument('name'), {}, 'config', self.language.toLowerCase!) 23 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeExceptionCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Exception from '@formidablejs/stubs/src/stubs/exception/exception' 4 | 5 | export class MakeExceptionCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:exception {name} {?--domain}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | domain: Prop.string!.nullable!.description('Domain name') 14 | } 15 | 16 | get description 17 | 'Create a new exception class' 18 | 19 | get resource 20 | 'Exception' 21 | 22 | get stub 23 | new Exception(self.argument('name'), { 24 | domain: self.option('domain', null) 25 | }, 'exception', self.language.toLowerCase!) 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeFactoryCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Factory from '@formidablejs/stubs/src/stubs/factory/factory' 4 | 5 | export class MakeFactoryCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:factory {name}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The class of the factory') 13 | } 14 | 15 | get description 16 | 'Create a new factory class' 17 | 18 | get resource 19 | 'Factory' 20 | 21 | get stub 22 | new Factory( 23 | self.argument('name'), 24 | {}, 25 | 'factory', 26 | self.language.toLowerCase! 27 | ) 28 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeMailCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Mail from '@formidablejs/stubs/src/stubs/mail/mail' 4 | 5 | export class MakeMailCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:mail {name} {?--domain}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | domain: Prop.string!.nullable!.description('Domain name') 14 | } 15 | 16 | get description 17 | 'Create a new email class' 18 | 19 | get resource 20 | 'Mail' 21 | 22 | get stub 23 | new Mail(self.argument('name'), { 24 | domain: self.option('domain', null) 25 | }, 'mail', self.language.toLowerCase!) 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeMiddlewareCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Middleware from '@formidablejs/stubs/src/stubs/middleware/middleware' 4 | 5 | export class MakeMiddlewareCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:middleware {name} {?--domain}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | domain: Prop.string!.nullable!.description('Domain name') 14 | } 15 | 16 | get description 17 | 'Create a new middleware class' 18 | 19 | get resource 20 | 'Middleware' 21 | 22 | get stub 23 | new Middleware(self.argument('name'), { 24 | domain: self.option('domain', null) 25 | }, 'middleware', self.language.toLowerCase!) 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeRequestCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Request from '@formidablejs/stubs/src/stubs/request/request' 4 | 5 | export class MakeRequestCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:request {name} {?--domain}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | domain: Prop.string!.nullable!.description('Domain name') 14 | } 15 | 16 | get description 17 | 'Create a new form request class' 18 | 19 | get resource 20 | 'Request' 21 | 22 | get stub 23 | new Request(self.argument('name'), { 24 | domain: self.option('domain', null) 25 | }, 'request', self.language.toLowerCase!) 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeResolverCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Resolver from '@formidablejs/stubs/src/stubs/resolver/resolver' 4 | 5 | export class MakeResolverCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:resolver {name} {?--domain}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | domain: Prop.string!.nullable!.description('Domain name') 14 | } 15 | 16 | get description 17 | 'Create a new resolver class' 18 | 19 | get resource 20 | 'Resolver' 21 | 22 | get stub 23 | new Resolver(self.argument('name'), { 24 | domain: self.option('domain', null) 25 | }, 'resolver', self.language.toLowerCase!) 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeSeederCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Seeder from '@formidablejs/stubs/src/stubs/seeder/seeder' 4 | 5 | export class MakeSeederCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:seeder {name} {?--table}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the seeder') 13 | table: Prop.string!.description('The table to seed to') 14 | } 15 | 16 | get description 17 | 'Create a new seeder file' 18 | 19 | get resource 20 | 'Seeder' 21 | 22 | get stub 23 | new Seeder( 24 | self.argument('name'), 25 | { 26 | table: self.option('table') 27 | }, 28 | 'seeder', 29 | self.language.toLowerCase! 30 | ) 31 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeTagCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import Tag from '@formidablejs/stubs/src/stubs/tag/tag' 4 | 5 | export class MakeTagCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:tag {name}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the tag') 13 | } 14 | 15 | get description 16 | 'Create a new imba tag' 17 | 18 | get resource 19 | 'Tag' 20 | 21 | get stub 22 | new Tag(self.argument('name'), { }, 'tag') 23 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MakeViewCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MakeResourceCommand } from './MakeResourceCommand' 3 | import View from '@formidablejs/stubs/src/stubs/view/view' 4 | 5 | export class MakeViewCommand < MakeResourceCommand 6 | 7 | get signature 8 | 'make:view {name}' 9 | 10 | get props 11 | { 12 | name: Prop.string!.description('The name of the class') 13 | } 14 | 15 | get description 16 | 'Create a new view class' 17 | 18 | get resource 19 | 'View' 20 | 21 | get stub 22 | new View(self.argument('name'), { }, 'view') 23 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MigrateCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MigrateUpCommand } from './MigrateUpCommand' 3 | 4 | export class MigrateCommand < MigrateUpCommand 5 | 6 | get signature 7 | 'migrate {?--migration}' 8 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MigrateDownCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MigrationCommand } from './MigrationCommand' 3 | 4 | export class MigrateDownCommand < MigrationCommand 5 | 6 | get signature 7 | 'migrate:down {?--migration}' 8 | 9 | get props 10 | { 11 | migration: Prop.string!.alias('m').nullable!.description 'Migration file to run' 12 | } 13 | 14 | get description 15 | 'Reverse migration(s)' 16 | 17 | def handle 18 | call 'down' 19 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MigrateLatestCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MigrationCommand } from './MigrationCommand' 3 | 4 | export class MigrateLatestCommand < MigrationCommand 5 | 6 | get signature 7 | 'migrate:latest' 8 | 9 | get description 10 | 'Run latest migrations' 11 | 12 | def handle 13 | call 'latest' 14 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MigrateRollbackCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MigrationCommand } from './MigrationCommand' 3 | 4 | export class MigrateRollbackCommand < MigrationCommand 5 | 6 | get signature 7 | 'migrate:rollback {?--all}' 8 | 9 | get props 10 | { 11 | all: Prop.boolean!.default(false).description 'Rollback all migrations' 12 | } 13 | 14 | get description 15 | 'Rollback the last or all database migrations' 16 | 17 | def handle 18 | call 'rollback' 19 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/MigrateUpCommand.imba: -------------------------------------------------------------------------------- 1 | import { Prop } from '@formidablejs/console' 2 | import { MigrationCommand } from './MigrationCommand' 3 | 4 | export class MigrateUpCommand < MigrationCommand 5 | 6 | get signature 7 | 'migrate:up {?--migration}' 8 | 9 | get props 10 | { 11 | migration: Prop.string!.alias('m').nullable!.description 'Migration file to run' 12 | } 13 | 14 | get description 15 | 'Run migration(s)' 16 | 17 | def handle 18 | call 'up' 19 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/SessionPruneExpiredCommand.imba: -------------------------------------------------------------------------------- 1 | import Database from '../../../Database/Database' 2 | import { Command } from '../Command' 3 | 4 | export class SessionPruneExpiredCommand < Command 5 | 6 | get signature 7 | 'session:prune-expired' 8 | 9 | get description 10 | 'Prune expired sessions' 11 | 12 | def handle 13 | const total = await Database.table('personal_access_tokens') 14 | .where('name', 'auth:session') 15 | .where('ttl', '<', (new Date!).valueOf!) 16 | .delete! 17 | 18 | if !isNaN(total) 19 | self.message('info', 'Successfully pruned expired sessions') 20 | 21 | return exit! 22 | 23 | self.message('error', 'An error occured while trying to prune expired sessions') 24 | 25 | self.exit! 26 | -------------------------------------------------------------------------------- /src/Foundation/Console/Commands/UpCommand.imba: -------------------------------------------------------------------------------- 1 | import { MaintenanceCommand } from './MaintenanceCommand' 2 | 3 | export class UpCommand < MaintenanceCommand 4 | 5 | get signature 6 | 'up' 7 | 8 | get description 9 | 'Bring the application out of maintenance mode' 10 | 11 | def handle 12 | up! 13 | 14 | self.exit! 15 | -------------------------------------------------------------------------------- /src/Foundation/Console/ServeEvents.imba: -------------------------------------------------------------------------------- 1 | const events = [] 2 | 3 | export class ServeEvents 4 | 5 | static def add callback\Function 6 | events.push callback 7 | 8 | static def get 9 | events 10 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/ApplicationException.imba: -------------------------------------------------------------------------------- 1 | class ApplicationException < Error 2 | prop response 3 | prop status 4 | 5 | def constructor response\any, status\number = 500 6 | super() 7 | 8 | this.response = response 9 | this.status = status 10 | 11 | this.initMessage! 12 | this.initName! 13 | 14 | def initMessage 15 | if this.response !== undefined && this.response !== null 16 | this.message = this.response 17 | 18 | elif this.response.constructor.name 19 | this.message = this.response.constructor.name 20 | .match(/[A-Z][a-z]+|[0-9]+/g) 21 | .join(' ') 22 | 23 | def initName 24 | this.name = this.constructor.name 25 | 26 | def getStatus 27 | this.status 28 | 29 | export default ApplicationException 30 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/DecryptException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class DecryptException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/EncryptException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class EncryptException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/ExitHandlerException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class ExitHandlerException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/InvalidAppKeyException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class InvalidAppKeyException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/InvalidEncryptionKeyTypeException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class InvalidEncryptionKeyTypeException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/InvalidServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class InvalidServiceResolver < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/MaintenanceModeException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from '../../Http/Exceptions/HttpException' 2 | 3 | export default class MaintenanceModeException < HttpException 4 | 5 | prop response\string = 'Service Unavailable' 6 | prop status\number = 503 7 | -------------------------------------------------------------------------------- /src/Foundation/Exceptions/UnserializedEncryptValueException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from './ApplicationException' 2 | 3 | export default class UnserializedEncryptValueException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Hashing/Exceptions/InvalidHashConfigurationException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class InvalidHashConfigurationException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Hashing/Exceptions/InvalidHashDriverException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class InvalidHashDriverException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Hashing/HashServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import ServiceResolver from '../Support/ServiceResolver' 2 | import Hash from './Hash' 3 | 4 | export default class HashServiceResolver < ServiceResolver 5 | 6 | def boot 7 | Hash.configure(self.app.config.get('hashing')) 8 | -------------------------------------------------------------------------------- /src/Http/Exceptions/BadRequestException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from './HttpException' 2 | 3 | class BadRequestException < HttpException 4 | 5 | prop status = 400 6 | 7 | export default BadRequestException 8 | -------------------------------------------------------------------------------- /src/Http/Exceptions/ForbiddenException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from './HttpException' 2 | 3 | class ForbiddenException < HttpException 4 | 5 | prop status = 403 6 | 7 | export default ForbiddenException 8 | -------------------------------------------------------------------------------- /src/Http/Exceptions/HttpException.imba: -------------------------------------------------------------------------------- 1 | import isEmpty from '../../Support/Helpers/isEmpty' 2 | 3 | class HttpException < Error 4 | prop response 5 | prop status = 400 6 | 7 | def constructor response\string, statusCode\number|null = null 8 | super() 9 | 10 | this.response = response 11 | 12 | if !isEmpty(statusCode) then self.status = statusCode 13 | 14 | this.initMessage! 15 | this.initName! 16 | 17 | def initMessage 18 | if this.response !== undefined && this.response !== null 19 | this.message = this.response 20 | 21 | elif this.response !== undefined && this.response !== null && this.response.constructor.name 22 | this.message = this.response.constructor.name 23 | .match(/[A-Z][a-z]+|[0-9]+/g) 24 | .join(' ') 25 | 26 | def initName 27 | this.name = this.constructor.name 28 | 29 | def getStatus 30 | this.status 31 | 32 | export default HttpException 33 | -------------------------------------------------------------------------------- /src/Http/Exceptions/InvalidRouteActionException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class InvalidRouteActionException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/Exceptions/InvalidSignatureException.imba: -------------------------------------------------------------------------------- 1 | import ForbiddenException from './ForbiddenException' 2 | 3 | export default class InvalidSignatureException < ForbiddenException 4 | -------------------------------------------------------------------------------- /src/Http/Exceptions/NotFoundException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from './HttpException' 2 | import { FastifyRequest } from 'fastify' 3 | import FormRequest from '../Request/FormRequest' 4 | import Request from '../Request/Request' 5 | 6 | class NotFoundException < HttpException 7 | 8 | prop status = 404 9 | 10 | static def using request\Request|FormRequest|FastifyRequest 11 | new self(request instanceof FormRequest ? "Route {request.req.method}:{request.req.url} not found." : "Route {request.method}:{request.url} not found.") 12 | 13 | export default NotFoundException 14 | -------------------------------------------------------------------------------- /src/Http/Exceptions/UndefinedMiddlewareException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UndefinedMiddlewareException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/Exceptions/UnsupportedSessionDriverException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UnsupportedSessionDriverException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/Exceptions/index.imba: -------------------------------------------------------------------------------- 1 | import BadRequestException from './BadRequestException' 2 | import ForbiddenException from './ForbiddenException' 3 | import HttpException from './HttpException' 4 | import InvalidSignatureException from './InvalidSignatureException' 5 | import NotFoundException from './NotFoundException' 6 | import UndefinedMiddlewareException from './UndefinedMiddlewareException' 7 | import UnsupportedSessionDriverException from '../Session/Exceptions/UnsupportedSessionDriverException' 8 | 9 | export { 10 | BadRequestException 11 | ForbiddenException 12 | HttpException 13 | InvalidSignatureException 14 | NotFoundException 15 | UndefinedMiddlewareException 16 | UnsupportedSessionDriverException 17 | } 18 | -------------------------------------------------------------------------------- /src/Http/Kernel/getResponse.imba: -------------------------------------------------------------------------------- 1 | import isClass from '../../Support/Helpers/isClass' 2 | 3 | export default def getResponse route\object, request, reply 4 | if route.action instanceof Function && !isClass(route.action, true) 5 | return await route.action request, reply 6 | 7 | let controller 8 | let action 9 | 10 | if !Array.isArray(route.action) 11 | controller = new route.action 12 | action = '__invoke' 13 | else 14 | controller = new route.action[0] 15 | action = route.action[1] 16 | 17 | controller.#request = request 18 | 19 | await controller[action](request, reply) 20 | -------------------------------------------------------------------------------- /src/Http/Kernel/handleNotFound.imba: -------------------------------------------------------------------------------- 1 | import type FormRequest from '../Request/FormRequest' 2 | import NotFoundException from '../Exceptions/NotFoundException' 3 | 4 | export default def handleNotFound request\FormRequest 5 | new NotFoundException "Route {request.method!}:{request.url!} not found." 6 | -------------------------------------------------------------------------------- /src/Http/Kernel/hasContentTypes.imba: -------------------------------------------------------------------------------- 1 | import formbody from '@fastify/formbody' 2 | import multipart from '@fastify/multipart' 3 | 4 | export default def hasContentTypes fastify 5 | fastify.register formbody 6 | fastify.register multipart 7 | 8 | fastify.addContentTypeParser 'application/json', { parseAs: 'string' }, do(req, body, done) 9 | try 10 | done(null, JSON.parse(body)) 11 | catch 12 | done(null, {}) 13 | -------------------------------------------------------------------------------- /src/Http/Middleware.imba: -------------------------------------------------------------------------------- 1 | export default class Middleware 2 | 3 | def handle request, reply 4 | this 5 | -------------------------------------------------------------------------------- /src/Http/Middleware/ConvertEmptyStringsToNull.imba: -------------------------------------------------------------------------------- 1 | import TransformsRequest from './TransformsRequest' 2 | 3 | export default class ConvertEmptyStringsToNull < TransformsRequest 4 | 5 | def transform key, value 6 | value !== '' ? value : null 7 | -------------------------------------------------------------------------------- /src/Http/Middleware/EnsureEmailIsVerified.imba: -------------------------------------------------------------------------------- 1 | import Redirect from '../Redirect/Redirect' 2 | import Request from '../Request/Request' 3 | import EmailNotVerifiedException from '../../Auth/Exceptions/EmailNotVerifiedException' 4 | 5 | export default class EnsureEmailIsVerified 6 | 7 | get redirectToRoute\string 8 | '/email/unverified' 9 | 10 | def handle request\Request, reply, params = [] 11 | if request.auth!.check! && !request.user!.email_verified_at 12 | if request.expectsHtml! && self.redirectToRoute 13 | return self.toHtml(request, reply, params) 14 | 15 | return self.toJson(request, reply, params) 16 | 17 | def toHtml request, reply, params = [] 18 | Redirect.to(this.redirectToRoute) 19 | 20 | def toJson request, reply, params = [] 21 | throw new EmailNotVerifiedException 'Email is not verified.' 22 | -------------------------------------------------------------------------------- /src/Http/Middleware/EnsureStateless.imba: -------------------------------------------------------------------------------- 1 | import type { FastifyReply } from 'fastify' 2 | import type FormRequest from '../Request/FormRequest' 3 | 4 | export default class EnsureStateless 5 | 6 | get strict\boolean 7 | false 8 | 9 | def handle request\FormRequest, reply\FastifyReply, params\any[]|null 10 | reply.setCookie = do null 11 | 12 | if self.strict 13 | try delete request.req.session 14 | try delete request.req.cookies 15 | -------------------------------------------------------------------------------- /src/Http/Middleware/TransformsRequest.imba: -------------------------------------------------------------------------------- 1 | export default class TransformsRequest 2 | 3 | get except 4 | [ 5 | 6 | ] 7 | 8 | def handle request 9 | this.clean request 10 | 11 | def clean request 12 | if (request.request.body && request.request.body.constructor === ({}).constructor) 13 | const results = Object.keys(request.request.body).map do(key) 14 | let value = request.request.body[key] 15 | 16 | if except.includes(key) == false 17 | value = transform(key, request.input(key)) 18 | 19 | { 20 | [key]: value 21 | } 22 | 23 | let output = {} 24 | 25 | try 26 | output = Object.assign(...results) 27 | 28 | request.request.body = output 29 | 30 | def transform key, value 31 | value 32 | -------------------------------------------------------------------------------- /src/Http/Middleware/TrimStrings.imba: -------------------------------------------------------------------------------- 1 | import TransformsRequest from './TransformsRequest' 2 | 3 | export default class TrimStrings < TransformsRequest 4 | 5 | def transform key, value 6 | typeof value == 'string' ? value.trim! : value 7 | -------------------------------------------------------------------------------- /src/Http/Middleware/ValidateSignature.imba: -------------------------------------------------------------------------------- 1 | import querystring from 'querystring' 2 | import jwt from 'jsonwebtoken' 3 | import Encrypter from '../../Foundation/Encrypter' 4 | import InvalidSignatureException from '../Exceptions/InvalidSignatureException' 5 | import type FormRequest from '../Request/FormRequest' 6 | 7 | export default class ValidateSignature 8 | 9 | prop config 10 | 11 | def constructor config 12 | this.config = config 13 | 14 | def handle request\FormRequest 15 | try 16 | const decodedSignature = await jwt.verify(request.signature! ?? '', Encrypter.key!) 17 | 18 | const uri = querystring.unescape(decodedSignature.uri) 19 | 20 | if request.urlWithoutSignature! !== uri 21 | throw new InvalidSignatureException 'Invalid signature.' 22 | 23 | return request 24 | 25 | throw new InvalidSignatureException 'Invalid signature.' 26 | 27 | -------------------------------------------------------------------------------- /src/Http/Request/Exceptions/DestinationExistsException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class DestinationExistsException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/Request/Request.imba: -------------------------------------------------------------------------------- 1 | import FormRequest from './FormRequest' 2 | 3 | export default class Request < FormRequest 4 | -------------------------------------------------------------------------------- /src/Http/Response/JsonResponse.imba: -------------------------------------------------------------------------------- 1 | import type { FastifyReply } from 'fastify' 2 | 3 | export default class JsonResponse 4 | 5 | prop data\object = {} 6 | prop statusCode\number = 200 7 | 8 | def constructor object\object, statusCode\number = 200 9 | self.data = object 10 | self.statusCode = statusCode 11 | 12 | static def make object\object, statusCode\number 13 | new JsonResponse(object, statusCode) 14 | 15 | def code statusCode\number = 200 16 | self.statusCode = statusCode 17 | 18 | self 19 | 20 | def toJson reply\FastifyReply 21 | reply.type('application/json') 22 | reply.code(self.statusCode) 23 | 24 | reply.send(self.data) 25 | -------------------------------------------------------------------------------- /src/Http/Response/Response.imba: -------------------------------------------------------------------------------- 1 | import JsonResponse from './JsonResponse' 2 | import ViewResponse from './ViewResponse' 3 | import type { FastifyReply } from 'fastify' 4 | import type View from '../View/View' 5 | 6 | export default class Response 7 | 8 | prop data\object|null = null 9 | prop statusCode\number = 200 10 | 11 | def constructor data\any = null, statusCode\number = 200 12 | self.data = data 13 | self.statusCode = statusCode 14 | 15 | def json object\object, statusCode\number = 200 16 | JsonResponse.make(object, statusCode) 17 | 18 | def view view\View, data\object|null = null 19 | ViewResponse.make(view, data) 20 | 21 | def code statusCode\number 22 | self.statusCode = statusCode 23 | 24 | self 25 | 26 | def toResponse reply\FastifyReply 27 | reply.code(self.statusCode) 28 | 29 | reply.send(self.data) 30 | -------------------------------------------------------------------------------- /src/Http/Router/Exceptions/InvalidRouteActionException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class InvalidRouteActionException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/Router/Path.imba: -------------------------------------------------------------------------------- 1 | export default class Path 2 | 3 | static def clean prefix\string[], pattern\string 4 | prefix = prefix 5 | .join('/') 6 | .replace /^\s*\/*\s*|\s*\/*\s*$/gm, '' 7 | 8 | pattern = pattern 9 | .replace /^\s*\/*\s*|\s*\/*\s*$/gm, '' 10 | 11 | '/' + "{prefix}/{pattern}".replace /^\s*\/*\s*|\s*\/*\s*$/gm, '' 12 | -------------------------------------------------------------------------------- /src/Http/Session/DriverManager.imba: -------------------------------------------------------------------------------- 1 | import UnsupportedSessionDriverException from './Exceptions/UnsupportedSessionDriverException' 2 | 3 | const drivers = {} 4 | 5 | export default class DriverManager 6 | 7 | static def register name\string, driver\object 8 | drivers[name] = driver 9 | 10 | static def get name\string 11 | const driver = drivers[name] 12 | 13 | if driver == null || driver == undefined 14 | throw new UnsupportedSessionDriverException "{name} is not a supported driver." 15 | 16 | driver 17 | 18 | static def isRegistered name\string 19 | const driver = drivers[name] 20 | 21 | driver !== undefined || driver !== null 22 | 23 | -------------------------------------------------------------------------------- /src/Http/Session/Exceptions/TokenMismatchException.imba: -------------------------------------------------------------------------------- 1 | import ForbiddenException from '../../../Http/Exceptions/ForbiddenException' 2 | 3 | export default class TokenMismatchException < ForbiddenException 4 | -------------------------------------------------------------------------------- /src/Http/Session/Exceptions/UnsupportedSessionDriverException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UnsupportedSessionDriverException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/Session/SessionFileStoreServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import session from '@fastify/session' 2 | import DriverManager from './DriverManager' 3 | import ServiceResolver from '../../Support/ServiceResolver' 4 | import FileStore from 'session-file-store' 5 | 6 | export default class SessionFileStoreServiceResolver < ServiceResolver 7 | 8 | static get runInCli 9 | false 10 | 11 | def boot 12 | if self.app.config.get('session.driver') === 'file' 13 | const store = FileStore(session) 14 | 15 | DriverManager.register('file', new store({ 16 | path: 'storage/sessions' 17 | })) 18 | -------------------------------------------------------------------------------- /src/Http/Session/SessionMemoryStoreServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import session from '@fastify/session' 2 | import DriverManager from './DriverManager' 3 | import ServiceResolver from '../../Support/ServiceResolver' 4 | import MemoryStore from 'memorystore' 5 | 6 | export default class SessionMemoryStoreServiceResolver < ServiceResolver 7 | 8 | static get runInCli 9 | false 10 | 11 | def boot 12 | if self.app.config.get('session.driver') == 'memory' 13 | const store = MemoryStore(session) 14 | 15 | DriverManager.register('memory', new store({ 16 | checkPeriod: 86400000 17 | })) 18 | 19 | self.app.addHook('onClose', do 20 | if DriverManager.isRegistered('memory') then DriverManager.get('memory').stopInterval! 21 | ) 22 | -------------------------------------------------------------------------------- /src/Http/URL/Exceptions/MissingRouteParamException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class MissingRouteParamException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/URL/Exceptions/UnregisteredRouteException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UnregisteredRouteException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Http/View/Exceptions/UndefinedDataPropException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class UndefinedDataPropException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Mail/Mailable.imba: -------------------------------------------------------------------------------- 1 | import { Mailable as MailableBase } from '@formidablejs/mailer' 2 | import { config as ConfigFinder } from '../Support/Helpers/index' 3 | 4 | export class Mailable < MailableBase 5 | 6 | get config 7 | ConfigFinder 8 | -------------------------------------------------------------------------------- /src/Mix/Repository.imba: -------------------------------------------------------------------------------- 1 | import isEmpty from '../Support/Helpers/isEmpty' 2 | import fs from 'fs' 3 | import path from 'path' 4 | 5 | export default class Repository 6 | 7 | static def get file\string 8 | const mixManifest\object|null = self.manifest! 9 | 10 | if isEmpty mixManifest then return file 11 | 12 | mixManifest[file] || file 13 | 14 | static def manifest 15 | const location\string = path.join(process.cwd!, 'public', 'mix-manifest.json') 16 | 17 | if fs.existsSync(location) 18 | const content\string = fs.readFileSync(location, 'utf8') 19 | 20 | return content ? JSON.parse(content) : null 21 | 22 | null 23 | -------------------------------------------------------------------------------- /src/Support/Decorators/context.imba: -------------------------------------------------------------------------------- 1 | import { Context } from '../../Foundation/Context' 2 | 3 | def context target 4 | Context.inject target 5 | 6 | exports.context = context 7 | exports.@context = context 8 | -------------------------------------------------------------------------------- /src/Support/Encryption/Exceptions/MissingAppKeyException.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class MissingAppKeyException < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Support/Helpers/Error/BooleanCastError.imba: -------------------------------------------------------------------------------- 1 | export default class BooleanCastError < Error 2 | 3 | def constructor message\string 4 | super message 5 | 6 | this.message = message 7 | 8 | this.name = 'BooleanCastError' 9 | -------------------------------------------------------------------------------- /src/Support/Helpers/Error/ConfigNotCachedError.imba: -------------------------------------------------------------------------------- 1 | export default class ConfigNotCachedError < Error 2 | 3 | def constructor message\string = 'Config is not cached' 4 | super message 5 | 6 | this.name = 'ConfigNotCachedError' 7 | -------------------------------------------------------------------------------- /src/Support/Helpers/Error/InvalidExitFunction.imba: -------------------------------------------------------------------------------- 1 | import ApplicationException from '../../../Foundation/Exceptions/ApplicationException' 2 | 3 | export default class InvalidExitFunction < ApplicationException 4 | -------------------------------------------------------------------------------- /src/Support/Helpers/asObject.imba: -------------------------------------------------------------------------------- 1 | export default def asObject object\object 2 | let output = new Object 3 | 4 | for own property, value of object 5 | output[property] = value 6 | 7 | output 8 | -------------------------------------------------------------------------------- /src/Support/Helpers/bind.imba: -------------------------------------------------------------------------------- 1 | import Bind from '../../Database/Bind' 2 | 3 | export default def bind table\string, first\boolean = true 4 | new Bind(table, first) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/config.imba: -------------------------------------------------------------------------------- 1 | import ConfigNotCachedError from './Error/ConfigNotCachedError' 2 | import dot from './dotNotation' 3 | import path from 'path' 4 | 5 | def fallback notation\string, default\any = null 6 | try 7 | const app = require('../../Foundation/Application').default 8 | 9 | app.getConfig(notation, default) 10 | catch e 11 | throw new ConfigNotCachedError 12 | 13 | export default def config notation\string, default\any = null 14 | try 15 | const config = require(path.join(process.cwd!, 'bootstrap', 'cache', 'config.json')) 16 | 17 | dot(config, notation) ?? default 18 | catch e 19 | fallback(notation, default) 20 | -------------------------------------------------------------------------------- /src/Support/Helpers/decrypt.imba: -------------------------------------------------------------------------------- 1 | import Encrypter from '../../Foundation/Encrypter' 2 | 3 | export default def decrypt hash\string, unserialize = false 4 | Encrypter.decrypt(hash, unserialize) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/die.imba: -------------------------------------------------------------------------------- 1 | import ExitHandlerException from '../../Foundation/Exceptions/ExitHandlerException' 2 | import InvalidExitFunction from './Error/InvalidExitFunction' 3 | import isFunction from './isFunction' 4 | 5 | export default def die handler 6 | if !(handler.constructor.name === 'AsyncFunction' || isFunction(handler)) 7 | throw new InvalidExitFunction 'Handler must be a valid function.' 8 | 9 | throw new ExitHandlerException handler 10 | -------------------------------------------------------------------------------- /src/Support/Helpers/dotNotation.imba: -------------------------------------------------------------------------------- 1 | import isObject from './isObject' 2 | import isString from './isString' 3 | 4 | export default def dotNotation object\object, key\string 5 | if !isObject object 6 | throw new TypeError 'Expected object' 7 | 8 | if !isString key 9 | throw new TypeError 'Expected string' 10 | 11 | const results = key.split('.').reduce(&, object) do(o, i) 12 | o ? o[i] ?? null : null 13 | 14 | results 15 | -------------------------------------------------------------------------------- /src/Support/Helpers/encrypt.imba: -------------------------------------------------------------------------------- 1 | import Encrypter from '../../Foundation/Encrypter' 2 | 3 | export default def encrypt value\any, serialize = false 4 | Encrypter.encrypt(value, serialize) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/env.imba: -------------------------------------------------------------------------------- 1 | import Application from '../../Foundation/Application' 2 | import isEmpty from './isEmpty' 3 | import isString from './isString' 4 | 5 | export default def env key\string, default\any = null 6 | try Application.getEnv(key, default) 7 | catch 8 | if !isString(key) then throw new TypeError 'Expected string.' 9 | 10 | let output = process.env[key] 11 | 12 | if isString output 13 | const results = output.match(/\$\{(.*?)\}/g) 14 | 15 | if !isEmpty(results) 16 | results.forEach do(variable) 17 | output = output.replace(variable, process.env[variable.slice(2, -1)]) 18 | 19 | if isEmpty(output) then return default 20 | 21 | ['true', 'false'].includes(output.toLowerCase!) ? output = JSON.parse(output) : output 22 | -------------------------------------------------------------------------------- /src/Support/Helpers/expiresIn.imba: -------------------------------------------------------------------------------- 1 | import ms from 'ms' 2 | 3 | export default def expiresIn time\string 4 | "PX {ms(time)}" 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/hashEquals.imba: -------------------------------------------------------------------------------- 1 | import Encrypter from '../../Foundation/Encrypter' 2 | 3 | export default def hashEquals knownString\string, userString\any 4 | Encrypter.hashEquals(knownString, userString) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/imbaEnv.imba: -------------------------------------------------------------------------------- 1 | export default def imbaEnv stringify\boolean = true 2 | const prefix = 'IMBA_APP_' 3 | const envList = {} 4 | 5 | for own env, value of process.env 6 | if env.startsWith(prefix) 7 | envList[env] = value 8 | 9 | stringify ? JSON.stringify(envList) : envList 10 | -------------------------------------------------------------------------------- /src/Support/Helpers/isArray.imba: -------------------------------------------------------------------------------- 1 | export default def isArray object 2 | object !== undefined && object !== null && object.constructor == Array 3 | -------------------------------------------------------------------------------- /src/Support/Helpers/isBoolean.imba: -------------------------------------------------------------------------------- 1 | export default def isBoolean object 2 | object !== undefined && object !== null && object.constructor == Boolean 3 | -------------------------------------------------------------------------------- /src/Support/Helpers/isClass.imba: -------------------------------------------------------------------------------- 1 | export default def isClass object, strict\boolean = false 2 | if strict 3 | if !(object && object.constructor === Function) || object.prototype === undefined 4 | return false 5 | 6 | if Function.prototype !== Object.getPrototypeOf(object) 7 | return true 8 | 9 | return Object.getOwnPropertyNames(object.prototype).length > 1 10 | else 11 | typeof object === 'function' && /^\s*class\s+/.test(object.toString!) 12 | -------------------------------------------------------------------------------- /src/Support/Helpers/isEmpty.imba: -------------------------------------------------------------------------------- 1 | import isObject from './isObject' 2 | import isArray from './isArray' 3 | import isBoolean from './isBoolean' 4 | import isString from './isString' 5 | 6 | export default def isEmpty value\any 7 | if value === null || value === undefined 8 | return true 9 | 10 | if isString(value) && value.trim! === '' 11 | return true 12 | 13 | if isBoolean(value) && value === false 14 | return true 15 | 16 | if (isString(value) || typeof value === 'number') && !isNaN(value) && Number(value) === 0 17 | return true 18 | 19 | if isArray(value) && value.length === 0 20 | return true 21 | 22 | if isObject(value) && Object.keys(value).length === 0 23 | return true 24 | 25 | return false 26 | -------------------------------------------------------------------------------- /src/Support/Helpers/isFunction.imba: -------------------------------------------------------------------------------- 1 | export default def isFunction object 2 | object !== undefined && object !== null && object.constructor == Function 3 | -------------------------------------------------------------------------------- /src/Support/Helpers/isNumber.imba: -------------------------------------------------------------------------------- 1 | export default def isNumber object 2 | object !== undefined && object !== null && object.constructor == Number 3 | -------------------------------------------------------------------------------- /src/Support/Helpers/isObject.imba: -------------------------------------------------------------------------------- 1 | export default def isObject object 2 | object !== undefined && object !== null && object.constructor == Object 3 | -------------------------------------------------------------------------------- /src/Support/Helpers/isString.imba: -------------------------------------------------------------------------------- 1 | export default def isString object 2 | object !== undefined && object !== null && object.constructor == String 3 | -------------------------------------------------------------------------------- /src/Support/Helpers/loadHelpers.imba: -------------------------------------------------------------------------------- 1 | import * as helpers from './index' 2 | 3 | export default def loadHelpers 4 | for own key, value of helpers 5 | if !global[key] && value 6 | global[key] = value 7 | 8 | -------------------------------------------------------------------------------- /src/Support/Helpers/location.imba: -------------------------------------------------------------------------------- 1 | export default def location 2 | const resource = new Promise(do(resolve, reject) resolve(1)) 3 | 4 | try 5 | const kResourceStoreSymbol = Object.getOwnPropertySymbols(resource)[2] 6 | const kResourceStoreValue = resource[kResourceStoreSymbol] 7 | 8 | const locationSymbol = Object.getOwnPropertySymbols(kResourceStoreValue)[1] 9 | const locationValue = kResourceStoreValue[locationSymbol] 10 | 11 | if !locationValue.href 12 | return null 13 | 14 | locationValue 15 | catch error 16 | return null 17 | -------------------------------------------------------------------------------- /src/Support/Helpers/mix.imba: -------------------------------------------------------------------------------- 1 | import Repository from '../../Mix/Repository' 2 | 3 | export default def mix file\string 4 | Repository.get file 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/multitap.imba: -------------------------------------------------------------------------------- 1 | import { InfiniteHigherOrderTapProxy } from '../InfiniteHigherOrderTapProxy' 2 | 3 | export default def multitap object 4 | new InfiniteHigherOrderTapProxy object 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/now.imba: -------------------------------------------------------------------------------- 1 | import Database from '../../Database/Database' 2 | 3 | export default def now 4 | # new Date().toISOString().replace('Z','').replace('T', ' ') 5 | # 'CURRENT_TIMESTAMP' 6 | Database.fn.now! 7 | -------------------------------------------------------------------------------- /src/Support/Helpers/response.imba: -------------------------------------------------------------------------------- 1 | import Response from '../../Http/Response/Response' 2 | 3 | export default def response data\any = null, statusCode\number = 200 4 | new Response(data, statusCode) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/route.imba: -------------------------------------------------------------------------------- 1 | import URL from '../../Http/URL/URL' 2 | 3 | export default def route name, params = {} 4 | URL.route(name, params) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/signedRoute.imba: -------------------------------------------------------------------------------- 1 | import URL from '../../Http/URL/URL' 2 | 3 | export default def signedRoute name, params = {} 4 | URL.signedRoute(name, params) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/singularize.imba: -------------------------------------------------------------------------------- 1 | import pluralize from 'pluralize' 2 | import isString from './isString' 3 | 4 | export default def singularize value\string 5 | if !isString value 6 | throw new TypeError 'value must be a string' 7 | 8 | pluralize.singular(value) 9 | -------------------------------------------------------------------------------- /src/Support/Helpers/slug.imba: -------------------------------------------------------------------------------- 1 | import isString from './isString' 2 | 3 | export default def slug value\string, separator\string = '-', options\object = null 4 | if !isString value 5 | throw new TypeError 'value must be a string' 6 | 7 | if !isString separator 8 | throw new TypeError 'separator must be a string' 9 | 10 | if options && typeof options != 'object' 11 | throw new TypeError 'options must be an object' 12 | 13 | if !options 14 | return value 15 | .normalize('NFD') 16 | .replace(/[\u0300-\u036f]/g, '') 17 | .toLowerCase! 18 | .trim! 19 | .replace(/[^a-z0-9 ]/g, '') 20 | .replace(/\s+/g, separator) 21 | 22 | const lowerCase = options.lowerCase ?? true 23 | 24 | if lowerCase 25 | value = value.toLowerCase! 26 | 27 | value 28 | .normalize('NFD') 29 | .replace(/[\u0300-\u036f]/g, '') 30 | .trim! 31 | .replace(/\s+/g, separator) 32 | .replace(/[0-9 ]/g, '') 33 | -------------------------------------------------------------------------------- /src/Support/Helpers/strRandom.imba: -------------------------------------------------------------------------------- 1 | import isNumber from './isNumber' 2 | import crypto from 'crypto' 3 | 4 | export default def strRandom length\number = 8 5 | if !isNumber length 6 | throw new TypeError 'length must be a number' 7 | 8 | if length % 2 !== 0 9 | throw new RangeError 'length must be an even number' 10 | 11 | crypto.randomBytes(length / 2).toString('hex') 12 | -------------------------------------------------------------------------------- /src/Support/Helpers/tap.imba: -------------------------------------------------------------------------------- 1 | import { HigherOrderTapProxy } from '../HigherOrderTapProxy' 2 | import { isEmpty } from './' 3 | import { isFunction } from './' 4 | 5 | export default def tap object, callback 6 | if !isEmpty(callback) 7 | if !isFunction(callback) then throw TypeError 'Expected a valid function.' 8 | 9 | callback(object) 10 | 11 | return object 12 | 13 | new HigherOrderTapProxy object 14 | -------------------------------------------------------------------------------- /src/Support/Helpers/temporarySignedRoute.imba: -------------------------------------------------------------------------------- 1 | import URL from '../../Http/URL/URL' 2 | 3 | export default def temporarySignedRoute name\string, expiresIn\string, params\object = {} 4 | URL.temporarySignedRoute(name, expiresIn, params) 5 | -------------------------------------------------------------------------------- /src/Support/Helpers/toBoolean.imba: -------------------------------------------------------------------------------- 1 | import isString from './isString' 2 | import BooleanCastError from './Error/BooleanCastError' 3 | 4 | export default def toBoolean value 5 | if typeof value === 'boolean' 6 | return value 7 | 8 | if typeof value === 'number' 9 | return Boolean value 10 | 11 | if isString(value) && ( 12 | value.split!.includes('0') || value.split!.includes('1') 13 | ) 14 | return Boolean value 15 | 16 | if !isString(value) 17 | throw new BooleanCastError("Can't convert {value} to boolean.") 18 | 19 | JSON.parse value.toLowerCase! 20 | -------------------------------------------------------------------------------- /src/Support/Helpers/updateLine.imba: -------------------------------------------------------------------------------- 1 | import { existsSync } from 'fs' 2 | import { readFileSync } from 'fs' 3 | import { writeFileSync } from 'fs' 4 | 5 | export def updateLine file\string, callback\function 6 | if !existsSync(file) then return false 7 | 8 | const contents = readFileSync(file, 'utf8') 9 | const lines = [] 10 | 11 | contents.split('\n').map do(line, index) lines.push callback(line, index) 12 | 13 | writeFileSync file, lines.join('\n'), { encoding: 'utf8' } 14 | 15 | true 16 | -------------------------------------------------------------------------------- /src/Support/Helpers/version.imba: -------------------------------------------------------------------------------- 1 | import fs from 'fs' 2 | import path from 'path' 3 | import { version as frameworkVersion } from '../../../package.json' 4 | 5 | export default def version 6 | frameworkVersion 7 | -------------------------------------------------------------------------------- /src/Support/Helpers/view.imba: -------------------------------------------------------------------------------- 1 | import type View from '../../Http/View/View' 2 | import ViewResponse from '../../Http/Response/ViewResponse' 3 | 4 | export default def view view\View, data\object|null = null 5 | ViewResponse.make(view, data) 6 | -------------------------------------------------------------------------------- /src/Support/Helpers/wildcard.imba: -------------------------------------------------------------------------------- 1 | import isString from './isString' 2 | 3 | export default def wildcard value\string, match\string 4 | if !isString value 5 | throw new TypeError 'value must be a string' 6 | 7 | if !isString match 8 | throw new TypeError 'match must be a string' 9 | 10 | const escapeRegex = do(value) value.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") 11 | 12 | new RegExp("^" + match.split("*").map(escapeRegex).join(".*") + "$").test value 13 | -------------------------------------------------------------------------------- /src/Support/Helpers/without.imba: -------------------------------------------------------------------------------- 1 | import isArray from './isArray' 2 | import isObject from './isObject' 3 | 4 | export default def without object\object, exclude\string[] 5 | if !isObject(object) then throw new TypeError 'Expected object' 6 | 7 | if !isArray(exclude) then throw new TypeError 'Expected array' 8 | 9 | const output = {} 10 | 11 | Object.keys(object).forEach do(key) 12 | if !exclude.includes(key) then Object.assign(output, { 13 | [ key ] : object[key] 14 | }) 15 | 16 | output 17 | -------------------------------------------------------------------------------- /src/Support/HigherOrderTapProxy.imba: -------------------------------------------------------------------------------- 1 | export class HigherOrderTapProxy 2 | 3 | def constructor object 4 | return new Proxy(object, { 5 | get: do(target, prop) 6 | if typeof target[prop] == 'function' 7 | return do(...args) 8 | target[prop].apply( 9 | target, args 10 | ) 11 | 12 | target 13 | 14 | target[prop] 15 | }) 16 | -------------------------------------------------------------------------------- /src/Support/InfiniteHigherOrderTapProxy.imba: -------------------------------------------------------------------------------- 1 | export class InfiniteHigherOrderTapProxy 2 | 3 | def constructor object 4 | return new Proxy(object, { 5 | get: do(target, prop) 6 | if prop == 'untap' then return do target 7 | 8 | if typeof target[prop] == 'function' 9 | return do(...args) 10 | target[prop].apply( 11 | target, args 12 | ) 13 | 14 | this 15 | 16 | target[prop] 17 | }) 18 | -------------------------------------------------------------------------------- /src/Support/Language/Middleware/AcceptLanguage.imba: -------------------------------------------------------------------------------- 1 | export default class AcceptLanguage 2 | 3 | get mappings 4 | { 5 | 6 | } 7 | 8 | def handle request 9 | if request.hasHeader('accept-language') 10 | let language = request.header('accept-language') 11 | 12 | language = language == '*' ? null : language.split(';')[0].trim! 13 | 14 | if language !== null || language !== undefined 15 | request.setLocale(self.getLanguage(request)) 16 | 17 | request 18 | 19 | def getLanguage request 20 | const languageMaps = {} 21 | 22 | for own key, value of self.mappings 23 | languageMaps[key.toLowerCase!] = value 24 | 25 | const locale\string = request.header('accept-language') || '' 26 | 27 | const language\string|undefined = languageMaps[locale.toLowerCase!] 28 | 29 | if language !== undefined 30 | return language 31 | 32 | return request.header('accept-language') 33 | -------------------------------------------------------------------------------- /src/Support/ServiceResolver.imba: -------------------------------------------------------------------------------- 1 | import Application from '../Foundation/Application' 2 | 3 | export default class ServiceResolver 4 | 5 | prop app\Application 6 | 7 | get context 8 | [ 9 | 10 | ] 11 | 12 | def constructor app\Application 13 | self.app = app 14 | 15 | def boot 16 | null 17 | 18 | def register 19 | null 20 | -------------------------------------------------------------------------------- /src/Validator/Exceptions/ValidationException.imba: -------------------------------------------------------------------------------- 1 | import HttpException from '../../Http/Exceptions/HttpException' 2 | 3 | class ValidationException < HttpException 4 | 5 | prop status = 422 6 | 7 | static def withMessages messages\object 8 | return new self({ 9 | message: 'The given data was invalid.' 10 | errors: messages 11 | }) 12 | 13 | export default ValidationException 14 | -------------------------------------------------------------------------------- /src/Validator/Validator.imba: -------------------------------------------------------------------------------- 1 | import FormValidation from '../Http/Request/FormValidation' 2 | 3 | export default class Validator 4 | 5 | static def make body\object, rules\object, messages\object = {} 6 | const validation = this.get! 7 | 8 | new validation(body, rules, messages) 9 | 10 | static def get 11 | validation = (new FormValidation).getValidation! 12 | -------------------------------------------------------------------------------- /test/config/Config.js: -------------------------------------------------------------------------------- 1 | const { ConfigRepository } = require('../../lib'); 2 | 3 | module.exports = class Config extends ConfigRepository { 4 | 5 | /** 6 | * Get registered config. 7 | * 8 | * @return {Object} 9 | */ 10 | get registered() { 11 | return { 12 | app: { 13 | name: 'Test App', 14 | }, 15 | database: { 16 | type: 'sqlite', 17 | file: ':memory:', 18 | }, 19 | }; 20 | } 21 | } -------------------------------------------------------------------------------- /test/config/repository.test.js: -------------------------------------------------------------------------------- 1 | const Config = require('./Config'); 2 | 3 | describe('src/Config/Repository', () => { 4 | let config; 5 | 6 | beforeAll(() => { 7 | config = new Config; 8 | }); 9 | 10 | afterAll(() => { 11 | config = null; 12 | }); 13 | 14 | it('Should return "Test App"', () => { 15 | expect(config.get('app.name')) 16 | .toBe('Test App'); 17 | }); 18 | 19 | it('Should return "Test App"', () => { 20 | expect(config.get('app.names', 'Test App')) 21 | .toBe('Test App'); 22 | }); 23 | 24 | it('Should return true', () => { 25 | expect(config.has('app.name')) 26 | .toBeTruthy(); 27 | }); 28 | 29 | it('Should return false', () => { 30 | expect(config.has('app.names')) 31 | .toBeFalsy(); 32 | }); 33 | 34 | it('Should throw TypeError', () => { 35 | expect(() => { 36 | config.has([]) 37 | }).toThrow(TypeError); 38 | }); 39 | }) 40 | -------------------------------------------------------------------------------- /test/encrypter/encrypter.exceptions.test.js: -------------------------------------------------------------------------------- 1 | const { default: Encrypter } = require("../../lib/Foundation/Encrypter"); 2 | const { default: InvalidAppKeyException } = require("../../lib/Foundation/Exceptions/InvalidAppKeyException"); 3 | 4 | describe('src/Encrypter/Encrypter (Exceptions)', () => { 5 | it('Should throw "InvalidAppKeyException" (encrypt)', () => { 6 | expect(() => { 7 | Encrypter.encrypt('random-string') 8 | }).toThrow(InvalidAppKeyException); 9 | }); 10 | 11 | it('Should throw "InvalidAppKeyException" (decrypt)', () => { 12 | expect(() => { 13 | Encrypter.decrypt('random-string') 14 | }).toThrow(InvalidAppKeyException); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /test/encrypter/encrypter.test.js: -------------------------------------------------------------------------------- 1 | const { default: DecryptException } = require('../../lib/Foundation/Exceptions/DecryptException'); 2 | const Encrypter = require('./setup/Encrypter'); 3 | 4 | describe('src/Encrypter/Encrypter', () => { 5 | it('Should encrypt', () => { 6 | expect(Encrypter.encrypt('Luna')).toEqual(expect.any(String)); 7 | }); 8 | 9 | it('Should decrypt and return "Luna"', () => { 10 | const encrypted = Encrypter.encrypt('Luna'); 11 | 12 | expect(Encrypter.decrypt(encrypted)).toEqual('Luna'); 13 | }); 14 | 15 | it('Should throw "DecryptException"', () => { 16 | expect(() => { 17 | Encrypter.decrypt('random-string') 18 | }).toThrow(DecryptException); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /test/encrypter/setup/Encrypter.js: -------------------------------------------------------------------------------- 1 | const { default: Encrypter }= require('../../../lib/Foundation/Encrypter') 2 | const crypto = require('crypto'); 3 | 4 | /** 5 | * Generate app key. 6 | * 7 | * @returns {String} 8 | */ 9 | const getKey = () => { 10 | const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; 11 | let key = ''; 12 | for (let i = 0; i < 32; i++) { 13 | key += chars.charAt(Math.floor(Math.random() * chars.length)); 14 | } 15 | 16 | return 'base64:' + Buffer.from(key + ':' + crypto.randomBytes(8).toString('hex')).toString('base64'); 17 | } 18 | 19 | Encrypter.configure({ 20 | algorithm: 'AES-256-CBC', 21 | appKey: getKey() 22 | }); 23 | 24 | module.exports = Encrypter; -------------------------------------------------------------------------------- /test/environment/.env: -------------------------------------------------------------------------------- 1 | APP_NAME=Formidable 2 | APP_ENV=testing 3 | -------------------------------------------------------------------------------- /test/environment/repository.test.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { default: Repository } = require('../../lib/Environment/Repository') 3 | 4 | describe('src/Environment/Repository', () => { 5 | /** 6 | * @var {Repository} 7 | */ 8 | let environment; 9 | 10 | beforeAll(() => { 11 | environment = new Repository(path.resolve(__dirname)); 12 | }); 13 | 14 | afterAll(() => { 15 | environment = null 16 | }); 17 | 18 | it('Should return "Formidable"', () => { 19 | expect(environment.get('APP_NAME')).toBe('Formidable') 20 | }) 21 | 22 | it('Should return "null"', () => { 23 | expect(environment.get('RANDOM_ENV_NAME')).toBe(null) 24 | }); 25 | 26 | }); -------------------------------------------------------------------------------- /test/helpers/asObject.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { asObject } } = require('../../lib'); 2 | 3 | describe('Test the asObject helper method.', () => { 4 | test('Should return true if custom object can be casted as an object', () => { 5 | const user = { 6 | name: 'Donald' 7 | }; 8 | 9 | expect(asObject(user)).toEqual({ 10 | name: 'Donald' 11 | }); 12 | }); 13 | }); -------------------------------------------------------------------------------- /test/helpers/config.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { config } } = require('../../lib'); 2 | const { default: ConfigNotCachedError } = require('../../lib/Support/Helpers/Error/ConfigNotCachedError'); 3 | 4 | describe('Test the config helper method.', () => { 5 | 6 | test('Should throw an error if the config is not cached', () => { 7 | expect(() => { 8 | config('app.name') 9 | }).toThrow(ConfigNotCachedError); 10 | }); 11 | 12 | }); -------------------------------------------------------------------------------- /test/helpers/dotNotation.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { dotNotation } } = require('../../lib'); 2 | 3 | const object = { 4 | test: { 5 | string: 'Hello world' 6 | } 7 | }; 8 | 9 | describe('Test the dotNotation helper method', () => { 10 | 11 | test('Should return Hello world', () => { 12 | expect(dotNotation(object, 'test.string')).toBe('Hello world'); 13 | }); 14 | 15 | test('Should return null if the key does not exist', () => { 16 | expect(dotNotation(object, 'test.string2')).toBe(null); 17 | }); 18 | 19 | test('Should throw an error if the object is not a valid object', () => { 20 | expect(() => { 21 | dotNotation(null, 'test.string'); 22 | }).toThrow(TypeError); 23 | }); 24 | 25 | test('Should throw an error if the key is not a valid string notation', () => { 26 | expect(() => { 27 | dotNotation(object, null); 28 | }).toThrow(TypeError); 29 | }); 30 | 31 | }); -------------------------------------------------------------------------------- /test/helpers/isArray.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isArray } } = require('../../lib'); 2 | 3 | describe('Test the isArray helper method.', () => { 4 | 5 | test('Should return true if object is an array', () => { 6 | expect(isArray([])).toBe(true); 7 | }); 8 | 9 | test('Should return false if object is not an array', () => { 10 | expect(isArray({})).toBe(false); 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /test/helpers/isBoolean.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isBoolean } } = require('../../lib'); 2 | 3 | describe('Test the isBoolean helper method.', () => { 4 | 5 | test('Should return true if object is boolean', () => { 6 | expect(isBoolean(true)).toBe(true); 7 | }); 8 | 9 | test('Should return false if object is not a boolean', () => { 10 | expect(isBoolean({})).toBe(false); 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /test/helpers/isClass.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isClass } } = require('../../lib'); 2 | 3 | describe('Test the isClass helper method.', () => { 4 | 5 | test('Should return true if object is a class', () => { 6 | const UserController = class UserController {}; 7 | 8 | expect(isClass(UserController)).toBe(true); 9 | }); 10 | 11 | test('Should return false if object is not a class', () => { 12 | expect(isClass({})).toBe(false); 13 | }); 14 | 15 | }); -------------------------------------------------------------------------------- /test/helpers/isFunction.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isFunction } } = require('../../lib'); 2 | 3 | describe('Test the isFunction helper method.', () => { 4 | 5 | test('Should return true if object is a function', () => { 6 | const func = () => { 7 | console.log('this is a function'); 8 | } 9 | 10 | expect(isFunction(func)).toBe(true); 11 | }); 12 | 13 | test('Should return false if object is not a function', () => { 14 | expect(isFunction({})).toBe(false); 15 | }); 16 | 17 | }); -------------------------------------------------------------------------------- /test/helpers/isNumber.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isNumber } } = require('../../lib'); 2 | 3 | describe('Test the isNumber helper method.', () => { 4 | 5 | test('Should return true if object is a number', () => { 6 | expect(isNumber(1)).toBe(true); 7 | }); 8 | 9 | test('Should return false if object is not a number', () => { 10 | expect(isNumber({})).toBe(false); 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /test/helpers/isObject.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isObject } } = require('../../lib'); 2 | 3 | describe('Test the isObject helper method.', () => { 4 | 5 | test('Should return true if object is a valid object', () => { 6 | expect(isObject({})).toBe(true); 7 | }); 8 | 9 | test('Should return false if object is not a valid object', () => { 10 | expect(isObject(null)).toBe(false); 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /test/helpers/isString.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { isString } } = require('../../lib'); 2 | 3 | describe('Test the isString helper method.', () => { 4 | 5 | test('Should return true if object is a valid string', () => { 6 | expect(isString('Hello world')).toBe(true); 7 | }); 8 | 9 | test('Should return false if object is not a valid string', () => { 10 | expect(isString(null)).toBe(false); 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /test/helpers/multitap.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { multitap } } = require('../../lib'); 2 | 3 | class User { 4 | constructor() { 5 | this.name = null; 6 | this.age = null; 7 | } 8 | 9 | setName(name) { 10 | this.name = name; 11 | } 12 | 13 | setAge(age) { 14 | this.age = age; 15 | } 16 | } 17 | 18 | describe('Test the tap helper method.', () => { 19 | let user; 20 | 21 | beforeAll(() => user = new User()); 22 | 23 | afterAll(() => user = null); 24 | 25 | test('Should return the target object', () => { 26 | expect(multitap(user).setName('Donald')).toBeInstanceOf(User); 27 | expect(multitap(user).setName('Luna').untap()).toBeInstanceOf(User); 28 | }); 29 | 30 | test('Should equal name', () => { 31 | expect(multitap(user).setAge(24).name).toEqual('Luna'); 32 | }); 33 | }); -------------------------------------------------------------------------------- /test/helpers/route.test.js: -------------------------------------------------------------------------------- 1 | const Route = require('../../lib/Http/Router/Route').default; 2 | const { helpers: { route } } = require('../../lib'); 3 | 4 | describe('Test the route helper method.', () => { 5 | beforeAll(() => { 6 | Route.get('url-test', () => {}).name('cool-name') 7 | }) 8 | 9 | test('Should create a URL from a route name', () => { 10 | expect(route('cool-name')).toBe('/url-test'); 11 | }); 12 | }); -------------------------------------------------------------------------------- /test/helpers/signedRoute.test.js: -------------------------------------------------------------------------------- 1 | const URL = require('../../lib/Http/URL/URL').default; 2 | const Route = require('../../lib/Http/Router/Route').default; 3 | const { helpers: { signedRoute } } = require('../../lib'); 4 | 5 | describe('Test the signedRoute helper method.', () => { 6 | beforeAll(() => { 7 | URL.setSecret('random-secret') 8 | Route.get('url-test', () => {}).name('cool-name') 9 | }) 10 | 11 | test('Should create a signed URL from a route name', async () => { 12 | const url = await signedRoute('cool-name'); 13 | 14 | expect(url).toContain('/url-test?signature='); 15 | }); 16 | }); -------------------------------------------------------------------------------- /test/helpers/slug.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { slug } } = require('../../lib'); 2 | 3 | describe('Test the slug helper method.', () => { 4 | test('Should return hello-world', () => { 5 | expect(slug('hello world')).toBe('hello-world'); 6 | }); 7 | 8 | test('Should throw an error if the value is not a valid string', () => { 9 | expect(() => { 10 | slug({}); 11 | }).toThrow(TypeError); 12 | }); 13 | 14 | test('Should throw an error if the separator value is not a valid string', () => { 15 | expect(() => { 16 | slug('hello world', {}); 17 | }).toThrow(TypeError); 18 | }); 19 | 20 | }); -------------------------------------------------------------------------------- /test/helpers/strRandom.test.js: -------------------------------------------------------------------------------- 1 | const { helpers: { strRandom } } = require('../../lib'); 2 | 3 | describe('Test the strRandom helper method.', () => { 4 | test('Should return a 8 char string', () => { 5 | expect(strRandom()).toHaveLength(8); 6 | }); 7 | 8 | test('Should return a 40 char string', () => { 9 | expect(strRandom(40)).toHaveLength(40); 10 | }); 11 | 12 | test('Should throw an error if the length is not a valid number', () => { 13 | expect(() => { 14 | strRandom('foo'); 15 | }).toThrow(TypeError); 16 | }); 17 | 18 | test('Should throw an error if the length is not divisible by 2', () => { 19 | expect(() => { 20 | strRandom(3); 21 | }).toThrow(RangeError); 22 | }); 23 | }); -------------------------------------------------------------------------------- /test/helpers/temporarySignedRoute.test.js: -------------------------------------------------------------------------------- 1 | const URL = require('../../lib/Http/URL/URL').default; 2 | const Route = require('../../lib/Http/Router/Route').default; 3 | const { helpers: { temporarySignedRoute } } = require('../../lib'); 4 | 5 | describe('Test the temporarySignedRoute helper method.', () => { 6 | beforeAll(() => { 7 | URL.setSecret('random-secret') 8 | Route.get('url-test', () => {}).name('cool-name') 9 | }) 10 | 11 | test('Should create a temporarily signed URL from a route name', async () => { 12 | const url = await temporarySignedRoute('cool-name', '1 minute'); 13 | 14 | expect(url).toContain('/url-test?signature='); 15 | }); 16 | }); -------------------------------------------------------------------------------- /test/jwt/setup/Config.js: -------------------------------------------------------------------------------- 1 | const { ConfigRepository } = require('../../../lib'); 2 | 3 | module.exports = class Config extends ConfigRepository { 4 | 5 | /** 6 | * Get registered config. 7 | * 8 | * @return {Object} 9 | */ 10 | get registered() { 11 | return { 12 | app: { 13 | url: 'http://localhost:3000', 14 | }, 15 | }; 16 | } 17 | } -------------------------------------------------------------------------------- /test/jwt/setup/Database.js: -------------------------------------------------------------------------------- 1 | const { Knex } = require('knex'); 2 | const { db } = require('./db-config'); 3 | 4 | module.exports = class Database { 5 | static table(name) { 6 | return db.from(name) 7 | } 8 | 9 | /** 10 | * @returns {Knex} db 11 | */ 12 | static get knex() { 13 | return db; 14 | } 15 | } -------------------------------------------------------------------------------- /test/jwt/setup/db-config.js: -------------------------------------------------------------------------------- 1 | const knex = require('knex'); 2 | const config = require('./knexfile'); 3 | 4 | exports.db = knex(config.test) -------------------------------------------------------------------------------- /test/jwt/setup/knexfile.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | test: { 5 | client: 'sqlite3', 6 | connection: ':memory:', 7 | useNullAsDefault: true, 8 | migrations: { 9 | directory: path.join(__dirname, 'migrations') 10 | }, 11 | seeds: { 12 | directory: path.join(__dirname, 'seeds') 13 | } 14 | }, 15 | 16 | } -------------------------------------------------------------------------------- /test/jwt/setup/migrations/20210724082462-create_users_table.js: -------------------------------------------------------------------------------- 1 | exports.up = function(knex, Promise) { 2 | return knex.schema.createTable('users', function(table) { 3 | table.increments(); 4 | table.string('name').notNullable(); 5 | table.integer('email').notNullable(); 6 | table.string('password').notNullable(); 7 | table.timestamp('created_at').defaultTo(knex.fn.now()) 8 | table.timestamp('updated_at').defaultTo(knex.fn.now()) 9 | }) 10 | } 11 | 12 | exports.down = function(knex, Promise) { 13 | return knex.schema.dropTable('users'); 14 | } -------------------------------------------------------------------------------- /test/jwt/setup/migrations/20210820161410_create_personal_access_tokens_table.js: -------------------------------------------------------------------------------- 1 | const { Knex } = require('knex'); 2 | 3 | /** @param {Knex} knex */ 4 | exports.up = (knex) => { 5 | return knex.schema.createTable('personal_access_tokens', (table) => { 6 | table.increments('id').primary(); 7 | table.string('tokenable_type'); 8 | table.bigInteger('tokenable_id').index().unsigned(); 9 | table.string('name'); 10 | table.string('abilities').nullable(); 11 | table.string('payload').nullable(); 12 | table.integer('ttl').index().nullable(); 13 | table.timestamp('last_used_at').nullable(); 14 | table.timestamps(true, true); 15 | }); 16 | } 17 | 18 | /** @param {Knex} knex */ 19 | exports.down = (knex) => knex.schema.dropTable('personal_access_tokens'); 20 | -------------------------------------------------------------------------------- /test/jwt/setup/seeds/users.js: -------------------------------------------------------------------------------- 1 | exports.seed = function(knex) { 2 | // Deletes ALL existing entries 3 | return knex('users').truncate() 4 | .then(function () { 5 | // Inserts seed entries 6 | return knex('users').insert([ 7 | { 8 | id: 1, 9 | name: 'John Doe', 10 | email: 'johndoe@example', 11 | password: '$2a$12$1UBpKKPqk0/5/VQ.AjjFxOJT.NKw6udWjtPWNbfN6jfBbYqqnODOW' 12 | } 13 | ]); 14 | }); 15 | }; -------------------------------------------------------------------------------- /test/redis/redis.test.js: -------------------------------------------------------------------------------- 1 | const Redis = require('../../lib/Redis/Redis').default; 2 | const Config = require('./setup/Config'); 3 | 4 | describe('src/Redis/Redis', () => { 5 | const redis = Redis; 6 | 7 | beforeAll(() => { 8 | redis.configure(new Config); 9 | }); 10 | 11 | afterAll(() => { 12 | redis.closeAll(); 13 | }); 14 | 15 | it('Should set a value', async () => { 16 | const status = await redis.set('name', 'Donald'); 17 | 18 | return expect(status).toBe('OK'); 19 | }); 20 | 21 | it('Should get a value', async () => { 22 | const value = await redis.get('name'); 23 | 24 | return expect(value).toBe('Donald'); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /test/redis/setup/Config.js: -------------------------------------------------------------------------------- 1 | const { ConfigRepository } = require('../../../lib'); 2 | 3 | module.exports = class Config extends ConfigRepository { 4 | 5 | /** 6 | * Get registered config. 7 | * 8 | * @return {Object} 9 | */ 10 | get registered() { 11 | return { 12 | database: { 13 | redis: { 14 | options: { 15 | prefix: 'formidable_framework_test_', 16 | }, 17 | 18 | default: { 19 | host: '127.0.0.1', 20 | port: 6379, 21 | database: 0, 22 | } 23 | } 24 | }, 25 | }; 26 | } 27 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // Change this to match your project 3 | "include": [".temp/*"], 4 | "compilerOptions": { 5 | "skipLibCheck": true, 6 | // Tells TypeScript to read JS files, as 7 | // normally they are ignored as source files 8 | "allowJs": true, 9 | // Generate d.ts files 10 | "declaration": true, 11 | // This compiler run should 12 | // only output d.ts files 13 | "emitDeclarationOnly": true, 14 | // Types should go into this directory. 15 | // Removing this would place the .d.ts files 16 | // next to the .js files 17 | "outDir": "types" 18 | } 19 | } -------------------------------------------------------------------------------- /types/Auth/Auth.d.ts: -------------------------------------------------------------------------------- 1 | import Driver from "./Drivers/Driver"; 2 | 3 | export default Auth; 4 | declare class Auth { 5 | static setProvider(provider: Provider = object): void; 6 | 7 | static getTable(): string; 8 | 9 | static attempt(body: object): Promise; 10 | 11 | constructor(user: User, abilities: string, driverManager: Driver); 12 | 13 | _driver: Driver; 14 | 15 | abilities: () => object | null; 16 | 17 | user: () => User; 18 | 19 | driver(): Driver; 20 | 21 | can(perform: string): boolean; 22 | 23 | check(): boolean; 24 | } 25 | 26 | Auth.setProvider({ 27 | cool: true 28 | }) -------------------------------------------------------------------------------- /types/Auth/AuthenticationServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class AuthenticationServiceResolver extends ServiceResolver { 2 | get protocol(): any; 3 | get provider(): any; 4 | } 5 | import ServiceResolver from "../Support/ServiceResolver"; 6 | -------------------------------------------------------------------------------- /types/Auth/DriverManager.d.ts: -------------------------------------------------------------------------------- 1 | export default class DriverManager { 2 | /** 3 | @param {string} name 4 | @param {object} driver 5 | */ 6 | static register(name: string, driver: object): any; 7 | /** 8 | @param {string} protocol 9 | @param {FormRequest} request 10 | @param {FastifyReply} reply 11 | @param {any[]|null} params 12 | @param {Repository} config 13 | */ 14 | static get(protocol: string, request: FormRequest, reply: FastifyReply, params: any[] | null, config: Repository): any; 15 | } 16 | -------------------------------------------------------------------------------- /types/Auth/Drivers/JwtDriver.d.ts: -------------------------------------------------------------------------------- 1 | export default class JwtDriver extends Driver { 2 | verify(): Promise<{ 3 | token: any; 4 | tokenable: any; 5 | }>; 6 | /** 7 | @param {object} body 8 | */ 9 | authenticate(body: object): Promise; 10 | /** 11 | @param {object} body 12 | */ 13 | register(body: object): Promise; 14 | /** 15 | @param {object} body 16 | */ 17 | logout(body?: object): Promise; 18 | } 19 | import Driver from "./Driver"; 20 | -------------------------------------------------------------------------------- /types/Auth/Drivers/SessionDriver.d.ts: -------------------------------------------------------------------------------- 1 | export default class SessionDriver extends Driver { 2 | verify(): Promise; 6 | renewSession(): Promise; 10 | /** 11 | @param {object} body 12 | */ 13 | authenticate(body: object): Promise; 14 | /** 15 | @param {object} body 16 | */ 17 | register(body: object): Promise; 18 | /** 19 | @param {object} body 20 | */ 21 | logout(body?: object): Promise; 22 | } 23 | import Driver from "./Driver"; 24 | -------------------------------------------------------------------------------- /types/Auth/Exceptions/AuthorizationException.d.ts: -------------------------------------------------------------------------------- 1 | export default AuthorizationException; 2 | declare class AuthorizationException extends HttpException { 3 | static [$__init__$](): typeof AuthorizationException; 4 | constructor(...args: any[]); 5 | [$__patch__$]($$?: {}): void; 6 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 7 | } 8 | import HttpException from "../../Http/Exceptions/HttpException"; 9 | declare const $__patch__$: unique symbol; 10 | declare const $__init__$: unique symbol; 11 | -------------------------------------------------------------------------------- /types/Auth/Exceptions/EmailNotVerifiedException.d.ts: -------------------------------------------------------------------------------- 1 | export default EmailNotVerifiedException; 2 | declare class EmailNotVerifiedException extends HttpException { 3 | static [$__init__$](): typeof EmailNotVerifiedException; 4 | constructor(...args: any[]); 5 | [$__patch__$]($$?: {}): void; 6 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 7 | } 8 | import HttpException from "../../Http/Exceptions/HttpException"; 9 | declare const $__patch__$: unique symbol; 10 | declare const $__init__$: unique symbol; 11 | -------------------------------------------------------------------------------- /types/Auth/Exceptions/EmailVerifiedException.d.ts: -------------------------------------------------------------------------------- 1 | export default EmailVerifiedException; 2 | declare class EmailVerifiedException extends HttpException { 3 | static [$__init__$](): typeof EmailVerifiedException; 4 | constructor(...args: any[]); 5 | [$__patch__$]($$?: {}): void; 6 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 7 | } 8 | import HttpException from "../../Http/Exceptions/HttpException"; 9 | declare const $__patch__$: unique symbol; 10 | declare const $__init__$: unique symbol; 11 | -------------------------------------------------------------------------------- /types/Auth/Exceptions/UnsupportedAuthDriverException.d.ts: -------------------------------------------------------------------------------- 1 | export default class UnsupportedAuthDriverException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Auth/Http/Controllers/LoginController.d.ts: -------------------------------------------------------------------------------- 1 | export default LoginController; 2 | declare class LoginController extends Controller { 3 | /** 4 | @param {function} handler 5 | */ 6 | static onLogin(handler: Function): Function; 7 | static [$__init__$](): typeof LoginController; 8 | constructor(...args: any[]); 9 | /** 10 | @param {LoginRequest} request 11 | */ 12 | login(request: LoginRequest, reply: any): any; 13 | } 14 | import Controller from "../../../Http/Controller"; 15 | import LoginRequest from "../Requests/LoginRequest"; 16 | declare const $__init__$: unique symbol; 17 | -------------------------------------------------------------------------------- /types/Auth/Http/Controllers/LogoutController.d.ts: -------------------------------------------------------------------------------- 1 | export default LogoutController; 2 | declare class LogoutController extends Controller { 3 | /** 4 | @param {function} handler 5 | */ 6 | static onLogout(handler: Function): Function; 7 | static [$__init__$](): typeof LogoutController; 8 | constructor(...args: any[]); 9 | /** 10 | @param {LogoutRequest} request 11 | */ 12 | logout(request: LogoutRequest, reply: any): any; 13 | } 14 | import Controller from "../../../Http/Controller"; 15 | import LogoutRequest from "../Requests/LogoutRequest"; 16 | declare const $__init__$: unique symbol; 17 | -------------------------------------------------------------------------------- /types/Auth/Http/Controllers/RegisterController.d.ts: -------------------------------------------------------------------------------- 1 | export default RegisterController; 2 | declare class RegisterController extends Controller { 3 | /** 4 | @param {function} handler 5 | */ 6 | static onRegister(handler: Function): Function; 7 | static [$__init__$](): typeof RegisterController; 8 | constructor(...args: any[]); 9 | /** 10 | @param {RegisterRequest} request 11 | */ 12 | register(request: RegisterRequest, reply: any): any; 13 | } 14 | import Controller from "../../../Http/Controller"; 15 | import RegisterRequest from "../Requests/RegisterRequest"; 16 | declare const $__init__$: unique symbol; 17 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/Authenticate.d.ts: -------------------------------------------------------------------------------- 1 | export default class Authenticate { 2 | /** 3 | @param {Repository} config 4 | */ 5 | constructor(config: Repository); 6 | config: Repository; 7 | /** 8 | @param {FormRequest} request 9 | @param {FastifyReply} reply 10 | @param {any[]|null} params 11 | */ 12 | handle(request: FormRequest, reply: FastifyReply, params: any[] | null): Promise<() => Auth>; 13 | get defaultProtocol(): any; 14 | /** 15 | @param {string} protocol 16 | */ 17 | configure(protocol: string): any; 18 | } 19 | import Auth from "../../Auth"; 20 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeForgot.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeForgot { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeForgot(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeLogin.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeLogin { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeLogin(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeLogout.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeLogout { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeLogout(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeRegister.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeRegister { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeRegister(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeResend.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeResend { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeResend(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeReset.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeReset { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeReset(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Middleware/BeforeVerify.d.ts: -------------------------------------------------------------------------------- 1 | export default class BeforeVerify { 2 | /** 3 | @param {function} handler 4 | */ 5 | static beforeVerify(handler: Function): Function; 6 | constructor(config: any); 7 | config: any; 8 | /** 9 | @param {any[]} params 10 | */ 11 | handle(request: any, reply: any, params: any[]): any; 12 | get defaultProtocol(): any; 13 | } 14 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/EmailResendRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class EmailResendRequest extends FormRequest { 2 | authorize(): boolean; 3 | rules(): { 4 | email: string; 5 | }; 6 | persist(): Promise; 7 | } 8 | import FormRequest from "../../../Http/Request/FormRequest"; 9 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/ForgotPasswordRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class ForgotPasswordRequest extends FormRequest { 2 | authorize(): boolean; 3 | rules(): { 4 | email: string; 5 | }; 6 | persist(): Promise; 7 | } 8 | import FormRequest from "../../../Http/Request/FormRequest"; 9 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/LoginRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class LoginRequest extends FormRequest { 2 | static [$__init__$](): typeof LoginRequest; 3 | constructor(...args: any[]); 4 | authDriver: any; 5 | authorize(): boolean; 6 | rules(): { 7 | email: string; 8 | password: string; 9 | remember_me: string; 10 | }; 11 | persist(): Promise; 12 | [$__patch__$]($$?: {}): void; 13 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 14 | } 15 | import FormRequest from "../../../Http/Request/FormRequest"; 16 | declare const $__patch__$: unique symbol; 17 | declare const $__init__$: unique symbol; 18 | export {}; 19 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/LogoutRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class LogoutRequest extends FormRequest { 2 | authorize(): boolean; 3 | persist(): Promise; 4 | } 5 | import FormRequest from "../../../Http/Request/FormRequest"; 6 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/RegisterRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class RegisterRequest extends FormRequest { 2 | static [$__init__$](): typeof RegisterRequest; 3 | constructor(...args: any[]); 4 | authDriver: any; 5 | authorize(): boolean; 6 | rules(): { 7 | name: string; 8 | email: string; 9 | password: string; 10 | password_confirmation: string; 11 | }; 12 | persist(): Promise; 13 | [$__patch__$]($$?: {}): void; 14 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 15 | } 16 | import FormRequest from "../../../Http/Request/FormRequest"; 17 | declare const $__patch__$: unique symbol; 18 | declare const $__init__$: unique symbol; 19 | export {}; 20 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/ResetPasswordRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class ResetPasswordRequest extends FormRequest { 2 | authorize(): boolean; 3 | rules(): { 4 | password: string; 5 | password_confirmation: string; 6 | }; 7 | persist(): Promise; 8 | } 9 | import FormRequest from "../../../Http/Request/FormRequest"; 10 | -------------------------------------------------------------------------------- /types/Auth/Http/Requests/VerifyEmailRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class VerifyEmailRequest extends FormRequest { 2 | authorize(): boolean; 3 | persist(): Promise; 4 | } 5 | import FormRequest from "../../../Http/Request/FormRequest"; 6 | -------------------------------------------------------------------------------- /types/Auth/Mail/ResetPassword.d.ts: -------------------------------------------------------------------------------- 1 | import { Mailable } from "@formidablejs/mailer"; 2 | import Request from "../../Http/Request/Request"; 3 | import FormRequest from "../../Http/Request/FormRequest"; 4 | 5 | type CustomRequest = { 6 | /** 7 | * Password reset url. 8 | */ 9 | passwordResetUrl: string 10 | } & FormRequest 11 | 12 | export default class ResetPassword extends Mailable { 13 | request: CustomRequest 14 | constructor(request: FormRequest | Request); 15 | render(): unknown 16 | } 17 | -------------------------------------------------------------------------------- /types/Auth/Mail/VerifyEmail.d.ts: -------------------------------------------------------------------------------- 1 | import { Mailable } from "@formidablejs/mailer"; 2 | import Request from "../../Http/Request/Request"; 3 | import FormRequest from "../../Http/Request/FormRequest"; 4 | 5 | type CustomRequest = { 6 | /** 7 | * Verification url. 8 | */ 9 | verificationUrl: string 10 | } & FormRequest 11 | 12 | export default class VerifyEmail extends Mailable { 13 | request: CustomRequest 14 | constructor(request: FormRequest | Request, user: User); 15 | render(): unknown 16 | } 17 | -------------------------------------------------------------------------------- /types/Auth/Mail/index.d.ts: -------------------------------------------------------------------------------- 1 | import ResetPassword from './ResetPassword' 2 | import VerifyEmail from './VerifyEmail' 3 | 4 | export { 5 | ResetPassword, 6 | VerifyEmail 7 | } -------------------------------------------------------------------------------- /types/Auth/Protocol.d.ts: -------------------------------------------------------------------------------- 1 | export default class Protocol { 2 | /** 3 | @param {Repository} config 4 | */ 5 | static make(config: Repository): Protocol; 6 | /** 7 | @param {Repository} config 8 | */ 9 | constructor(config: Repository); 10 | config: Repository; 11 | /** 12 | @param {string} protocol 13 | */ 14 | configure(protocol: string): any; 15 | [$__patch__$]($$?: {}): void; 16 | [$__init__$]($$?: any, deep?: boolean): void; 17 | } 18 | import Repository from "../Config/Repository"; 19 | declare const $__patch__$: unique symbol; 20 | declare const $__init__$: unique symbol; 21 | export {}; 22 | -------------------------------------------------------------------------------- /types/Auth/Tokens/PersonalAccessTokenServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class PersonalAccessTokenServiceResolver extends ServiceResolver { 2 | boot(): typeof PersonalAccessToken; 3 | } 4 | import ServiceResolver from "../../Support/ServiceResolver"; 5 | import PersonalAccessToken from "./PersonalAccessToken"; 6 | -------------------------------------------------------------------------------- /types/Config/Repository.d.ts: -------------------------------------------------------------------------------- 1 | export default class Repository { 2 | static setEnvironment(): any; 3 | static getEnvironment(): any; 4 | constructor($$?: any); 5 | temp: any; 6 | get registered(): Object; 7 | /** 8 | @param {string} key 9 | */ 10 | has(key: string): boolean; 11 | /** 12 | @param {string} key 13 | @param {any} default 14 | */ 15 | get(key: string, default$?: any): any; 16 | /** 17 | @param {string} key 18 | @param {any} value 19 | */ 20 | set(key: string, value: any): any; 21 | all(): Object; 22 | [$__patch__$]($$?: {}): void; 23 | [$__init__$]($$?: any, deep?: boolean): void; 24 | } 25 | declare const $__patch__$: unique symbol; 26 | declare const $__init__$: unique symbol; 27 | export {}; 28 | -------------------------------------------------------------------------------- /types/Database/Bind.d.ts: -------------------------------------------------------------------------------- 1 | export default class Bind { 2 | /** 3 | @param {string} table 4 | @param {boolean} first 5 | */ 6 | constructor(table: string, first?: boolean); 7 | table: string; 8 | first: boolean; 9 | /** 10 | @param {Request} request 11 | @param {number} key 12 | */ 13 | handle(request: Request, key: number): any; 14 | [$__patch__$]($$?: {}): void; 15 | [$__init__$]($$?: any, deep?: boolean): void; 16 | } 17 | declare const $__patch__$: unique symbol; 18 | declare const $__init__$: unique symbol; 19 | export {}; 20 | -------------------------------------------------------------------------------- /types/Database/Config.d.ts: -------------------------------------------------------------------------------- 1 | export default Config; 2 | export class Config { 3 | /** @type {string}*/ 4 | static get default(): string; 5 | /** @type {object}*/ 6 | static get connections(): any; 7 | /** @type {string}*/ 8 | static get client(): string; 9 | 10 | static get settings(): any; 11 | 12 | static get isReturningDriver(): boolean; 13 | 14 | static make(): {}; 15 | } 16 | -------------------------------------------------------------------------------- /types/Database/IContextual.d.ts: -------------------------------------------------------------------------------- 1 | export interface IContextual { 2 | get context(): string 3 | } 4 | -------------------------------------------------------------------------------- /types/Database/Migration.d.ts: -------------------------------------------------------------------------------- 1 | export default class Migration { 2 | /** 3 | @param {string} name 4 | */ 5 | make(name: string): any; 6 | /** 7 | @param {string|null} name 8 | @param {boolean} up 9 | */ 10 | migrate(name?: string | null, up?: boolean): any; 11 | latest(): any; 12 | fresh(): Promise; 13 | /** 14 | @param {boolean} all 15 | */ 16 | rollback(all?: boolean): any; 17 | list(): any; 18 | } 19 | -------------------------------------------------------------------------------- /types/Database/Seeder.d.ts: -------------------------------------------------------------------------------- 1 | export default class Seeder { 2 | /** 3 | @param {string} name 4 | */ 5 | make(name: string): any; 6 | run(): any; 7 | } 8 | -------------------------------------------------------------------------------- /types/Environment/Repository.d.ts: -------------------------------------------------------------------------------- 1 | export default class Repository { 2 | /** 3 | @param {string} root 4 | */ 5 | constructor(root: string); 6 | variables: NodeJS.ProcessEnv; 7 | /** 8 | @param {string} key 9 | @param {any} default 10 | */ 11 | get(key: string, default$?: any): any; 12 | [$__patch__$]($$?: {}): void; 13 | [$__init__$]($$?: any, deep?: boolean): void; 14 | } 15 | declare const $__patch__$: unique symbol; 16 | declare const $__init__$: unique symbol; 17 | export {}; 18 | -------------------------------------------------------------------------------- /types/Foundation/Bootstrap.d.ts: -------------------------------------------------------------------------------- 1 | export default class Bootstrap { 2 | /** 3 | @param {string} location 4 | @param {object} config 5 | */ 6 | static cache(location: string, config: object): any; 7 | } 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Command.d.ts: -------------------------------------------------------------------------------- 1 | export class Command extends BaseCommand { 2 | get app(): any; 3 | /** 4 | @param {string} type 5 | @param {string} message 6 | @param {boolean} newLine 7 | */ 8 | message(type: string, message: string, newLine?: boolean): void; 9 | /** 10 | @param {string} default 11 | */ 12 | env(default$: any): any; 13 | usingEnv(): void; 14 | /** 15 | @param {string} message 16 | */ 17 | confirm(message: string): Promise; 18 | shouldRun(): Promise; 19 | } 20 | import { Command as BaseCommand } from "@formidablejs/console"; 21 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/CacheCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class CacheCommand extends Command { 2 | get config(): string; 3 | get address(): string; 4 | cache(): mixed; 5 | /** 6 | @param {boolean} newLine 7 | */ 8 | clear(newLine?: boolean): void; 9 | } 10 | import { Command } from "../Command"; 11 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/ConfigCacheCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class ConfigCacheCommand extends CacheCommand { 2 | } 3 | import { CacheCommand } from "./CacheCommand"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/ConfigClearCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class ConfigClearCommand extends CacheCommand { 2 | } 3 | import { CacheCommand } from "./CacheCommand"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/DbSeedCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class DbSeedCommand extends Command { 2 | handle(): Promise; 3 | } 4 | import { Command } from "../Command"; 5 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/DownCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class DownCommand extends MaintenanceCommand { 2 | get props(): { 3 | message: import("@formidablejs/console/types/Props/Prop").default; 4 | retry: import("@formidablejs/console/types/Props/Prop").default; 5 | refresh: import("@formidablejs/console/types/Props/Prop").default; 6 | secret: import("@formidablejs/console/types/Props/Prop").default; 7 | status: import("@formidablejs/console/types/Props/Prop").default; 8 | redirect: import("@formidablejs/console/types/Props/Prop").default; 9 | }; 10 | } 11 | import { MaintenanceCommand } from "./MaintenanceCommand"; 12 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/EnvironmentCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class EnvironmentCommand extends Command { 2 | } 3 | import { Command } from "../Command"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/GenerateKeyCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class GenerateKeyCommand extends Command { 2 | get props(): { 3 | env: import("@formidablejs/console/types/Props/Prop").default; 4 | show: import("@formidablejs/console/types/Props/Prop").default; 5 | }; 6 | get envFile(): mixed; 7 | get envPath(): string; 8 | /** 9 | @param {number} length 10 | */ 11 | key(length?: number): string; 12 | /** 13 | @param {string} key 14 | */ 15 | updateEnv(key: string): boolean; 16 | } 17 | import { Command } from "../Command"; 18 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/InspireCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class InspireCommand extends Command { 2 | } 3 | import { Command } from "../Command"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MaintenanceCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MaintenanceCommand extends Command { 2 | get file(): string; 3 | down(): any; 4 | up(): mixed; 5 | } 6 | import { Command } from "../Command"; 7 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeCommandCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeCommandCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeConfigCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeConfigCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeControllerCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeControllerCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | api: import("@formidablejs/console/types/Props/Prop").default; 5 | invokable: import("@formidablejs/console/types/Props/Prop").default; 6 | resource: import("@formidablejs/console/types/Props/Prop").default; 7 | "store-request": import("@formidablejs/console/types/Props/Prop").default; 8 | "update-request": import("@formidablejs/console/types/Props/Prop").default; 9 | }; 10 | get stub(): any; 11 | } 12 | import { MakeResourceCommand } from "./MakeResourceCommand"; 13 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeCrudCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeCrudCommand extends Command { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | api: import("@formidablejs/console/types/Props/Prop").default; 5 | schema: import("@formidablejs/console/types/Props/Prop").default; 6 | repository: import("@formidablejs/console/types/Props/Prop").default; 7 | type: import("@formidablejs/console/types/Props/Prop").default; 8 | }; 9 | handle(): Promise; 10 | } 11 | import { Command } from "../Command"; 12 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeExceptionCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeExceptionCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeMailCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeMailCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeMiddlewareCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeMiddlewareCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeMigrationCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeMigrationCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | table: import("@formidablejs/console/types/Props/Prop").default; 5 | alter: import("@formidablejs/console/types/Props/Prop").default; 6 | schema: import("@formidablejs/console/types/Props/Prop").default; 7 | }; 8 | get stub(): any; 9 | } 10 | import { MakeResourceCommand } from "./MakeResourceCommand"; 11 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeRepositoryCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeRepositoryCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeRequestCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeRequestCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeResolverCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeResolverCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeResourceCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeResourceCommand extends Command { 2 | get resource(): string; 3 | get package(): string; 4 | get language(): any; 5 | get stub(): import("@formidablejs/stubs/types/Stub"); 6 | } 7 | import { Command } from "../Command"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeSeederCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeSeederCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | table: import("@formidablejs/console/types/Props/Prop").default; 5 | }; 6 | get stub(): any; 7 | } 8 | import { MakeResourceCommand } from "./MakeResourceCommand"; 9 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeTagCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeTagCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MakeViewCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MakeViewCommand extends MakeResourceCommand { 2 | get props(): { 3 | name: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | get stub(): any; 6 | } 7 | import { MakeResourceCommand } from "./MakeResourceCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MigrateDownCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MigrateDownCommand extends MigrationCommand { 2 | get props(): { 3 | migration: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | handle(): Promise; 6 | } 7 | import { MigrationCommand } from "./MigrationCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MigrateFreshCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MigrateFreshCommand extends MigrationCommand { 2 | handle(): Promise; 3 | } 4 | import { MigrationCommand } from "./MigrationCommand"; 5 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MigrateLatestCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MigrateLatestCommand extends MigrationCommand { 2 | handle(): Promise; 3 | } 4 | import { MigrationCommand } from "./MigrationCommand"; 5 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MigrateRollbackCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MigrateRollbackCommand extends MigrationCommand { 2 | get props(): { 3 | all: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | handle(): Promise; 6 | } 7 | import { MigrationCommand } from "./MigrationCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MigrateUpCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MigrateUpCommand extends MigrationCommand { 2 | get props(): { 3 | migration: import("@formidablejs/console/types/Props/Prop").default; 4 | }; 5 | handle(): Promise; 6 | } 7 | import { MigrationCommand } from "./MigrationCommand"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/MigrationCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class MigrationCommand extends Command { 2 | /** 3 | @param {string} action 4 | */ 5 | call(action: string, exitOnEnd?: boolean): Promise; 6 | } 7 | import { Command } from "../Command"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/PackagePublishCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class PackagePublishCommand extends Command { 2 | get props(): { 3 | package: import("@formidablejs/console/types/Props/Prop").default; 4 | tag: import("@formidablejs/console/types/Props/Prop").default; 5 | force: import("@formidablejs/console/types/Props/Prop").default; 6 | }; 7 | get package(): string; 8 | get basePackage(): string; 9 | get language(): any; 10 | get definition(): any; 11 | get publisherPath(): any; 12 | get publisher(): any; 13 | /** 14 | @param {string} optTag 15 | */ 16 | persist(optTag: string): void; 17 | } 18 | import { Command } from "../Command"; 19 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/RouteListCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class RouteListCommand extends Command { 2 | get props(): { 3 | method: import("@formidablejs/console/types/Props/Prop").default; 4 | legacy: import("@formidablejs/console/types/Props/Prop").default; 5 | }; 6 | } 7 | import { Command } from "../Command"; 8 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/SessionPruneExpiredCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class SessionPruneExpiredCommand extends Command { 2 | handle(): Promise; 3 | } 4 | import { Command } from "../Command"; 5 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/ShellCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class ShellCommand extends Command { 2 | get history(): string; 3 | handle(): Promise; 4 | } 5 | import { Command } from "../Command"; 6 | -------------------------------------------------------------------------------- /types/Foundation/Console/Commands/UpCommand.d.ts: -------------------------------------------------------------------------------- 1 | export class UpCommand extends MaintenanceCommand { 2 | } 3 | import { MaintenanceCommand } from "./MaintenanceCommand"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Console/verifyPort.ts: -------------------------------------------------------------------------------- 1 | export function verifyPort(port: number): Promise 2 | -------------------------------------------------------------------------------- /types/Foundation/ConsoleKernel.d.ts: -------------------------------------------------------------------------------- 1 | export default class ConsoleKernel { 2 | get default(): (typeof EnvironmentCommand | typeof ServeCommand)[]; 3 | get registered(): any[]; 4 | /** 5 | @param {Application} app 6 | */ 7 | registerCommands(app: Application, ctx: any): any[][]; 8 | /** 9 | @param {Application} app 10 | */ 11 | loadEvents(app: Application): any[][]; 12 | } 13 | import { EnvironmentCommand } from "./Console/Commands/EnvironmentCommand"; 14 | import { ServeCommand } from "./Console/Commands/ServeCommand"; 15 | -------------------------------------------------------------------------------- /types/Foundation/Context.d.ts: -------------------------------------------------------------------------------- 1 | export class ContextAPI { 2 | get registered(): { 3 | Database: any; 4 | DB: any; 5 | Mail: typeof Mail; 6 | }; 7 | inject(target: any): ContextAPI; 8 | } 9 | export let Context: ContextAPI; 10 | import { Mail } from "@formidablejs/mailer"; 11 | -------------------------------------------------------------------------------- /types/Foundation/Encrypter.d.ts: -------------------------------------------------------------------------------- 1 | export default class Encrypter { 2 | /** 3 | * Configure encryption. 4 | */ 5 | static configure(config: object): typeof Encrypter; 6 | 7 | /** 8 | * Get encryption key/iv. 9 | */ 10 | static appKey(type: string): string; 11 | 12 | /** 13 | * Get encryption key. 14 | */ 15 | static key(): string; 16 | 17 | /** 18 | * Get encryption iv. 19 | */ 20 | static iv(): string; 21 | 22 | /** 23 | * Encrypt value. 24 | */ 25 | static encrypt(value: any): string; 26 | 27 | /** 28 | * Decrypt value. 29 | */ 30 | static decrypt(hash: string): any; 31 | 32 | /** 33 | * Compares two strings to prevent timing attacks. 34 | */ 35 | static hashEquals(knownString: string, userString: string): boolean; 36 | } 37 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/ApplicationException.d.ts: -------------------------------------------------------------------------------- 1 | export default ApplicationException; 2 | declare class ApplicationException extends Error { 3 | static [$__init__$](): typeof ApplicationException; 4 | /** 5 | @param {any} response 6 | @param {number} status 7 | */ 8 | constructor(response: any, status?: number); 9 | response: any; 10 | status: number; 11 | initMessage(): any; 12 | initName(): string; 13 | getStatus(): number; 14 | [$__patch__$]($$?: {}): void; 15 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 16 | } 17 | declare const $__patch__$: unique symbol; 18 | declare const $__init__$: unique symbol; 19 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/DecryptException.d.ts: -------------------------------------------------------------------------------- 1 | export default class DecryptException extends ApplicationException { 2 | } 3 | import ApplicationException from "./ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/EncryptException.d.ts: -------------------------------------------------------------------------------- 1 | export default class EncryptException extends ApplicationException { 2 | } 3 | import ApplicationException from "./ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/ExitHandlerException.d.ts: -------------------------------------------------------------------------------- 1 | export default class ExitHandlerException extends ApplicationException { 2 | } 3 | import ApplicationException from "./ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/InvalidAppKeyException.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidAppKeyException extends ApplicationException { 2 | } 3 | import ApplicationException from "./ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/InvalidEncryptionKeyTypeException.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidEncryptionKeyTypeException extends ApplicationException { 2 | } 3 | import ApplicationException from "./ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/InvalidServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidServiceResolver extends ApplicationException { 2 | } 3 | import ApplicationException from "./ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Foundation/Exceptions/MaintenanceModeException.d.ts: -------------------------------------------------------------------------------- 1 | export default class MaintenanceModeException extends HttpException { 2 | static [$__init__$](): typeof MaintenanceModeException; 3 | constructor(...args: any[]); 4 | [$__patch__$]($$?: {}): void; 5 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 6 | } 7 | import HttpException from "../../Http/Exceptions/HttpException"; 8 | declare const $__patch__$: unique symbol; 9 | declare const $__init__$: unique symbol; 10 | export {}; 11 | -------------------------------------------------------------------------------- /types/Foundation/Inspiring.d.ts: -------------------------------------------------------------------------------- 1 | export class Inspiring { 2 | /** @type {string}*/ 3 | static get quote(): string; 4 | /** @type {Array}*/ 5 | static get quotes(): string[]; 6 | /** @param {string} quote*/ 7 | static formatForConsole(quote: string): string; 8 | } 9 | -------------------------------------------------------------------------------- /types/Foundation/Server.d.ts: -------------------------------------------------------------------------------- 1 | import Application from './Application' 2 | 3 | type ServerCallback = (_error: Error, address: string) => void; 4 | 5 | type ServerOptions = { 6 | port?: number 7 | host?: string 8 | _?: ServerCallback 9 | } 10 | 11 | export default class Server { 12 | /** 13 | * Initialize a new server instance. 14 | */ 15 | constructor(application: Promise) 16 | 17 | /** 18 | * Initialize a new server instance. 19 | */ 20 | static use(application: Promise): Server 21 | 22 | /** 23 | * Start the application server. 24 | */ 25 | start(serverOptions?: ServerOptions): Promise 26 | } 27 | -------------------------------------------------------------------------------- /types/Hashing/Exceptions/InvalidHashConfigurationException.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidHashConfigurationException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Hashing/Exceptions/InvalidHashDriverException.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidHashDriverException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Hashing/Hash.d.ts: -------------------------------------------------------------------------------- 1 | export default class Hash { 2 | static getDriver(): any; 3 | 4 | static make(value: string): Promise; 5 | 6 | static check(value: string, hash: string): Promise; 7 | 8 | static configure(config: object): void; 9 | 10 | static reset(): void; 11 | } 12 | -------------------------------------------------------------------------------- /types/Hashing/HashServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class HashServiceResolver extends ServiceResolver { 2 | } 3 | import ServiceResolver from "../Support/ServiceResolver"; 4 | -------------------------------------------------------------------------------- /types/Http/Cookie/CookieServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class CookieServiceResolver extends ServiceResolver { 2 | /** 3 | * Session config. 4 | */ 5 | /** 6 | * 7 | * Session config. 8 | 9 | */ 10 | get config(): { 11 | secret: any; 12 | parseOptions: { 13 | domain: any; 14 | httpOnly: any; 15 | maxAge: any; 16 | path: any; 17 | sameSite: any; 18 | secure: any; 19 | signed: any; 20 | }; 21 | }; 22 | /** 23 | * Boot cookie service resolver. 24 | * 25 | * @returns {void} 26 | */ 27 | /** 28 | * 29 | * Boot cookie service resolver. 30 | * 31 | * @returns {void} 32 | 33 | */ 34 | boot(): void; 35 | } 36 | import ServiceResolver from "../../Support/ServiceResolver"; 37 | -------------------------------------------------------------------------------- /types/Http/Exceptions/BadRequestException.d.ts: -------------------------------------------------------------------------------- 1 | export default BadRequestException; 2 | declare class BadRequestException extends HttpException { 3 | static [$__init__$](): typeof BadRequestException; 4 | constructor(...args: any[]); 5 | [$__patch__$]($$?: {}): void; 6 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 7 | } 8 | import HttpException from "./HttpException"; 9 | declare const $__patch__$: unique symbol; 10 | declare const $__init__$: unique symbol; 11 | -------------------------------------------------------------------------------- /types/Http/Exceptions/ForbiddenException.d.ts: -------------------------------------------------------------------------------- 1 | export default ForbiddenException; 2 | declare class ForbiddenException extends HttpException { 3 | static [$__init__$](): typeof ForbiddenException; 4 | constructor(...args: any[]); 5 | [$__patch__$]($$?: {}): void; 6 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 7 | } 8 | import HttpException from "./HttpException"; 9 | declare const $__patch__$: unique symbol; 10 | declare const $__init__$: unique symbol; 11 | -------------------------------------------------------------------------------- /types/Http/Exceptions/HttpException.d.ts: -------------------------------------------------------------------------------- 1 | export default HttpException; 2 | declare class HttpException extends Error { 3 | static [$__init__$](): typeof HttpException; 4 | /** 5 | @param {string} response 6 | @param {number|null} statusCode 7 | */ 8 | constructor(response: string, statusCode?: number | null); 9 | response: string; 10 | status: number; 11 | initMessage(): string; 12 | initName(): string; 13 | getStatus(): number; 14 | [$__patch__$]($$?: {}): void; 15 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 16 | } 17 | declare const $__patch__$: unique symbol; 18 | declare const $__init__$: unique symbol; 19 | -------------------------------------------------------------------------------- /types/Http/Exceptions/InvalidSignatureException.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidSignatureException extends ForbiddenException { 2 | } 3 | import ForbiddenException from "./ForbiddenException"; 4 | -------------------------------------------------------------------------------- /types/Http/Exceptions/NotFoundException.d.ts: -------------------------------------------------------------------------------- 1 | export default NotFoundException; 2 | declare class NotFoundException extends HttpException { 3 | /** 4 | @param {Request|FormRequest|FastifyRequest} request 5 | */ 6 | static using(request: Request | FormRequest | FastifyRequest): NotFoundException; 7 | static [$__init__$](): typeof NotFoundException; 8 | constructor(...args: any[]); 9 | [$__patch__$]($$?: {}): void; 10 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 11 | } 12 | import HttpException from "./HttpException"; 13 | declare const $__patch__$: unique symbol; 14 | declare const $__init__$: unique symbol; 15 | import Request from "../Request/Request"; 16 | import FormRequest from "../Request/FormRequest"; 17 | import { FastifyRequest } from "fastify/types/request"; 18 | -------------------------------------------------------------------------------- /types/Http/Exceptions/UndefinedMiddlewareException.d.ts: -------------------------------------------------------------------------------- 1 | export default class UndefinedMiddlewareException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Http/Kernel.d.ts: -------------------------------------------------------------------------------- 1 | export default class Kernel { 2 | get middleware(): any[]; 3 | get middlewareGroups(): {}; 4 | get routeMiddleware(): {}; 5 | getAllMiddleware(route: any, _middleware?: any): any[]; 6 | listen(config: any, errorHandler: any, interceptors: any, hooks: any, plugins: any, serverConfig: any, returnMode: any): Promise; 7 | /** 8 | @param {string} address 9 | */ 10 | storeAddress(address: string): string; 11 | hasRoutes(router: any, config: any): any[]; 12 | /** 13 | @param {object} route 14 | */ 15 | resolveMiddleware(route: object, request: any, reply: any, config: any, _middleware?: any): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /types/Http/Kernel/getResponse.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {object} route 3 | */ 4 | export default function getResponse(route: object, request: any, reply: any): Promise; 5 | -------------------------------------------------------------------------------- /types/Http/Kernel/handleNotFound.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {FormRequest} request 3 | */ 4 | export default function handleNotFound(request: FormRequest): NotFoundException; 5 | import NotFoundException from "../Exceptions/NotFoundException"; 6 | -------------------------------------------------------------------------------- /types/Http/Kernel/hasContentTypes.d.ts: -------------------------------------------------------------------------------- 1 | export default function hasContentTypes(fastify: any): any; 2 | -------------------------------------------------------------------------------- /types/Http/Kernel/resolveResponse.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {any} response 3 | @param {FormRequest} request 4 | */ 5 | export default function resolveResponse(response: any, request: FormRequest, reply: any, skipResolvers?: boolean): Promise; 6 | -------------------------------------------------------------------------------- /types/Http/Middleware.d.ts: -------------------------------------------------------------------------------- 1 | export default class Middleware { 2 | handle(request: Request, reply: FastifyReply, params?: object): any; 3 | 4 | terminate?(request: Request, reply: FastifyReply, params?: object): any 5 | } -------------------------------------------------------------------------------- /types/Http/Middleware/ConvertEmptyStringsToNull.d.ts: -------------------------------------------------------------------------------- 1 | export default class ConvertEmptyStringsToNull extends TransformsRequest { 2 | } 3 | import TransformsRequest from "./TransformsRequest"; 4 | -------------------------------------------------------------------------------- /types/Http/Middleware/EnsureEmailIsVerified.d.ts: -------------------------------------------------------------------------------- 1 | import Request from "../Request/Request"; 2 | 3 | export default class EnsureEmailIsVerified { 4 | /** 5 | * Route to redirect to. 6 | */ 7 | get redirectToRoute(): string; 8 | 9 | /** 10 | * Handle middleware. 11 | */ 12 | handle(request: Request, reply: FastifyReply, params?: Array): any; 13 | 14 | /** 15 | * Handle requests expecting html. 16 | */ 17 | toHtml(request: Request, reply: FastifyReply, params?: Array): any; 18 | 19 | /** 20 | * Handle requests expecting json. 21 | */ 22 | toJson(request: Request, reply: FastifyReply, params?: Array): any; 23 | } 24 | -------------------------------------------------------------------------------- /types/Http/Middleware/EnsureStateless.d.ts: -------------------------------------------------------------------------------- 1 | import { FastifyReply } from "fastify"; 2 | import FormRequest from "../Request/FormRequest"; 3 | import Request from "../Request/Request"; 4 | 5 | export default class EnsureStateless { 6 | /** 7 | * When strict mode is enabled, your application will completely 8 | * remove sessions and cookies. Conversely, when strict mode is not 9 | * enabled, only the ability to set cookies will be disabled. 10 | * 11 | * @default false 12 | */ 13 | get strict(): boolean 14 | 15 | /** 16 | * Handle request. 17 | */ 18 | handle(request: FormRequest|Request, reply: FastifyReply, params: any[] | null): () => any; 19 | } 20 | -------------------------------------------------------------------------------- /types/Http/Middleware/IMiddleware.d.ts: -------------------------------------------------------------------------------- 1 | import { FastifyReply } from "fastify" 2 | import FormRequest from "../Request/FormRequest" 3 | import Request from "../Request/Request" 4 | 5 | export interface IMiddleware { 6 | new (...args: any[]): { 7 | handle: (request: Request | FormRequest, reply?: FastifyReply, params?: any[]) => any 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /types/Http/Middleware/MiddlewareAliases.d.ts: -------------------------------------------------------------------------------- 1 | import { IMiddleware } from "./IMiddleware" 2 | 3 | export type MiddlewareAliases = { 4 | [key: string]: IMiddleware 5 | } 6 | -------------------------------------------------------------------------------- /types/Http/Middleware/MiddlewareGroups.d.ts: -------------------------------------------------------------------------------- 1 | import { IMiddleware } from "./IMiddleware" 2 | 3 | export type MiddlewareGroups = { 4 | [key: string]: Array 5 | } 6 | -------------------------------------------------------------------------------- /types/Http/Middleware/TransformsRequest.d.ts: -------------------------------------------------------------------------------- 1 | export default class TransformsRequest { 2 | get except(): any[]; 3 | handle(request: any): {}; 4 | clean(request: any): {}; 5 | transform(key: any, value: any): any; 6 | } 7 | -------------------------------------------------------------------------------- /types/Http/Middleware/TrimStrings.d.ts: -------------------------------------------------------------------------------- 1 | export default class TrimStrings extends TransformsRequest { 2 | } 3 | import TransformsRequest from "./TransformsRequest"; 4 | -------------------------------------------------------------------------------- /types/Http/Middleware/ValidateSignature.d.ts: -------------------------------------------------------------------------------- 1 | export default class ValidateSignature { 2 | constructor(config: any); 3 | config: any; 4 | /** 5 | @param {FormRequest} request 6 | */ 7 | handle(request: FormRequest): Promise; 8 | [$__patch__$]($$?: {}): void; 9 | [$__init__$]($$?: any, deep?: boolean): void; 10 | } 11 | declare const $__patch__$: unique symbol; 12 | declare const $__init__$: unique symbol; 13 | export {}; 14 | -------------------------------------------------------------------------------- /types/Http/Request/Exceptions/DestinationExistsException.d.ts: -------------------------------------------------------------------------------- 1 | export default class DestinationExistsException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Http/Request/FormValidation.d.ts: -------------------------------------------------------------------------------- 1 | export default class FormValidation { 2 | /** 3 | @param {string} locale 4 | */ 5 | constructor(locale?: string); 6 | locale: string; 7 | getValidation(): any; 8 | } 9 | -------------------------------------------------------------------------------- /types/Http/Request/Request.d.ts: -------------------------------------------------------------------------------- 1 | export default class Request extends FormRequest { 2 | } 3 | import FormRequest from "./FormRequest"; 4 | -------------------------------------------------------------------------------- /types/Http/Response/JsonResponse.d.ts: -------------------------------------------------------------------------------- 1 | import { FastifyReply } from "fastify"; 2 | 3 | export type JsonData = { 4 | [key: string]: number | string | Array | JsonData 5 | } 6 | 7 | export default class JsonResponse { 8 | static make(object: JsonData, statusCode: number): JsonResponse; 9 | /** 10 | @param {object} object 11 | @param {number} statusCode 12 | */ 13 | constructor(object: object, statusCode?: number); 14 | data: any; 15 | statusCode: number; 16 | /** 17 | @param {number} statusCode 18 | */ 19 | code(statusCode?: number): JsonResponse; 20 | /** 21 | @param {FastifyReply} reply 22 | */ 23 | toJson(reply: FastifyReply): any; 24 | [$__patch__$]($$?: {}): void; 25 | [$__init__$]($$?: any, deep?: boolean): void; 26 | } 27 | declare const $__patch__$: unique symbol; 28 | declare const $__init__$: unique symbol; 29 | export {}; 30 | -------------------------------------------------------------------------------- /types/Http/Router/Exceptions/InvalidRouteActionException.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidRouteActionException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Http/Router/Path.d.ts: -------------------------------------------------------------------------------- 1 | export default class Path { 2 | /** 3 | @param {string[]} prefix 4 | @param {string} pattern 5 | */ 6 | static clean(prefix: string[], pattern: string): string; 7 | } 8 | -------------------------------------------------------------------------------- /types/Http/Session/DriverManager.d.ts: -------------------------------------------------------------------------------- 1 | export default class DriverManager { 2 | /** 3 | @param {string} name 4 | @param {object} driver 5 | */ 6 | static register(name: string, driver: object): any; 7 | /** 8 | @param {string} name 9 | */ 10 | static get(name: string): any; 11 | /** 12 | @param {string} name 13 | */ 14 | static isRegistered(name: string): boolean; 15 | } 16 | -------------------------------------------------------------------------------- /types/Http/Session/Exceptions/TokenMismatchException.d.ts: -------------------------------------------------------------------------------- 1 | export default class TokenMismatchException extends ForbiddenException { 2 | } 3 | import ForbiddenException from "../../../Http/Exceptions/ForbiddenException"; 4 | -------------------------------------------------------------------------------- /types/Http/Session/Exceptions/UnsupportedSessionDriverException.d.ts: -------------------------------------------------------------------------------- 1 | export default class UnsupportedSessionDriverException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Http/Session/SessionFileStoreServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class SessionFileStoreServiceResolver extends ServiceResolver { 2 | } 3 | import ServiceResolver from "../../Support/ServiceResolver"; 4 | -------------------------------------------------------------------------------- /types/Http/Session/SessionMemoryStoreServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class SessionMemoryStoreServiceResolver extends ServiceResolver { 2 | boot(): import("../..").Application; 3 | } 4 | import ServiceResolver from "../../Support/ServiceResolver"; 5 | -------------------------------------------------------------------------------- /types/Http/URL/Exceptions/MissingRouteParamException.d.ts: -------------------------------------------------------------------------------- 1 | export default class MissingRouteParamException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Http/URL/Exceptions/UnregisteredRouteException.d.ts: -------------------------------------------------------------------------------- 1 | export default class UnregisteredRouteException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Http/View/Exceptions/UndefinedDataPropException.d.ts: -------------------------------------------------------------------------------- 1 | export default class UndefinedDataPropException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Mail/Mailable.d.ts: -------------------------------------------------------------------------------- 1 | import { Mailable as MailableBase } from '@formidablejs/mailer' 2 | import { config as ConfigFinder } from '../Support/Helpers/index' 3 | 4 | export class Mailable extends MailableBase { 5 | config: typeof ConfigFinder 6 | } 7 | -------------------------------------------------------------------------------- /types/Mix/Repository.d.ts: -------------------------------------------------------------------------------- 1 | export default class Repository { 2 | /** 3 | @param {string} file 4 | */ 5 | static get(file: string): any; 6 | static manifest(): any; 7 | } 8 | -------------------------------------------------------------------------------- /types/Support/Decorators/context.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /types/Support/Decorators/use.d.ts: -------------------------------------------------------------------------------- 1 | type Descriptor = { 2 | value: D 3 | writable: boolean 4 | enumerable: boolean 5 | configurable: boolean 6 | } 7 | 8 | function DI( 9 | target: T, 10 | key: string, 11 | descriptor: Descriptor, 12 | paramaters: P 13 | ) 14 | 15 | function use(...objects: T); 16 | 17 | function αuse(...objects: T); 18 | 19 | export { 20 | use, 21 | αuse, 22 | DI 23 | } 24 | -------------------------------------------------------------------------------- /types/Support/Encryption/Exceptions/MissingAppKeyException.d.ts: -------------------------------------------------------------------------------- 1 | export default class MissingAppKeyException extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Support/Encryption/HasEncryptionKey.d.ts: -------------------------------------------------------------------------------- 1 | import Repository from "../../Config/Repository"; 2 | import FormRequest from "../../Http/Request/FormRequest"; 3 | 4 | export default class HasEncryptionKey { 5 | /** 6 | @param {Repository} config 7 | */ 8 | constructor(config: Repository); 9 | config: Repository; 10 | /** 11 | @param {FormRequest} request 12 | */ 13 | handle(request: FormRequest): FormRequest; 14 | key(): any; 15 | } 16 | -------------------------------------------------------------------------------- /types/Support/Helpers/Error/BooleanCastError.d.ts: -------------------------------------------------------------------------------- 1 | export default class BooleanCastError extends Error { 2 | static [$__init__$](): typeof BooleanCastError; 3 | /** 4 | @param {string} message 5 | */ 6 | constructor(message: string); 7 | } 8 | declare const $__init__$: unique symbol; 9 | export {}; 10 | -------------------------------------------------------------------------------- /types/Support/Helpers/Error/ConfigNotCachedError.d.ts: -------------------------------------------------------------------------------- 1 | export default class ConfigNotCachedError extends Error { 2 | static [$__init__$](): typeof ConfigNotCachedError; 3 | } 4 | declare const $__init__$: unique symbol; 5 | export {}; 6 | -------------------------------------------------------------------------------- /types/Support/Helpers/Error/InvalidExitFunction.d.ts: -------------------------------------------------------------------------------- 1 | export default class InvalidExitFunction extends ApplicationException { 2 | } 3 | import ApplicationException from "../../../Foundation/Exceptions/ApplicationException"; 4 | -------------------------------------------------------------------------------- /types/Support/Helpers/asObject.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {object} object 3 | */ 4 | export default function asObject(object: object): T; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/bind.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} table 3 | @param {boolean} first 4 | */ 5 | export default function bind(table: string, first?: boolean): Bind; 6 | import Bind from "../../Database/Bind"; 7 | -------------------------------------------------------------------------------- /types/Support/Helpers/config.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} notation 3 | @param {any} default 4 | */ 5 | export default function config(notation: string, default$?: T): T; 6 | -------------------------------------------------------------------------------- /types/Support/Helpers/decrypt.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} hash 3 | */ 4 | export default function decrypt(hash: string, unserialize?: boolean): T; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/die.d.ts: -------------------------------------------------------------------------------- 1 | export default function die(handler: Function | CallableFunction): void; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/dotNotation.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {object} object 3 | @param {string} key 4 | */ 5 | export default function dotNotation(object: object, key: string): T; 6 | -------------------------------------------------------------------------------- /types/Support/Helpers/encrypt.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {any} value 3 | */ 4 | export default function encrypt(value: T, serialize?: boolean): string; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/env.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} key 3 | @param {any} default 4 | */ 5 | export default function env(key: string, default$?: T): T; 6 | -------------------------------------------------------------------------------- /types/Support/Helpers/expiresIn.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} time 3 | */ 4 | export default function expiresIn(time: string): string; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/hashEquals.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Compares two strings to prevent timing attacks. 3 | */ 4 | export default function hashEquals(knownString: string, userString: string): boolean; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/imbaEnv.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {boolean} stringify 3 | */ 4 | export default function imbaEnv(stringify?: boolean): {}; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/isArray.d.ts: -------------------------------------------------------------------------------- 1 | export default function isArray(object: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/isBoolean.d.ts: -------------------------------------------------------------------------------- 1 | export default function isBoolean(object: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/isClass.d.ts: -------------------------------------------------------------------------------- 1 | export default function isClass(object: any, strict?: boolean): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/isEmpty.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {any} value 3 | */ 4 | export default function isEmpty(value: any): boolean; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/isFunction.d.ts: -------------------------------------------------------------------------------- 1 | export default function isFunction(object: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/isNumber.d.ts: -------------------------------------------------------------------------------- 1 | export default function isNumber(object: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/isObject.d.ts: -------------------------------------------------------------------------------- 1 | export default function isObject(object: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/isString.d.ts: -------------------------------------------------------------------------------- 1 | export default function isString(object: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/loadHelpers.d.ts: -------------------------------------------------------------------------------- 1 | export default function loadHelpers(): void; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/location.d.ts: -------------------------------------------------------------------------------- 1 | type Location = { 2 | href: string; 3 | origin: string; 4 | protocol: 'http' | 'https'; 5 | username: string; 6 | password: string; 7 | host: string; 8 | hostname: string; 9 | port: string; 10 | pathname: string; 11 | search: string; 12 | searchParams: URLSearchParams; 13 | hash: string; 14 | }; 15 | 16 | /** 17 | * Get the current location object. 18 | * 19 | * @experimental 20 | */ 21 | export default function location(): Location | null; 22 | -------------------------------------------------------------------------------- /types/Support/Helpers/mix.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} file 3 | */ 4 | export default function mix(file: string): string; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/multitap.d.ts: -------------------------------------------------------------------------------- 1 | export default function multitap(object: any): InfiniteHigherOrderTapProxy; 2 | import { InfiniteHigherOrderTapProxy } from "../InfiniteHigherOrderTapProxy"; 3 | -------------------------------------------------------------------------------- /types/Support/Helpers/now.d.ts: -------------------------------------------------------------------------------- 1 | export default function now(): any; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/response.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {any} data 3 | @param {number} statusCode 4 | */ 5 | export default function response(data?: any, statusCode?: number): Response; 6 | import Response from "../../Http/Response/Response"; 7 | -------------------------------------------------------------------------------- /types/Support/Helpers/route.d.ts: -------------------------------------------------------------------------------- 1 | type Params = { 2 | [key: string]: string | number | Params, 3 | } 4 | 5 | /** 6 | * Generate a URL for a given route name. 7 | */ 8 | export default function route(name: string, params?: Params): string; 9 | -------------------------------------------------------------------------------- /types/Support/Helpers/signedRoute.d.ts: -------------------------------------------------------------------------------- 1 | type Params = { 2 | [key: string]: string | number | Params, 3 | } 4 | 5 | /** 6 | * Generate a signed URL for a given route name. 7 | */ 8 | export default function signedRoute(name: string, params?: Params): Promise; 9 | -------------------------------------------------------------------------------- /types/Support/Helpers/singularize.d.ts: -------------------------------------------------------------------------------- 1 | export default function singularize(value: string): string; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/slug.d.ts: -------------------------------------------------------------------------------- 1 | type SlugOptions = { 2 | lowerCase?: boolean; 3 | } 4 | 5 | /** 6 | @param {string} value 7 | @param {string} separator 8 | */ 9 | export default function slug(value: string, separator?: string, options?: SlugOptions): string; 10 | -------------------------------------------------------------------------------- /types/Support/Helpers/strRandom.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {number} length 3 | */ 4 | export default function strRandom(length?: number): string; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/tap.d.ts: -------------------------------------------------------------------------------- 1 | export default function tap(object: any, callback: Function | CallableFunction): T; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/temporarySignedRoute.d.ts: -------------------------------------------------------------------------------- 1 | type Params = { 2 | [key: string]: string | number | Params, 3 | } 4 | 5 | /** 6 | * Generate a temporary signed URL for a given route name. 7 | */ 8 | export default function temporarySignedRoute(name: string, expiresIn: string, params?: Params): Promise; 9 | -------------------------------------------------------------------------------- /types/Support/Helpers/toBoolean.d.ts: -------------------------------------------------------------------------------- 1 | export default function toBoolean(value: any): boolean; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/updateLine.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} file 3 | @param {function} callback 4 | */ 5 | export function updateLine(file: string, callback: Function): boolean; 6 | -------------------------------------------------------------------------------- /types/Support/Helpers/version.d.ts: -------------------------------------------------------------------------------- 1 | export default function version(): string; 2 | -------------------------------------------------------------------------------- /types/Support/Helpers/view.d.ts: -------------------------------------------------------------------------------- 1 | import { IView } from "../../Http/View/View"; 2 | import ViewResponse from "../../Http/Response/ViewResponse"; 3 | 4 | export default function view(view: IView, data?: object | null): ViewResponse; 5 | -------------------------------------------------------------------------------- /types/Support/Helpers/wildcard.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {string} value 3 | @param {string} match 4 | */ 5 | export default function wildcard(value: string, match: string): boolean; 6 | -------------------------------------------------------------------------------- /types/Support/Helpers/without.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @param {object} object 3 | @param {string[]} exclude 4 | */ 5 | export default function without(object: object, exclude: string[]): {}; 6 | -------------------------------------------------------------------------------- /types/Support/HigherOrderTapProxy.d.ts: -------------------------------------------------------------------------------- 1 | export class HigherOrderTapProxy { 2 | constructor(object: any); 3 | } 4 | -------------------------------------------------------------------------------- /types/Support/InfiniteHigherOrderTapProxy.d.ts: -------------------------------------------------------------------------------- 1 | export class InfiniteHigherOrderTapProxy { 2 | constructor(object: any); 3 | } 4 | -------------------------------------------------------------------------------- /types/Support/Language/LanguageServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class LanguageServiceResolver extends ServiceResolver { 2 | boot(): import("../..").Application; 3 | } 4 | import ServiceResolver from "../ServiceResolver"; 5 | -------------------------------------------------------------------------------- /types/Support/Language/Middleware/AcceptLanguage.d.ts: -------------------------------------------------------------------------------- 1 | export default class AcceptLanguage { 2 | get mappings(): {}; 3 | handle(request: any): any; 4 | getLanguage(request: any): any; 5 | } 6 | -------------------------------------------------------------------------------- /types/Support/ServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | import Application from "../Foundation/Application"; 2 | 3 | export default class ServiceResolver { 4 | /** 5 | * Application instance. 6 | */ 7 | app: Application; 8 | 9 | /** 10 | * Whether or not Service Resolver should be loaded in 11 | * cli mode. 12 | * 13 | * @default true 14 | */ 15 | static get runInCli(): boolean; 16 | 17 | /** 18 | * Initiate Service Resolver. 19 | */ 20 | constructor(app: Application); 21 | 22 | /** 23 | * Get contextual objects. 24 | */ 25 | get context(): any[]; 26 | 27 | /** 28 | * Boot up Service Resolver. 29 | */ 30 | boot(): unknown; 31 | 32 | /** 33 | * Register Service Resolver. 34 | */ 35 | register(): unknown; 36 | } 37 | -------------------------------------------------------------------------------- /types/Validator/Exceptions/ValidationException.d.ts: -------------------------------------------------------------------------------- 1 | export default ValidationException; 2 | declare class ValidationException extends HttpException { 3 | /** 4 | @param {object} messages 5 | */ 6 | static withMessages(messages: object): ValidationException; 7 | static [$__init__$](): typeof ValidationException; 8 | constructor(...args: any[]); 9 | [$__patch__$]($$?: {}): void; 10 | [$__init__$]($$?: any, deep?: boolean, ...args: any[]): void; 11 | } 12 | import HttpException from "../../Http/Exceptions/HttpException"; 13 | declare const $__patch__$: unique symbol; 14 | declare const $__init__$: unique symbol; 15 | -------------------------------------------------------------------------------- /types/Validator/ValidationServiceResolver.d.ts: -------------------------------------------------------------------------------- 1 | export default class ValidationServiceResolver extends ServiceResolver { 2 | boot(): ValidationServiceResolver; 3 | nullable(): boolean; 4 | registeredRules(): {}; 5 | /** 6 | @param {object} rules 7 | */ 8 | registerRules(rules: object): ValidationServiceResolver; 9 | } 10 | import ServiceResolver from "../Support/ServiceResolver"; 11 | -------------------------------------------------------------------------------- /types/Validator/Validator.d.ts: -------------------------------------------------------------------------------- 1 | export default class Validator { 2 | /** 3 | @param {object} body 4 | @param {object} rules 5 | @param {object} messages 6 | */ 7 | static make(body: object, rules: object, messages?: object): any; 8 | static get(): any; 9 | } 10 | --------------------------------------------------------------------------------