arikajs 0.0.1

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +432 -0
  3. package/dist/Application.d.ts +32 -0
  4. package/dist/Application.d.ts.map +1 -0
  5. package/dist/Application.js +122 -0
  6. package/dist/Application.js.map +1 -0
  7. package/dist/Contracts/Application.d.ts +17 -0
  8. package/dist/Contracts/Application.d.ts.map +1 -0
  9. package/dist/Contracts/Application.js +3 -0
  10. package/dist/Contracts/Application.js.map +1 -0
  11. package/dist/createApp.d.ts +6 -0
  12. package/dist/createApp.d.ts.map +1 -0
  13. package/dist/createApp.js +11 -0
  14. package/dist/createApp.js.map +1 -0
  15. package/dist/http/Handler.d.ts +36 -0
  16. package/dist/http/Handler.d.ts.map +1 -0
  17. package/dist/http/Handler.js +95 -0
  18. package/dist/http/Handler.js.map +1 -0
  19. package/dist/http/Kernel.d.ts +33 -0
  20. package/dist/http/Kernel.d.ts.map +1 -0
  21. package/dist/http/Kernel.js +84 -0
  22. package/dist/http/Kernel.js.map +1 -0
  23. package/dist/http/Middleware/RequestLoggingMiddleware.d.ts +4 -0
  24. package/dist/http/Middleware/RequestLoggingMiddleware.d.ts.map +1 -0
  25. package/dist/http/Middleware/RequestLoggingMiddleware.js +17 -0
  26. package/dist/http/Middleware/RequestLoggingMiddleware.js.map +1 -0
  27. package/dist/http/Middleware/ValidateRequestMiddleware.d.ts +13 -0
  28. package/dist/http/Middleware/ValidateRequestMiddleware.d.ts.map +1 -0
  29. package/dist/http/Middleware/ValidateRequestMiddleware.js +34 -0
  30. package/dist/http/Middleware/ValidateRequestMiddleware.js.map +1 -0
  31. package/dist/index.d.ts +15 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +57 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/providers/AuthServiceProvider.d.ts +12 -0
  36. package/dist/providers/AuthServiceProvider.d.ts.map +1 -0
  37. package/dist/providers/AuthServiceProvider.js +28 -0
  38. package/dist/providers/AuthServiceProvider.js.map +1 -0
  39. package/dist/providers/DatabaseServiceProvider.d.ts +12 -0
  40. package/dist/providers/DatabaseServiceProvider.d.ts.map +1 -0
  41. package/dist/providers/DatabaseServiceProvider.js +39 -0
  42. package/dist/providers/DatabaseServiceProvider.js.map +1 -0
  43. package/dist/providers/FrameworkServiceProvider.d.ts +6 -0
  44. package/dist/providers/FrameworkServiceProvider.d.ts.map +1 -0
  45. package/dist/providers/FrameworkServiceProvider.js +28 -0
  46. package/dist/providers/FrameworkServiceProvider.js.map +1 -0
  47. package/dist/providers/HttpServiceProvider.d.ts +13 -0
  48. package/dist/providers/HttpServiceProvider.d.ts.map +1 -0
  49. package/dist/providers/HttpServiceProvider.js +34 -0
  50. package/dist/providers/HttpServiceProvider.js.map +1 -0
  51. package/dist/providers/LoggingServiceProvider.d.ts +6 -0
  52. package/dist/providers/LoggingServiceProvider.d.ts.map +1 -0
  53. package/dist/providers/LoggingServiceProvider.js +19 -0
  54. package/dist/providers/LoggingServiceProvider.js.map +1 -0
  55. package/dist/providers/ValidationServiceProvider.d.ts +8 -0
  56. package/dist/providers/ValidationServiceProvider.d.ts.map +1 -0
  57. package/dist/providers/ValidationServiceProvider.js +26 -0
  58. package/dist/providers/ValidationServiceProvider.js.map +1 -0
  59. package/package.json +39 -0
  60. package/src/Application.ts +101 -0
  61. package/src/Contracts/Application.ts +18 -0
  62. package/src/createApp.ts +9 -0
  63. package/src/http/Handler.ts +101 -0
  64. package/src/http/Kernel.ts +92 -0
  65. package/src/http/Middleware/RequestLoggingMiddleware.ts +17 -0
  66. package/src/http/Middleware/ValidateRequestMiddleware.ts +35 -0
  67. package/src/index.ts +33 -0
  68. package/src/providers/AuthServiceProvider.ts +28 -0
  69. package/src/providers/DatabaseServiceProvider.ts +40 -0
  70. package/src/providers/FrameworkServiceProvider.ts +26 -0
  71. package/src/providers/HttpServiceProvider.ts +35 -0
  72. package/src/providers/LoggingServiceProvider.ts +17 -0
  73. package/src/providers/ValidationServiceProvider.ts +24 -0
  74. package/tests/Framework.test.ts +120 -0
  75. package/tsconfig.json +25 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArikaJs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,432 @@
