@arikajs/cli 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +99 -6
  2. package/dist/bin/arika.js +2 -2
  3. package/dist/bin/arika.js.map +1 -1
  4. package/dist/src/ApplicationLoader.d.ts +5 -0
  5. package/dist/src/ApplicationLoader.d.ts.map +1 -1
  6. package/dist/src/ApplicationLoader.js +24 -2
  7. package/dist/src/ApplicationLoader.js.map +1 -1
  8. package/dist/src/Bootstrap.d.ts.map +1 -1
  9. package/dist/src/Bootstrap.js +35 -0
  10. package/dist/src/Bootstrap.js.map +1 -1
  11. package/dist/src/Commands/AuthApiInstallCommand.d.ts +24 -0
  12. package/dist/src/Commands/AuthApiInstallCommand.d.ts.map +1 -0
  13. package/dist/src/Commands/AuthApiInstallCommand.js +751 -0
  14. package/dist/src/Commands/AuthApiInstallCommand.js.map +1 -0
  15. package/dist/src/Commands/AuthInstallCommand.d.ts +7 -0
  16. package/dist/src/Commands/AuthInstallCommand.d.ts.map +1 -0
  17. package/dist/src/Commands/AuthInstallCommand.js +46 -0
  18. package/dist/src/Commands/AuthInstallCommand.js.map +1 -0
  19. package/dist/src/Commands/AuthWebInstallCommand.d.ts +31 -0
  20. package/dist/src/Commands/AuthWebInstallCommand.d.ts.map +1 -0
  21. package/dist/src/Commands/AuthWebInstallCommand.js +1100 -0
  22. package/dist/src/Commands/AuthWebInstallCommand.js.map +1 -0
  23. package/dist/src/Commands/BenchmarkCommand.d.ts +7 -0
  24. package/dist/src/Commands/BenchmarkCommand.d.ts.map +1 -0
  25. package/dist/src/Commands/BenchmarkCommand.js +25 -0
  26. package/dist/src/Commands/BenchmarkCommand.js.map +1 -0
  27. package/dist/src/Commands/CacheClearCommand.d.ts +7 -0
  28. package/dist/src/Commands/CacheClearCommand.d.ts.map +1 -0
  29. package/dist/src/Commands/CacheClearCommand.js +33 -0
  30. package/dist/src/Commands/CacheClearCommand.js.map +1 -0
  31. package/dist/src/Commands/CacheTableCommand.d.ts.map +1 -1
  32. package/dist/src/Commands/CacheTableCommand.js +21 -9
  33. package/dist/src/Commands/CacheTableCommand.js.map +1 -1
  34. package/dist/src/Commands/ConfigCacheCommand.d.ts +7 -0
  35. package/dist/src/Commands/ConfigCacheCommand.d.ts.map +1 -0
  36. package/dist/src/Commands/ConfigCacheCommand.js +86 -0
  37. package/dist/src/Commands/ConfigCacheCommand.js.map +1 -0
  38. package/dist/src/Commands/ConfigClearCommand.d.ts +7 -0
  39. package/dist/src/Commands/ConfigClearCommand.d.ts.map +1 -0
  40. package/dist/src/Commands/ConfigClearCommand.js +29 -0
  41. package/dist/src/Commands/ConfigClearCommand.js.map +1 -0
  42. package/dist/src/Commands/DocsGenerateCommand.d.ts +0 -1
  43. package/dist/src/Commands/DocsGenerateCommand.d.ts.map +1 -1
  44. package/dist/src/Commands/DocsGenerateCommand.js +68 -77
  45. package/dist/src/Commands/DocsGenerateCommand.js.map +1 -1
  46. package/dist/src/Commands/EnvValidateCommand.d.ts +7 -0
  47. package/dist/src/Commands/EnvValidateCommand.d.ts.map +1 -0
  48. package/dist/src/Commands/EnvValidateCommand.js +51 -0
  49. package/dist/src/Commands/EnvValidateCommand.js.map +1 -0
  50. package/dist/src/Commands/ListCommand.d.ts.map +1 -1
  51. package/dist/src/Commands/ListCommand.js +15 -8
  52. package/dist/src/Commands/ListCommand.js.map +1 -1
  53. package/dist/src/Commands/MakeCommand.d.ts +7 -0
  54. package/dist/src/Commands/MakeCommand.d.ts.map +1 -0
  55. package/dist/src/Commands/MakeCommand.js +110 -0
  56. package/dist/src/Commands/MakeCommand.js.map +1 -0
  57. package/dist/src/Commands/MakeCommandCommand.d.ts +20 -0
  58. package/dist/src/Commands/MakeCommandCommand.d.ts.map +1 -0
  59. package/dist/src/Commands/MakeCommandCommand.js +82 -0
  60. package/dist/src/Commands/MakeCommandCommand.js.map +1 -0
  61. package/dist/src/Commands/MakeControllerCommand.d.ts +17 -0
  62. package/dist/src/Commands/MakeControllerCommand.d.ts.map +1 -0
  63. package/dist/src/Commands/MakeControllerCommand.js +90 -0
  64. package/dist/src/Commands/MakeControllerCommand.js.map +1 -0
  65. package/dist/src/Commands/MakeEventCommand.d.ts +8 -0
  66. package/dist/src/Commands/MakeEventCommand.d.ts.map +1 -0
  67. package/dist/src/Commands/MakeEventCommand.js +48 -0
  68. package/dist/src/Commands/MakeEventCommand.js.map +1 -0
  69. package/dist/src/Commands/MakeJobCommand.d.ts +8 -0
  70. package/dist/src/Commands/MakeJobCommand.d.ts.map +1 -0
  71. package/dist/src/Commands/MakeJobCommand.js +55 -0
  72. package/dist/src/Commands/MakeJobCommand.js.map +1 -0
  73. package/dist/src/Commands/MakeListenerCommand.d.ts +8 -0
  74. package/dist/src/Commands/MakeListenerCommand.d.ts.map +1 -0
  75. package/dist/src/Commands/MakeListenerCommand.js +55 -0
  76. package/dist/src/Commands/MakeListenerCommand.js.map +1 -0
  77. package/dist/src/Commands/MakeMiddlewareCommand.d.ts +17 -0
  78. package/dist/src/Commands/MakeMiddlewareCommand.d.ts.map +1 -0
  79. package/dist/src/Commands/MakeMiddlewareCommand.js +69 -0
  80. package/dist/src/Commands/MakeMiddlewareCommand.js.map +1 -0
  81. package/dist/src/Commands/MakeMigrationCommand.js +4 -4
  82. package/dist/src/Commands/MakeMigrationCommand.js.map +1 -1
  83. package/dist/src/Commands/MakeModelCommand.d.ts +26 -0
  84. package/dist/src/Commands/MakeModelCommand.d.ts.map +1 -0
  85. package/dist/src/Commands/MakeModelCommand.js +193 -0
  86. package/dist/src/Commands/MakeModelCommand.js.map +1 -0
  87. package/dist/src/Commands/MakeProviderCommand.d.ts +17 -0
  88. package/dist/src/Commands/MakeProviderCommand.d.ts.map +1 -0
  89. package/dist/src/Commands/MakeProviderCommand.js +72 -0
  90. package/dist/src/Commands/MakeProviderCommand.js.map +1 -0
  91. package/dist/src/Commands/MakeViewCommand.d.ts +7 -0
  92. package/dist/src/Commands/MakeViewCommand.d.ts.map +1 -0
  93. package/dist/src/Commands/MakeViewCommand.js +37 -0
  94. package/dist/src/Commands/MakeViewCommand.js.map +1 -0
  95. package/dist/src/Commands/MigrateFreshCommand.d.ts +10 -0
  96. package/dist/src/Commands/MigrateFreshCommand.d.ts.map +1 -0
  97. package/dist/src/Commands/MigrateFreshCommand.js +129 -0
  98. package/dist/src/Commands/MigrateFreshCommand.js.map +1 -0
  99. package/dist/src/Commands/NewCommand.d.ts.map +1 -1
  100. package/dist/src/Commands/NewCommand.js +92 -24
  101. package/dist/src/Commands/NewCommand.js.map +1 -1
  102. package/dist/src/Commands/QueueFailedCommand.d.ts +7 -0
  103. package/dist/src/Commands/QueueFailedCommand.d.ts.map +1 -0
  104. package/dist/src/Commands/QueueFailedCommand.js +30 -0
  105. package/dist/src/Commands/QueueFailedCommand.js.map +1 -0
  106. package/dist/src/Commands/QueueFailedTableCommand.d.ts +7 -0
  107. package/dist/src/Commands/QueueFailedTableCommand.d.ts.map +1 -0
  108. package/dist/src/Commands/QueueFailedTableCommand.js +55 -0
  109. package/dist/src/Commands/QueueFailedTableCommand.js.map +1 -0
  110. package/dist/src/Commands/QueueFlushCommand.d.ts +7 -0
  111. package/dist/src/Commands/QueueFlushCommand.d.ts.map +1 -0
  112. package/dist/src/Commands/QueueFlushCommand.js +21 -0
  113. package/dist/src/Commands/QueueFlushCommand.js.map +1 -0
  114. package/dist/src/Commands/QueueRetryCommand.d.ts +7 -0
  115. package/dist/src/Commands/QueueRetryCommand.d.ts.map +1 -0
  116. package/dist/src/Commands/QueueRetryCommand.js +36 -0
  117. package/dist/src/Commands/QueueRetryCommand.js.map +1 -0
  118. package/dist/src/Commands/QueueTableCommand.d.ts.map +1 -1
  119. package/dist/src/Commands/QueueTableCommand.js +19 -13
  120. package/dist/src/Commands/QueueTableCommand.js.map +1 -1
  121. package/dist/src/Commands/QueueWorkCommand.d.ts +8 -0
  122. package/dist/src/Commands/QueueWorkCommand.d.ts.map +1 -0
  123. package/dist/src/Commands/QueueWorkCommand.js +88 -0
  124. package/dist/src/Commands/QueueWorkCommand.js.map +1 -0
  125. package/dist/src/Commands/RouteListCommand.d.ts +7 -0
  126. package/dist/src/Commands/RouteListCommand.d.ts.map +1 -0
  127. package/dist/src/Commands/RouteListCommand.js +108 -0
  128. package/dist/src/Commands/RouteListCommand.js.map +1 -0
  129. package/dist/src/Commands/ScheduleRunCommand.d.ts +9 -0
  130. package/dist/src/Commands/ScheduleRunCommand.d.ts.map +1 -0
  131. package/dist/src/Commands/ScheduleRunCommand.js +80 -0
  132. package/dist/src/Commands/ScheduleRunCommand.js.map +1 -0
  133. package/dist/src/Commands/ScheduleWorkCommand.d.ts +9 -0
  134. package/dist/src/Commands/ScheduleWorkCommand.d.ts.map +1 -0
  135. package/dist/src/Commands/ScheduleWorkCommand.js +81 -0
  136. package/dist/src/Commands/ScheduleWorkCommand.js.map +1 -0
  137. package/dist/src/Commands/ServeCommand.d.ts +1 -0
  138. package/dist/src/Commands/ServeCommand.d.ts.map +1 -1
  139. package/dist/src/Commands/ServeCommand.js +111 -21
  140. package/dist/src/Commands/ServeCommand.js.map +1 -1
  141. package/dist/src/TemplateManager.d.ts +4 -0
  142. package/dist/src/TemplateManager.d.ts.map +1 -1
  143. package/dist/src/TemplateManager.js +35 -6
  144. package/dist/src/TemplateManager.js.map +1 -1
  145. package/dist/templates/app/.env.example +47 -0
  146. package/dist/templates/app/README.md +62 -0
  147. package/dist/templates/app/app/Exceptions/Handler.ts +19 -0
  148. package/dist/templates/app/app/Http/Controllers/UserController.ts +90 -0
  149. package/dist/templates/app/app/Http/Kernel.ts +43 -0
  150. package/dist/templates/app/app/Http/Middleware/Authenticate.ts +10 -0
  151. package/dist/templates/app/app/Http/Middleware/EnsureEmailIsVerified.ts +18 -0
  152. package/dist/templates/app/app/Http/Middleware/ExampleMiddleware.ts +12 -0
  153. package/dist/templates/app/app/Http/Middleware/RedirectIfAuthenticated.ts +18 -0
  154. package/dist/templates/app/app/Http/Middleware/TrimStrings.ts +12 -0
  155. package/dist/templates/app/app/Http/Middleware/TrustProxies.ts +23 -0
  156. package/dist/templates/app/app/Http/Middleware/VerifyCsrfToken.ts +10 -0
  157. package/dist/templates/app/app/Models/User.ts +15 -0
  158. package/dist/templates/app/app/Providers/AppServiceProvider.ts +17 -0
  159. package/dist/templates/app/app/Providers/RouteServiceProvider.ts +35 -0
  160. package/dist/templates/app/bootstrap/app.ts +41 -0
  161. package/dist/templates/app/config/app.ts +10 -0
  162. package/dist/templates/app/config/cache.ts +44 -0
  163. package/dist/templates/app/config/database.ts +63 -0
  164. package/dist/templates/app/config/filesystems.ts +35 -0
  165. package/dist/templates/app/config/http.ts +6 -0
  166. package/dist/templates/app/config/logging.ts +37 -0
  167. package/dist/templates/app/config/mail.ts +29 -0
  168. package/dist/templates/app/config/queue.ts +42 -0
  169. package/{templates/app/database/migrations/0001_create_users_table.ts → dist/templates/app/database/migrations/2024_01_01_000001_create_users_table.ts} +3 -1
  170. package/dist/templates/app/database/migrations/2024_01_01_000002_create_password_resets_table.ts +22 -0
  171. package/dist/templates/app/database/migrations/2024_01_01_000003_create_failed_jobs_table.ts +25 -0
  172. package/dist/templates/app/package.json +22 -0
  173. package/dist/templates/app/public/assets/img/favicon.png +0 -0
  174. package/dist/templates/app/public/assets/img/logo.png +0 -0
  175. package/dist/templates/app/resources/views/errors/401.ark.html +320 -0
  176. package/dist/templates/app/resources/views/errors/403.ark.html +320 -0
  177. package/dist/templates/app/resources/views/errors/404.ark.html +320 -0
  178. package/dist/templates/app/resources/views/errors/419.ark.html +320 -0
  179. package/dist/templates/app/resources/views/errors/429.ark.html +320 -0
  180. package/dist/templates/app/resources/views/errors/500.ark.html +320 -0
  181. package/dist/templates/app/resources/views/errors/503.ark.html +320 -0
  182. package/dist/templates/app/resources/views/welcome.ark.html +846 -0
  183. package/dist/templates/app/routes/api.ts +39 -0
  184. package/dist/templates/app/routes/web.ts +10 -0
  185. package/dist/templates/app/server.ts +15 -0
  186. package/dist/templates/app/tsconfig.json +27 -0
  187. package/package.json +16 -10
  188. package/templates/app/.env.example +2 -2
  189. package/templates/app/README.md +62 -0
  190. package/templates/app/app/Exceptions/Handler.ts +19 -0
  191. package/templates/app/app/Http/Controllers/UserController.ts +90 -0
  192. package/templates/app/app/Http/Kernel.ts +39 -14
  193. package/templates/app/app/Http/Middleware/Authenticate.ts +10 -0
  194. package/templates/app/app/Http/Middleware/EnsureEmailIsVerified.ts +18 -0
  195. package/templates/app/app/Http/Middleware/ExampleMiddleware.ts +12 -0
  196. package/templates/app/app/Http/Middleware/RedirectIfAuthenticated.ts +18 -0
  197. package/templates/app/app/Http/Middleware/TrimStrings.ts +12 -0
  198. package/templates/app/app/Http/Middleware/TrustProxies.ts +23 -0
  199. package/templates/app/app/Http/Middleware/VerifyCsrfToken.ts +10 -0
  200. package/templates/app/app/Models/User.ts +5 -5
  201. package/templates/app/app/Providers/AppServiceProvider.ts +17 -0
  202. package/templates/app/app/Providers/RouteServiceProvider.ts +35 -0
  203. package/templates/app/bootstrap/app.ts +30 -2
  204. package/templates/app/config/app.ts +7 -6
  205. package/templates/app/config/cache.ts +14 -7
  206. package/templates/app/config/database.ts +48 -21
  207. package/templates/app/config/filesystems.ts +11 -9
  208. package/templates/app/config/http.ts +3 -2
  209. package/templates/app/config/logging.ts +6 -4
  210. package/templates/app/config/mail.ts +10 -8
  211. package/templates/app/config/queue.ts +6 -4
  212. package/templates/app/database/migrations/2024_01_01_000001_create_users_table.ts +25 -0
  213. package/templates/app/database/migrations/2024_01_01_000002_create_password_resets_table.ts +22 -0
  214. package/templates/app/database/migrations/2024_01_01_000003_create_failed_jobs_table.ts +25 -0
  215. package/templates/app/package.json +4 -3
  216. package/templates/app/public/assets/img/favicon.png +0 -0
  217. package/templates/app/public/assets/img/logo.png +0 -0
  218. package/templates/app/resources/views/welcome.ark.html +846 -0
  219. package/templates/app/routes/api.ts +8 -3
  220. package/templates/app/routes/web.ts +8 -4
  221. package/templates/app/server.ts +3 -4
  222. package/templates/app/tsconfig.json +12 -0
  223. package/dist/tests/Cli.test.d.ts +0 -2
  224. package/dist/tests/Cli.test.d.ts.map +0 -1
  225. package/dist/tests/Cli.test.js +0 -16
  226. package/dist/tests/Cli.test.js.map +0 -1
  227. package/templates/app/app/Controllers/UserController.ts +0 -88
  228. package/templates/app/resources/views/welcome.html +0 -470