1
+ # ArikaJS
2
+
3
+ <div align="center">
4
+
5
+ ![ArikaJS Logo](https://via.placeholder.com/200x200?text=ArikaJS)
6
+
7
+ **A Modern, Elegant Web Framework for Node.js**
8
+
9
+ [![npm version](https://img.shields.io/npm/v/arikajs.svg?style=flat-square)](https://www.npmjs.com/package/arikajs)
10
+ [![npm downloads](https://img.shields.io/npm/dm/arikajs.svg?style=flat-square)](https://www.npmjs.com/package/arikajs)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg?style=flat-square)](https://www.typescriptlang.org/)
13
+ [![Node.js](https://img.shields.io/badge/Node.js-20+-green.svg?style=flat-square)](https://nodejs.org/)
14
+ [![GitHub stars](https://img.shields.io/github/stars/arikajs/arikajs.svg?style=flat-square)](https://github.com/arikajs/arikajs/stargazers)
15
+ [![GitHub issues](https://img.shields.io/github/issues/arikajs/arikajs.svg?style=flat-square)](https://github.com/arikajs/arikajs/issues)
16
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/arikajs/arikajs/pulls)
17
+
18
+ [Quick Start](#quick-start) | [Examples](https://github.com/arikajs/examples) | [Community](https://discord.gg/arikajs)
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## 🚀 What is ArikaJS?
25
+
26
+ ArikaJS is a **modern, elegant, and powerful** Node.js framework that brings enterprise-grade features and developer-friendly patterns to the TypeScript/JavaScript ecosystem. Built from the ground up with TypeScript, ArikaJS provides a robust foundation for building scalable web applications and APIs with an intuitive, expressive syntax.
27
+
28
+ ### ✨ Key Features
29
+
30
+ - 🎯 **Elegant Syntax** - Clean, expressive code that's a joy to write
31
+ - 🔥 **TypeScript First** - Full TypeScript support with excellent type inference
32
+ - 🛣️ **Powerful Routing** - Intuitive routing with implicit model binding
33
+ - 💉 **Dependency Injection** - Built-in IoC container for clean architecture
34
+ - 🗄️ **Active Record ORM** - Eloquent-inspired database layer
35
+ - 🔐 **Authentication & Authorization** - Built-in auth system with guards and policies
36
+ - ✅ **Validation** - Comprehensive request validation
37
+ - 📧 **Mail & Notifications** - Easy email and notification system
38
+ - 🔄 **Queue System** - Background job processing
39
+ - 📦 **Service Providers** - Modular application architecture
40
+ - 🎨 **Template Engine** - Flexible view rendering
41
+ - 🧪 **Testing Ready** - Built with testing in mind
42
+
43
+ ---
44
+
45
+ ## 📦 Installation
46
+
47
+ ### Option 1: Quick Start (Using npx)
48
+
49
+ The fastest way to create a new ArikaJS project is using `npx`. No installation required!
50
+
51
+ ```bash
52
+ # Create a new project
53
+ npx @arikajs/cli new my-app
54
+
55
+ # Navigate to your project
56
+ cd my-app
57
+
58
+ # Start developing
59
+ npm run dev
60
+ ```
61
+
62
+ ### Option 2: Global Installation
63
+
64
+ If you prefer to have the `arika` command available everywhere, you can install the CLI globally:
65
+
66
+ ```bash
67
+ # Install the CLI globally
68
+ npm install -g @arikajs/cli
69
+
70
+ # Create a new project
71
+ arika new my-app
72
+ ```
73
+
74
+ # Install dependencies
75
+ npm install
76
+
77
+ # Start the development server
78
+ npm run dev
79
+ ```
80
+
81
+ Your application will be running at `http://localhost:8000` 🎉
82
+
83
+ ### Manual Installation
84
+
85
+ ```bash
86
+ # Create a new project directory
87
+ mkdir my-app && cd my-app
88
+
89
+ # Initialize npm
90
+ npm init -y
91
+
92
+ # Install ArikaJS
93
+ npm install arikajs
94
+
95
+ # Install dev dependencies
96
+ npm install -D @arikajs/cli typescript tsx @types/node
97
+ ```
98
+
99
+ ---
100
+
101
+ ## 🏗️ Project Structure
102
+
103
+ ```
104
+ my-app/
105
+ ├── app/
106
+ │ ├── Controllers/ # HTTP controllers
107
+ │ ├── Models/ # Database models
108
+ │ ├── Middleware/ # Custom middleware
109
+ │ └── Http/
110
+ │ └── Kernel.ts # HTTP kernel configuration
111
+ ├── bootstrap/
112
+ │ └── app.ts # Application bootstrap
113
+ ├── config/ # Configuration files
114
+ │ ├── app.ts
115
+ │ ├── database.ts
116
+ │ └── logging.ts
117
+ ├── database/
118
+ │ └── migrations/ # Database migrations
119
+ ├── routes/
120
+ │ └── web.ts # Route definitions
121
+ ├── server.ts # Application entry point
122
+ ├── .env # Environment variables
123
+ └── package.json
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 📚 Basic Usage
129
+
130
+ ### Routing
131
+
132
+ Define routes with an elegant, expressive syntax:
133
+
134
+ ```typescript
135
+ import { Route } from 'arikajs';
136
+
137
+ // Simple route
138
+ Route.get('/', () => {
139
+ return { message: 'Welcome to ArikaJS!' };
140
+ });
141
+
142
+ // Route with parameters
143
+ Route.get('/users/{id}', (request, id) => {
144
+ return { userId: id };
145
+ });
146
+
147
+ // Route groups with middleware
148
+ Route.group({ middleware: 'auth' }, () => {
149
+ Route.get('/dashboard', [DashboardController, 'index']);
150
+ Route.post('/posts', [PostController, 'store']);
151
+ });
152
+ ```
153
+
154
+ ### Implicit Model Binding
155
+
156
+ Automatically resolve models from route parameters:
157
+
158
+ ```typescript
159
+ import { Route } from 'arikajs';
160
+ import User from './app/Models/User';
161
+
162
+ // Register model binding
163
+ Route.model('user', User);
164
+
165
+ // The {user} parameter will automatically resolve to a User instance
166
+ Route.get('/users/{user}', (request, user: User) => {
167
+ return {
168
+ message: 'User found!',
169
+ user: user
170
+ };
171
+ });
172
+ ```
173
+
174
+ ### Controllers
175
+
176
+ Create clean, organized controllers:
177
+
178
+ ```typescript
179
+ import { Request, Response } from 'arikajs';
180
+ import User from '../Models/User';
181
+
182
+ export class UserController {
183
+ async index(request: Request, response: Response) {
184
+ const users = await User.all();
185
+ return response.json(users);
186
+ }
187
+
188
+ async show(request: Request, response: Response) {
189
+ const user = await User.findOrFail(request.params.id);
190
+ return response.json(user);
191
+ }
192
+
193
+ async store(request: Request, response: Response) {
194
+ const user = await User.create(request.body);
195
+ return response.status(201).json(user);
196
+ }
197
+ }
198
+ ```
199
+
200
+ ### Models (Active Record)
201
+
202
+ Work with databases using an elegant ORM:
203
+
204
+ ```typescript
205
+ import { Model } from 'arikajs';
206
+
207
+ export default class User extends Model {
208
+ protected static tableName = 'users';
209
+
210
+ // Define relationships
211
+ posts() {
212
+ return this.hasMany(Post);
213
+ }
214
+
215
+ // Custom methods
216
+ async sendWelcomeEmail() {
217
+ // Send email logic
218
+ }
219
+ }
220
+
221
+ // Usage
222
+ const user = await User.find(1);
223
+ const posts = await user.posts().get();
224
+
225
+ const newUser = await User.create({
226
+ name: 'John Doe',
227
+ email: 'john@example.com'
228
+ });
229
+ ```
230
+
231
+ ### Middleware
232
+
233
+ Create custom middleware for request processing:
234
+
235
+ ```typescript
236
+ import { MiddlewareHandler, Request, Response } from 'arikajs';
237
+
238
+ export default class AuthMiddleware implements MiddlewareHandler {
239
+ async handle(request: Request, response: Response, next: Function) {
240
+ if (!request.headers.authorization) {
241
+ return response.status(401).json({ error: 'Unauthorized' });
242
+ }
243
+
244
+ return next();
245
+ }
246
+ }
247
+ ```
248
+
249
+ ### Service Providers
250
+
251
+ Organize your application with service providers:
252
+
253
+ ```typescript
254
+ import { ServiceProvider } from 'arikajs';
255
+ import { PaymentService } from './Services/PaymentService';
256
+
257
+ export class PaymentServiceProvider extends ServiceProvider {
258
+ async register() {
259
+ this.app.singleton('payment', () => {
260
+ return new PaymentService(this.app.config().get('payment'));
261
+ });
262
+ }
263
+
264
+ async boot() {
265
+ // Bootstrap logic
266
+ }
267
+ }
268
+ ```
269
+
270
+ ### Database Migrations
271
+
272
+ Manage your database schema with migrations:
273
+
274
+ ```typescript
275
+ import { Migration, SchemaBuilder } from 'arikajs';
276
+
277
+ export default class CreateUsersTable extends Migration {
278
+ async up(schema: SchemaBuilder) {
279
+ await schema.create('users', (table) => {
280
+ table.increments('id');
281
+ table.string('name');
282
+ table.string('email').unique();
283
+ table.string('password');
284
+ table.timestamps();
285
+ });
286
+ }
287
+
288
+ async down(schema: SchemaBuilder) {
289
+ await schema.dropIfExists('users');
290
+ }
291
+ }
292
+ ```
293
+
294
+ ---
295
+
296
+ ## 🔧 Configuration
297
+
298
+ Configure your application in the `config/` directory:
299
+
300
+ **config/app.ts**
301
+ ```typescript
302
+ export default {
303
+ name: process.env.APP_NAME || 'ArikaJS',
304
+ env: process.env.NODE_ENV || 'development',
305
+ key: process.env.APP_KEY,
306
+ timezone: 'UTC',
307
+ };
308
+ ```
309
+
310
+ **config/database.ts**
311
+ ```typescript
312
+ export default {
313
+ default: 'mysql',
314
+ connections: {
315
+ mysql: {
316
+ driver: 'mysql',
317
+ host: process.env.DB_HOST || 'localhost',
318
+ port: parseInt(process.env.DB_PORT || '3306'),
319
+ database: process.env.DB_DATABASE,
320
+ username: process.env.DB_USERNAME,
321
+ password: process.env.DB_PASSWORD,
322
+ },
323
+ },
324
+ };
325
+ ```
326
+
327
+ ---
328
+
329
+ ## 🎨 CLI Commands
330
+
331
+ ArikaJS comes with a powerful CLI for common tasks:
332
+
333
+ ```bash
334
+ # Create a new application
335
+ arika new my-app
336
+
337
+ # Start development server
338
+ arika serve --dev
339
+
340
+ # Generate application key
341
+ arika key:generate
342
+
343
+ # Database migrations
344
+ arika migrate
345
+ arika migrate:rollback
346
+
347
+ # Create migration
348
+ arika make:migration create_posts_table
349
+ ```
350
+
351
+ ---
352
+
353
+ ## 🧪 Testing
354
+
355
+ ArikaJS is built with testing in mind:
356
+
357
+ ```typescript
358
+ import { describe, it } from 'node:test';
359
+ import assert from 'node:assert';
360
+ import app from './bootstrap/app';
361
+
362
+ describe('User API', () => {
363
+ it('should return all users', async () => {
364
+ const response = await app.get('/api/users');
365
+ assert.strictEqual(response.status, 200);
366
+ });
367
+ });
368
+ ```
369
+
370
+ ---
371
+
372
+ ## 📖 Documentation
373
+
374
+ Comprehensive documentation is available in the [GitHub repository](https://github.com/arikajs/arikajs).
375
+
376
+ For guides and examples, check out:
377
+ - [Installation Guide](https://github.com/arikajs/arikajs#installation)
378
+ - [Routing](https://github.com/arikajs/arikajs#routing)
379
+ - [Controllers](https://github.com/arikajs/arikajs#controllers)
380
+ - [Database & ORM](https://github.com/arikajs/arikajs#models-active-record)
381
+ - [Examples](https://github.com/arikajs/examples)
382
+
383
+ ---
384
+
385
+ ## 🤝 Contributing
386
+
387
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
388
+
389
+ ```bash
390
+ # Clone the repository
391
+ git clone https://github.com/arikajs/arikajs.git
392
+
393
+ # Install dependencies
394
+ npm install
395
+
396
+ # Run tests
397
+ npm test
398
+
399
+ # Build the project
400
+ npm run build
401
+ ```
402
+
403
+ ---
404
+
405
+ ## 📝 License
406
+
407
+ ArikaJS is open-sourced software licensed under the [MIT license](LICENSE).
408
+
409
+ ---
410
+
411
+ ## 🙏 Acknowledgments
412
+
413
+ ArikaJS draws inspiration from the best practices and patterns of modern web frameworks, including elegant API design, developer experience focus, and enterprise-grade architecture.
414
+
415
+ ---
416
+
417
+ ## 💬 Community & Support
418
+
419
+ - 📖 [Documentation](https://github.com/arikajs/arikajs#readme)
420
+ - 💬 [Discord Community](https://discord.gg/arikajs)
421
+ - 🐦 [Twitter](https://twitter.com/arikajs)
422
+ - 🐛 [Issue Tracker](https://github.com/arikajs/arikajs/issues)
423
+
424
+ ---
425
+
426
+ <div align="center">
427
+
428
+ **Built with ❤️ by the ArikaJS Team**
429
+
430
+ [GitHub](https://github.com/arikajs) • [npm](https://www.npmjs.com/package/arikajs)
431
+
432
+ </div>
@@ -0,0 +1,32 @@
1
+ import { Application as FoundationApplication } from '@arikajs/foundation';
2
+ import { Router } from '@arikajs/router';
3
+ import { Application as ApplicationContract } from './Contracts/Application';
4
+ export declare class Application extends FoundationApplication implements ApplicationContract {
5
+ protected router: Router;
6
+ constructor(basePath?: string);
7
+ /**
8
+ * Map a GET route.
9
+ */
10
+ get(path: string, handler: any): import("@arikajs/router").RouteEntry;
11
+ /**
12
+ * Map a POST route.
13
+ */
14
+ post(path: string, handler: any): import("@arikajs/router").RouteEntry;
15
+ /**
16
+ * Map a PUT route.
17
+ */
18
+ put(path: string, handler: any): import("@arikajs/router").RouteEntry;
19
+ /**
20
+ * Map a DELETE route.
21
+ */
22
+ delete(path: string, handler: any): import("@arikajs/router").RouteEntry;
23
+ /**
24
+ * Start the HTTP server.
25
+ */
26
+ listen(port?: number): Promise<void>;
27
+ /**
28
+ * Get the router instance.
29
+ */
30
+ getRouter(): Router;
31
+ }
32
+ //# sourceMappingURL=Application.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../src/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAS,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE7E,qBAAa,WAAY,SAAQ,qBAAsB,YAAW,mBAAmB;IACjF,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEb,QAAQ,GAAE,MAAsB;IAa5C;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAIrC;;OAEG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAItC;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAIrC;;OAEG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAIxC;;OAEG;IACU,MAAM,CAAC,IAAI,GAAE,MAAa;IAyCvC;;OAEG;IACI,SAAS,IAAI,MAAM;CAG7B"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Application = void 0;
37
+ const foundation_1 = require("@arikajs/foundation");
38
+ const router_1 = require("@arikajs/router");
39
+ const FrameworkServiceProvider_1 = require("./providers/FrameworkServiceProvider");
40
+ const logging_1 = require("@arikajs/logging");
41
+ class Application extends foundation_1.Application {
42
+ constructor(basePath = process.cwd()) {
43
+ super(basePath);
44
+ // Initialize Core Components
45
+ this.router = new router_1.Router(this.getContainer());
46
+ // Register within container
47
+ this.instance(router_1.Router, this.router);
48
+ // Register Core Framework Provider
49
+ this.register(FrameworkServiceProvider_1.FrameworkServiceProvider);
50
+ }
51
+ /**
52
+ * Map a GET route.
53
+ */
54
+ get(path, handler) {
55
+ return router_1.Route.get(path, handler);
56
+ }
57
+ /**
58
+ * Map a POST route.
59
+ */
60
+ post(path, handler) {
61
+ return router_1.Route.post(path, handler);
62
+ }
63
+ /**
64
+ * Map a PUT route.
65
+ */
66
+ put(path, handler) {
67
+ return router_1.Route.put(path, handler);
68
+ }
69
+ /**
70
+ * Map a DELETE route.
71
+ */
72
+ delete(path, handler) {
73
+ return router_1.Route.delete(path, handler);
74
+ }
75
+ /**
76
+ * Start the HTTP server.
77
+ */
78
+ async listen(port = 3000) {
79
+ if (!this.isBooted()) {
80
+ await this.boot();
81
+ }
82
+ const http = await Promise.resolve().then(() => __importStar(require('node:http')));
83
+ const { Request, Response } = await Promise.resolve().then(() => __importStar(require('@arikajs/http')));
84
+ const { Kernel } = await Promise.resolve().then(() => __importStar(require('./http/Kernel')));
85
+ // Resolve Kernel from the container
86
+ const kernel = this.make(Kernel);
87
+ const server = http.createServer(async (req, res) => {
88
+ // Instantiate Request and Response
89
+ // In a future refactor, these could also be resolved from factories
90
+ const request = new Request(this, req);
91
+ const response = new Response(res);
92
+ try {
93
+ const finalResponse = await kernel.handle(request, response);
94
+ kernel.terminate(request, finalResponse);
95
+ }
96
+ catch (error) {
97
+ if (!res.headersSent) {
98
+ res.writeHead(500, { 'Content-Type': 'application/json' });
99
+ res.end(JSON.stringify({
100
+ error: 'Internal Server Error',
101
+ message: error.message,
102
+ stack: process.env.NODE_ENV === 'development' ? error.stack : undefined
103
+ }));
104
+ }
105
+ }
106
+ });
107
+ return new Promise((resolve) => {
108
+ server.listen(port, () => {
109
+ logging_1.Log.info(`ArikaJS application listening on http://localhost:${port}`);
110
+ resolve();
111
+ });
112
+ });
113
+ }
114
+ /**
115
+ * Get the router instance.
116
+ */
117
+ getRouter() {
118
+ return this.router;
119
+ }
120
+ }
121
+ exports.Application = Application;
122
+ //# sourceMappingURL=Application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Application.js","sourceRoot":"","sources":["../src/Application.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,17 @@
1
+ import { Router } from '@arikajs/router';
2
+ import { Application as HttpApplicationContract } from '@arikajs/http';
3
+ export interface Application extends HttpApplicationContract {
4
+ getRouter(): Router;
5
+ getContainer(): any;
6
+ getBasePath(): string;
7
+ make<T = any>(token: any): T;
8
+ singleton<T = any>(token: any, factory: any): void;
9
+ instance<T = any>(token: any, value: T): void;
10
+ bind<T = any>(token: any, factory: any): void;
11
+ resolve<T = any>(token: any): T;
12
+ register(provider: any): void;
13
+ boot(): Promise<void>;
14
+ run(): Promise<void>;
15
+ isBooted(): boolean;
16
+ }
17
+ //# sourceMappingURL=Application.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../src/Contracts/Application.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAEvE,MAAM,WAAW,WAAY,SAAQ,uBAAuB;IACxD,SAAS,IAAI,MAAM,CAAC;IACpB,YAAY,IAAI,GAAG,CAAC;IACpB,WAAW,IAAI,MAAM,CAAC;IACtB,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC;IAC7B,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAC9C,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IAC9C,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAC;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,QAAQ,IAAI,OAAO,CAAC;CACvB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Application.js","sourceRoot":"","sources":["../../src/Contracts/Application.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { Application } from './Application';
2
+ /**
3
+ * Helper to create a new ArikaJS application instance.
4
+ */
5
+ export declare function createApp(basePath?: string): Application;
6
+ //# sourceMappingURL=createApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createApp.d.ts","sourceRoot":"","sources":["../src/createApp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAExD"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createApp = createApp;
4
+ const Application_1 = require("./Application");
5
+ /**
6
+ * Helper to create a new ArikaJS application instance.
7
+ */
8
+ function createApp(basePath) {
9
+ return new Application_1.Application(basePath);
10
+ }
11
+ //# sourceMappingURL=createApp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createApp.js","sourceRoot":"","sources":["../src/createApp.ts"],"names":[],"mappings":";;AAMA,8BAEC;AAPD,+CAA4C;AAE5C;;GAEG;AACH,SAAgB,SAAS,CAAC,QAAiB;IACvC,OAAO,IAAI,yBAAW,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC"}