@@ -0,0 +1,39 @@
1
+ import { Route, Request, Response, app } from 'arikajs';
2
+ import { UserController } from '@Controllers/UserController';
3
+
4
+ Route.get('/', () => {
5
+ return {
6
+ framework: 'ArikaJS',
7
+ version: app().version(),
8
+ type: 'Fullstack',
9
+ language: 'TypeScript',
10
+ status: 'Online',
11
+ message: 'Welcome to your premium ArikaJS Fullstack Application',
12
+ links: {
13
+ docs: 'https://github.com/arikajs/arikajs#readme',
14
+ github: 'https://github.com/arikajs/arikajs'
15
+ }
16
+ };
17
+ });
18
+
19
+ Route.get('/status', () => {
20
+ return {
21
+ status: 'UP',
22
+ uptime: process.uptime(),
23
+ timestamp: new Date().toISOString()
24
+ };
25
+ });
26
+
27
+ // Users CRUD Routes
28
+ const userController = new UserController();
29
+
30
+ Route.get('/users', userController.index);
31
+ Route.get('/users/:id', userController.show);
32
+ Route.post('/users', userController.store);
33
+ Route.put('/users/:id', userController.update);
34
+ Route.delete('/users/:id', userController.destroy);
35
+
36
+ // Example of a protected API route
37
+ // Route.get('/me', (req: Request, res: Response) => {
38
+ // return req.auth.user();
39
+ // }).withMiddleware('auth:api');
@@ -0,0 +1,10 @@
1
+ import { Route, Request, Response, view } from 'arikajs';
2
+
3
+ Route.get('/', (req: Request, res: Response) => {
4
+ return view('welcome', { name: 'ArikaApp' });
5
+ });
6
+
7
+ // Example of a protected route
8
+ // Route.get('/dashboard', (req: Request, res: Response) => {
9
+ // return view('dashboard');
10
+ // }).withMiddleware('auth');
@@ -0,0 +1,15 @@
1
+ import app from './bootstrap/app';
2
+ import { Log, config } from 'arikajs';
3
+
4
+ const start = async () => {
5
+ // Start the application
6
+ console.log('🚀 Starting ArikaJS application...');
7
+
8
+ const port = config('http.port', 3000);
9
+
10
+ await app.listen(port);
11
+ };
12
+
13
+ start().catch((err) => {
14
+ console.error('Failed to start application:', err);
15
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "baseUrl": ".",
7
+ "paths": {
8
+ "@/*": ["app/*"],
9
+ "@Models/*": ["app/Models/*"],
10
+ "@Mail/*": ["app/Mail/*"],
11
+ "@Controllers/*": ["app/Http/Controllers/*"],
12
+ "@Middleware/*": ["app/Http/Middleware/*"],
13
+ "@Http/*": ["app/Http/*"],
14
+ "@Exceptions/*": ["app/Exceptions/*"],
15
+ "@Providers/*": ["app/Providers/*"],
16
+ "@Config/*": ["config/*"]
17
+ },
18
+ "outDir": "./dist",
19
+ "rootDir": "./",
20
+ "strict": true,
21
+ "esModuleInterop": true,
22
+ "skipLibCheck": true,
23
+ "forceConsistentCasingInFileNames": true,
24
+ "experimentalDecorators": true,
25
+ "emitDecoratorMetadata": true
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arikajs/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "The command-line interface for the ArikaJS framework.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -9,12 +9,13 @@
9
9
  "arika": "dist/bin/arika.js"
10
10
  },
11
11
  "scripts": {
12
- "build": "tsc -p tsconfig.json && chmod +x dist/bin/arika.js",
12
+ "build": "tsc -p tsconfig.json && cp -R templates dist/ && chmod +x dist/bin/arika.js",
13
13
  "build:tests": "tsc -p tsconfig.test.json",
14
14
  "clean": "rm -rf dist",
15
15
  "prepare": "echo skip",
16
16
  "test": "npm run build && npm run build:tests && node --test 'dist/tests/**/*.test.js'",
17
- "test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'"
17
+ "test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'",
18
+ "dev": "tsc -p tsconfig.json --watch"
18
19
  },
19
20
  "files": [
20
21
  "dist",
@@ -32,18 +33,23 @@
32
33
  },
33
34
  "repository": {
34
35
  "type": "git",
35
- "url": "git+https://github.com/arikajs/cli.git"
36
+ "url": "git+https://github.com/ArikaJs/arikajs.git",
37
+ "directory": "packages/cli"
36
38
  },
37
39
  "bugs": {
38
- "url": "https://github.com/arikajs/cli/issues"
40
+ "url": "https://github.com/ArikaJs/arikajs/issues"
39
41
  },
40
- "homepage": "https://github.com/arikajs/cli#readme",
42
+ "homepage": "https://github.com/ArikaJs/arikajs/tree/main/packages/cli#readme",
41
43
  "dependencies": {
42
- "@arikajs/console": "file:../console",
43
- "@arikajs/database": "file:../database",
44
- "@arikajs/docs": "file:../docs",
44
+ "@arikajs/console": "*",
45
+ "@arikajs/database": "*",
46
+ "@arikajs/docs": "*",
47
+ "@arikajs/scheduler": "*",
48
+ "dotenv": "^16.4.5",
45
49
  "inquirer": "^8.2.7",
46
- "dotenv": "^16.4.5"
50
+ "ts-node": "^10.9.2",
51
+ "tsx": "^4.21.0",
52
+ "typescript": "^5.3.3"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@types/dotenv": "^8.2.3",
@@ -1,4 +1,4 @@
1
- APP_NAME=ArikaApp
1
+ APP_NAME=ArikaJs
2
2
  APP_ENV=development
3
3
  APP_PORT=3000
4
4
  APP_DEBUG=true
@@ -43,5 +43,5 @@ LOG_LEVEL=debug
43
43
 
44
44
  QUEUE_CONNECTION=sync
45
45
 
46
- CACHE_STORE=database
46
+ CACHE_STORE=file
47
47
  CACHE_PREFIX=arika_cache
@@ -0,0 +1,62 @@
1
+ # ArikaJS Application
2
+
3
+ Welcome to your new **ArikaJS** application! This project was generated with the ArikaJS CLI, providing you with a premium, type-safe, and high-performance foundation for your next web application or API.
4
+
5
+ ## 🚀 Getting Started
6
+
7
+ ### 1. Install Dependencies
8
+
9
+ ```bash
10
+ npm install
11
+ ```
12
+
13
+ ### 2. Configure Environment
14
+
15
+ Copy the `.env.example` file to `.env` and set your configuration value (like `APP_KEY` and database credentials).
16
+
17
+ ```bash
18
+ cp .env.example .env
19
+ ```
20
+
21
+ ### 3. Generate Application Key
22
+
23
+ ```bash
24
+ npx arika key:generate
25
+ ```
26
+
27
+ ### 4. Start Development Server
28
+
29
+ ```bash
30
+ npm run dev
31
+ ```
32
+
33
+ Your application will be running at `http://localhost:3000` 🎉
34
+
35
+ ## 🏗 Project Structure
36
+
37
+ - `app/`: Contains your application logic (Controllers, Models, Middleware).
38
+ - `bootstrap/`: Application bootstrapping and service provider registration.
39
+ - `config/`: Configuration files for various system components.
40
+ - `database/`: Migrations and seeders.
41
+ - `public/`: Static assets (images, CSS, JS).
42
+ - `resources/`: Views and templates.
43
+ - `routes/`: Route definitions for Web and API.
44
+ - `server.ts`: The entry point for the application.
45
+
46
+ ## 📚 Features
47
+
48
+ - **Eloquent-style ORM**: Simple and powerful database interactions.
49
+ - **Native Validation**: Easy request validation directly in your controllers.
50
+ - **Service Container**: Robust dependency injection and service management.
51
+ - **Middleware Pipeline**: Flexible request/response processing.
52
+ - **Templating Engine**: Fast and intuitive HTML rendering.
53
+
54
+ ## 🤝 Community & Support
55
+
56
+ - [GitHub Repository](https://github.com/arikajs/arikajs)
57
+ - [Documentation](https://github.com/arikajs/arikajs#readme)
58
+ - [Issue Tracker](https://github.com/arikajs/arikajs/issues)
59
+
60
+ ---
61
+
62
+ **Built with ❤️ by the ArikaJS Team**
@@ -0,0 +1,19 @@
1
+ import { Handler as BaseHandler } from 'arikajs';
2
+
3
+ export class Handler extends BaseHandler {
4
+ /**
5
+ * Report or log an exception.
6
+ */
7
+ public report(error: any): void {
8
+ super.report(error);
9
+ }
10
+
11
+ /**
12
+ * Register the exception handling callbacks for the application.
13
+ */
14
+ public register(): void {
15
+ //
16
+ }
17
+ }
18
+
19
+
@@ -0,0 +1,90 @@
1
+ import { Request, Response } from 'arikajs';
2
+ import { User } from '@Models/User';
3
+
4
+ export class UserController {
5
+ /**
6
+ * Display a listing of the resource.
7
+ */
8
+ async index(req: Request, res: Response) {
9
+ const users = await User.all();
10
+ return res.json({
11
+ message: 'List of all users',
12
+ data: users
13
+ });
14
+ }
15
+
16
+ /**
17
+ * Display the specified resource.
18
+ */
19
+ async show(req: Request, res: Response) {
20
+ const id = req.param('id');
21
+ const user = await User.find(id);
22
+
23
+ if (!user) {
24
+ return res.status(404).json({ message: 'User not found' });
25
+ }
26
+
27
+ return res.json({
28
+ message: 'User details',
29
+ data: user
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Store a newly created resource.
35
+ */
36
+ async store(req: Request, res: Response) {
37
+ const data = await req.validate({
38
+ name: 'required|string|max:255',
39
+ email: 'required|email|unique:users',
40
+ password: 'required|string|min:8',
41
+ });
42
+
43
+ const user = await User.create(data);
44
+
45
+ return res.status(201).json({
46
+ message: 'User created successfully',
47
+ data: user
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Update the specified resource.
53
+ */
54
+ async update(req: Request, res: Response) {
55
+ const id = req.param('id');
56
+ const user = await User.find(id);
57
+
58
+ if (!user) {
59
+ return res.status(404).json({ message: 'User not found' });
60
+ }
61
+
62
+ const data = await req.validate({
63
+ name: 'string|max:255',
64
+ email: `email|unique:users,email,${id}`,
65
+ });
66
+
67
+ await user.update(data);
68
+
69
+ return res.json({
70
+ message: 'User updated successfully',
71
+ data: user
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Remove the specified resource.
77
+ */
78
+ async destroy(req: Request, res: Response) {
79
+ const id = req.param('id');
80
+ const user = await User.find(id);
81
+
82
+ if (!user) {
83
+ return res.status(404).json({ message: 'User not found' });
84
+ }
85
+
86
+ await user.delete();
87
+
88
+ return res.json({ message: 'User deleted successfully' });
89
+ }
90
+ }
@@ -1,18 +1,43 @@
1
- import { Kernel as BaseKernel } from 'arikajs';
1
+ import { Kernel as BaseKernel, StartSession, ViewMiddleware } from 'arikajs';
2
+ import { Authenticate } from '@Middleware/Authenticate';
3
+ import { RedirectIfAuthenticated } from '@Middleware/RedirectIfAuthenticated';
4
+ import { EnsureEmailIsVerified } from '@Middleware/EnsureEmailIsVerified';
5
+ import { VerifyCsrfToken } from '@Middleware/VerifyCsrfToken';
6
+ import { TrimStrings } from '@Middleware/TrimStrings';
7
+ import { TrustProxies } from '@Middleware/TrustProxies';
2
8
 
3
9
  export class Kernel extends BaseKernel {
4
- /**
5
- * The application's route middleware groups.
6
- */
7
- protected middlewareGroups = {
8
- web: [],
9
- api: [],
10
- };
10
+ constructor(app: any) {
11
+ super(app);
11
12
 
12
- /**
13
- * The application's route middleware aliases.
14
- */
15
- protected routeMiddleware = {
16
- 'auth': (request: any, next: any) => next(request), // dummy for now
17
- };
13
+ // Global middleware — runs on EVERY request (web + API).
14
+ this.middleware.push(
15
+ new TrustProxies(),
16
+ new TrimStrings(),
17
+ );
18
+
19
+ // Middleware groups — 'web' and 'api' groups.
20
+ Object.assign(this.middlewareGroups, {
21
+ web: [
22
+ StartSession,
23
+ ViewMiddleware,
24
+ new VerifyCsrfToken(),
25
+ ],
26
+ api: [
27
+ 'throttle:120,60',
28
+ ],
29
+ });
30
+
31
+ // Named route middleware — aliases.
32
+ Object.assign(this.routeMiddleware, {
33
+ 'auth': Authenticate,
34
+ 'guest': RedirectIfAuthenticated,
35
+ 'verified': EnsureEmailIsVerified,
36
+ });
37
+
38
+ // Sync with router
39
+ const router = this.app.getRouter();
40
+ router.setMiddlewareGroups(this.middlewareGroups);
41
+ router.setRouteMiddleware(this.routeMiddleware);
42
+ }
18
43
  }
@@ -0,0 +1,10 @@
1
+ import { Authenticate as Middleware, Request } from 'arikajs';
2
+
3
+ export class Authenticate extends Middleware {
4
+ /**
5
+ * Get the path the user should be redirected to when they are not authenticated.
6
+ */
7
+ protected redirectTo(request: Request): string | null {
8
+ return request.expectsJson() ? null : '/auth/login';
9
+ }
10
+ }
@@ -0,0 +1,18 @@
1
+ import { Request, Response, Middleware } from 'arikajs';
2
+
3
+ export class EnsureEmailIsVerified implements Middleware {
4
+ /**
5
+ * Handle an incoming request.
6
+ */
7
+ public async handle(request: Request, next: (request: Request) => Promise<Response>): Promise<Response> {
8
+ const user = await request.auth.user();
9
+
10
+ if (!user || (typeof user.hasVerifiedEmail === 'function' && !user.hasVerifiedEmail())) {
11
+ return request.expectsJson()
12
+ ? (request as any).res.json({ message: 'Your email address is not verified.' }, 403)
13
+ : (request as any).res.redirect('/auth/verify');
14
+ }
15
+
16
+ return await next(request);
17
+ }
18
+ }
@@ -0,0 +1,12 @@
1
+ import { Request, Response } from 'arikajs';
2
+
3
+ export class ExampleMiddleware {
4
+ /**
5
+ * Handle an incoming request.
6
+ */
7
+ public async handle(request: Request, next: (req: Request) => Promise<Response>): Promise<Response> {
8
+ // Perform some action...
9
+
10
+ return await next(request);
11
+ }
12
+ }
@@ -0,0 +1,18 @@
1
+ import { Request, Response } from 'arikajs';
2
+
3
+ export class RedirectIfAuthenticated {
4
+ /**
5
+ * Handle an incoming request.
6
+ */
7
+ public async handle(request: Request, next: (request: Request) => Promise<Response>, ...guards: string[]): Promise<Response> {
8
+ const authGuards = guards.length > 0 ? guards : [undefined];
9
+
10
+ for (const guard of authGuards) {
11
+ if (await request.auth.guard(guard).check()) {
12
+ return (request as any).res.redirect('/dashboard');
13
+ }
14
+ }
15
+
16
+ return await next(request);
17
+ }
18
+ }
@@ -0,0 +1,12 @@
1
+ import { TrimStrings as Middleware } from 'arikajs';
2
+
3
+ export class TrimStrings extends Middleware {
4
+ /**
5
+ * The names of the attributes that should not be trimmed.
6
+ */
7
+ protected except: string[] = [
8
+ 'current_password',
9
+ 'password',
10
+ 'password_confirmation',
11
+ ];
12
+ }
@@ -0,0 +1,23 @@
1
+ import { Request, Response, Middleware } from 'arikajs';
2
+
3
+ export class TrustProxies implements Middleware {
4
+ /**
5
+ * The trusted proxies for the application.
6
+ * Use '*' to trust all proxies, or an array of IP addresses.
7
+ */
8
+ protected proxies: string | string[] = '*';
9
+
10
+ /**
11
+ * The proxy header mappings.
12
+ */
13
+ protected headers: string = 'X-Forwarded-For | X-Forwarded-Host | X-Forwarded-Proto';
14
+
15
+ /**
16
+ * Handle an incoming request.
17
+ */
18
+ public async handle(request: Request, next: (request: Request) => Promise<Response>): Promise<Response> {
19
+ // In ArikaJS, proxy trust is currently configured in the config/http.ts file,
20
+ // but this middleware can be used to dynamically set trust logic if needed.
21
+ return await next(request);
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import { VerifyCsrfToken as Middleware } from 'arikajs';
2
+
3
+ export class VerifyCsrfToken extends Middleware {
4
+ /**
5
+ * The URIs that should be excluded from CSRF verification.
6
+ */
7
+ protected except: string[] = [
8
+ //
9
+ ];
10
+ }
@@ -1,15 +1,15 @@
1
1
  import { Model } from 'arikajs';
2
2
 
3
3
  export class User extends Model {
4
- static table = 'users';
4
+ protected static table = 'users';
5
5
 
6
- static fillable = [
6
+ protected fillable: string[] = [
7
7
  'name',
8
8
  'email',
9
- 'password'
9
+ 'password',
10
10
  ];
11
11
 
12
- static hidden = [
13
- 'password'
12
+ protected hidden: string[] = [
13
+ 'password',
14
14
  ];
15
15
  }
@@ -0,0 +1,17 @@
1
+ import { ServiceProvider } from 'arikajs';
2
+
3
+ export class AppServiceProvider extends ServiceProvider {
4
+ /**
5
+ * Register any application services.
6
+ */
7
+ public register(): void {
8
+ //
9
+ }
10
+
11
+ /**
12
+ * Bootstrap any application services.
13
+ */
14
+ public boot(): void {
15
+ //
16
+ }
17
+ }
@@ -0,0 +1,35 @@
1
+ import { ServiceProvider, Route } from 'arikajs';
2
+ import path from 'path';
3
+
4
+ export class RouteServiceProvider extends ServiceProvider {
5
+ /**
6
+ * Register any application services.
7
+ */
8
+ public register(): void {
9
+ //
10
+ }
11
+
12
+ /**
13
+ * Bootstrap any application services.
14
+ */
15
+ public boot(): void {
16
+ this.loadRoutes();
17
+ }
18
+
19
+ /**
20
+ * Load the application routes.
21
+ */
22
+ protected loadRoutes(): void {
23
+ const basePath = (this.app as any).getBasePath();
24
+
25
+ // 1. Load web routes (with session, CSRF, etc.)
26
+ Route.middleware('web').group(() => {
27
+ require(path.join(basePath, 'routes/web'));
28
+ });
29
+
30
+ // 2. Load API routes with /api prefix (stateless, auth via JWT)
31
+ Route.middleware('api').prefix('api').group(() => {
32
+ require(path.join(basePath, 'routes/api'));
33
+ });
34
+ }
35
+ }
@@ -5,9 +5,37 @@ const app = createApp(
5
5
  path.resolve(__dirname, '../')
6
6
  );
7
7
 
8
- import { Kernel } from '../app/Http/Kernel';
9
- import { Kernel as BaseKernel } from 'arikajs';
8
+ /*
9
+ |--------------------------------------------------------------------------
10
+ | Register Service Providers
11
+ |--------------------------------------------------------------------------
12
+ |
13
+ | The service providers listed here will be automatically loaded on the
14
+ | request to your application. Feel free to add your own services.
15
+ |
16
+ */
17
+
18
+ import { AppServiceProvider } from '@Providers/AppServiceProvider';
19
+ import { RouteServiceProvider } from '@Providers/RouteServiceProvider';
20
+
21
+ app.register(AppServiceProvider);
22
+ app.register(RouteServiceProvider);
23
+
24
+ /*
25
+ |--------------------------------------------------------------------------
26
+ | Register The Http Kernel
27
+ |--------------------------------------------------------------------------
28
+ |
29
+ | Next, we need to bind the Http Kernel to the container so that it
30
+ | can be resolved when handling requests.
31
+ |
32
+ */
33
+
34
+ import { Kernel } from '@Http/Kernel';
35
+ import { Handler } from '@Exceptions/Handler';
36
+ import { Kernel as BaseKernel, Handler as BaseHandler } from 'arikajs';
10
37
 
11
38
  app.singleton(BaseKernel, () => new Kernel(app));
39
+ app.singleton(BaseHandler, () => new Handler());
12
40
 
13
41
  export default app;
@@ -1,9 +1,10 @@
1
+ import { env } from 'arikajs';
1
2
 
2
3
  export default {
3
- name: process.env.APP_NAME || 'ArikaJS',
4
- env: process.env.APP_ENV || 'production',
5
- debug: process.env.APP_DEBUG === 'true',
6
- url: process.env.APP_URL || 'http://localhost',
7
- timezone: process.env.APP_TIMEZONE || 'UTC',
8
- key: process.env.APP_KEY,
4
+ name: env('APP_NAME', 'ArikaJS'),
5
+ env: env('APP_ENV', 'production'),
6
+ debug: env('APP_DEBUG', false), // env() handles boolean strings if we want, but let's check.
7
+ url: env('APP_URL', 'http://localhost'),
8
+ timezone: env('APP_TIMEZONE', 'UTC'),
9
+ key: env('APP_KEY'),
9
10
  };