arikajs 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +419 -0
- package/dist/Application.d.ts +32 -0
- package/dist/Application.d.ts.map +1 -0
- package/dist/Application.js +122 -0
- package/dist/Application.js.map +1 -0
- package/dist/Contracts/Application.d.ts +17 -0
- package/dist/Contracts/Application.d.ts.map +1 -0
- package/dist/Contracts/Application.js +3 -0
- package/dist/Contracts/Application.js.map +1 -0
- package/dist/createApp.d.ts +6 -0
- package/dist/createApp.d.ts.map +1 -0
- package/dist/createApp.js +11 -0
- package/dist/createApp.js.map +1 -0
- package/dist/http/Handler.d.ts +36 -0
- package/dist/http/Handler.d.ts.map +1 -0
- package/dist/http/Handler.js +95 -0
- package/dist/http/Handler.js.map +1 -0
- package/dist/http/Kernel.d.ts +33 -0
- package/dist/http/Kernel.d.ts.map +1 -0
- package/dist/http/Kernel.js +82 -0
- package/dist/http/Kernel.js.map +1 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.d.ts +4 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.d.ts.map +1 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.js +17 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.js.map +1 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.d.ts +13 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.d.ts.map +1 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.js +34 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/AuthServiceProvider.d.ts +12 -0
- package/dist/providers/AuthServiceProvider.d.ts.map +1 -0
- package/dist/providers/AuthServiceProvider.js +28 -0
- package/dist/providers/AuthServiceProvider.js.map +1 -0
- package/dist/providers/DatabaseServiceProvider.d.ts +12 -0
- package/dist/providers/DatabaseServiceProvider.d.ts.map +1 -0
- package/dist/providers/DatabaseServiceProvider.js +39 -0
- package/dist/providers/DatabaseServiceProvider.js.map +1 -0
- package/dist/providers/FrameworkServiceProvider.d.ts +6 -0
- package/dist/providers/FrameworkServiceProvider.d.ts.map +1 -0
- package/dist/providers/FrameworkServiceProvider.js +28 -0
- package/dist/providers/FrameworkServiceProvider.js.map +1 -0
- package/dist/providers/HttpServiceProvider.d.ts +13 -0
- package/dist/providers/HttpServiceProvider.d.ts.map +1 -0
- package/dist/providers/HttpServiceProvider.js +34 -0
- package/dist/providers/HttpServiceProvider.js.map +1 -0
- package/dist/providers/LoggingServiceProvider.d.ts +6 -0
- package/dist/providers/LoggingServiceProvider.d.ts.map +1 -0
- package/dist/providers/LoggingServiceProvider.js +19 -0
- package/dist/providers/LoggingServiceProvider.js.map +1 -0
- package/dist/providers/ValidationServiceProvider.d.ts +8 -0
- package/dist/providers/ValidationServiceProvider.d.ts.map +1 -0
- package/dist/providers/ValidationServiceProvider.js +26 -0
- package/dist/providers/ValidationServiceProvider.js.map +1 -0
- package/package.json +38 -0
- package/package.json.backup +38 -0
- package/src/Application.ts +101 -0
- package/src/Contracts/Application.ts +18 -0
- package/src/createApp.ts +9 -0
- package/src/http/Handler.ts +101 -0
- package/src/http/Kernel.ts +90 -0
- package/src/http/Middleware/RequestLoggingMiddleware.ts +17 -0
- package/src/http/Middleware/ValidateRequestMiddleware.ts +35 -0
- package/src/index.ts +33 -0
- package/src/providers/AuthServiceProvider.ts +28 -0
- package/src/providers/DatabaseServiceProvider.ts +40 -0
- package/src/providers/FrameworkServiceProvider.ts +26 -0
- package/src/providers/HttpServiceProvider.ts +35 -0
- package/src/providers/LoggingServiceProvider.ts +17 -0
- package/src/providers/ValidationServiceProvider.ts +24 -0
- package/tests/Framework.test.ts +120 -0
- 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,419 @@
|
|
|
1
|
+
# ArikaJS
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
**A Modern, Elegant Web Framework for Node.js**
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/arikajs)
|
|
10
|
+
[](https://www.npmjs.com/package/arikajs)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
12
|
+
[](https://www.typescriptlang.org/)
|
|
13
|
+
[](https://nodejs.org/)
|
|
14
|
+
[](https://github.com/arikajs/arikajs/stargazers)
|
|
15
|
+
[](https://github.com/arikajs/arikajs/issues)
|
|
16
|
+
[](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
|
+
### Quick Start with CLI
|
|
48
|
+
|
|
49
|
+
The fastest way to get started is using the ArikaJS CLI:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Install the CLI globally
|
|
53
|
+
npm install -g @arikajs/cli
|
|
54
|
+
|
|
55
|
+
# Create a new project
|
|
56
|
+
arika new my-app
|
|
57
|
+
|
|
58
|
+
# Navigate to your project
|
|
59
|
+
cd my-app
|
|
60
|
+
|
|
61
|
+
# Install dependencies
|
|
62
|
+
npm install
|
|
63
|
+
|
|
64
|
+
# Start the development server
|
|
65
|
+
npm run dev
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Your application will be running at `http://localhost:8000` 🎉
|
|
69
|
+
|
|
70
|
+
### Manual Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Create a new project directory
|
|
74
|
+
mkdir my-app && cd my-app
|
|
75
|
+
|
|
76
|
+
# Initialize npm
|
|
77
|
+
npm init -y
|
|
78
|
+
|
|
79
|
+
# Install ArikaJS
|
|
80
|
+
npm install arikajs
|
|
81
|
+
|
|
82
|
+
# Install dev dependencies
|
|
83
|
+
npm install -D @arikajs/cli typescript tsx @types/node
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🏗️ Project Structure
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
my-app/
|
|
92
|
+
├── app/
|
|
93
|
+
│ ├── Controllers/ # HTTP controllers
|
|
94
|
+
│ ├── Models/ # Database models
|
|
95
|
+
│ ├── Middleware/ # Custom middleware
|
|
96
|
+
│ └── Http/
|
|
97
|
+
│ └── Kernel.ts # HTTP kernel configuration
|
|
98
|
+
├── bootstrap/
|
|
99
|
+
│ └── app.ts # Application bootstrap
|
|
100
|
+
├── config/ # Configuration files
|
|
101
|
+
│ ├── app.ts
|
|
102
|
+
│ ├── database.ts
|
|
103
|
+
│ └── logging.ts
|
|
104
|
+
├── database/
|
|
105
|
+
│ └── migrations/ # Database migrations
|
|
106
|
+
├── routes/
|
|
107
|
+
│ └── web.ts # Route definitions
|
|
108
|
+
├── server.ts # Application entry point
|
|
109
|
+
├── .env # Environment variables
|
|
110
|
+
└── package.json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 📚 Basic Usage
|
|
116
|
+
|
|
117
|
+
### Routing
|
|
118
|
+
|
|
119
|
+
Define routes with an elegant, expressive syntax:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { Route } from 'arikajs';
|
|
123
|
+
|
|
124
|
+
// Simple route
|
|
125
|
+
Route.get('/', () => {
|
|
126
|
+
return { message: 'Welcome to ArikaJS!' };
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Route with parameters
|
|
130
|
+
Route.get('/users/{id}', (request, id) => {
|
|
131
|
+
return { userId: id };
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Route groups with middleware
|
|
135
|
+
Route.group({ middleware: 'auth' }, () => {
|
|
136
|
+
Route.get('/dashboard', [DashboardController, 'index']);
|
|
137
|
+
Route.post('/posts', [PostController, 'store']);
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Implicit Model Binding
|
|
142
|
+
|
|
143
|
+
Automatically resolve models from route parameters:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { Route } from 'arikajs';
|
|
147
|
+
import User from './app/Models/User';
|
|
148
|
+
|
|
149
|
+
// Register model binding
|
|
150
|
+
Route.model('user', User);
|
|
151
|
+
|
|
152
|
+
// The {user} parameter will automatically resolve to a User instance
|
|
153
|
+
Route.get('/users/{user}', (request, user: User) => {
|
|
154
|
+
return {
|
|
155
|
+
message: 'User found!',
|
|
156
|
+
user: user
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Controllers
|
|
162
|
+
|
|
163
|
+
Create clean, organized controllers:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { Request, Response } from 'arikajs';
|
|
167
|
+
import User from '../Models/User';
|
|
168
|
+
|
|
169
|
+
export class UserController {
|
|
170
|
+
async index(request: Request, response: Response) {
|
|
171
|
+
const users = await User.all();
|
|
172
|
+
return response.json(users);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async show(request: Request, response: Response) {
|
|
176
|
+
const user = await User.findOrFail(request.params.id);
|
|
177
|
+
return response.json(user);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async store(request: Request, response: Response) {
|
|
181
|
+
const user = await User.create(request.body);
|
|
182
|
+
return response.status(201).json(user);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Models (Active Record)
|
|
188
|
+
|
|
189
|
+
Work with databases using an elegant ORM:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { Model } from 'arikajs';
|
|
193
|
+
|
|
194
|
+
export default class User extends Model {
|
|
195
|
+
protected static tableName = 'users';
|
|
196
|
+
|
|
197
|
+
// Define relationships
|
|
198
|
+
posts() {
|
|
199
|
+
return this.hasMany(Post);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Custom methods
|
|
203
|
+
async sendWelcomeEmail() {
|
|
204
|
+
// Send email logic
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Usage
|
|
209
|
+
const user = await User.find(1);
|
|
210
|
+
const posts = await user.posts().get();
|
|
211
|
+
|
|
212
|
+
const newUser = await User.create({
|
|
213
|
+
name: 'John Doe',
|
|
214
|
+
email: 'john@example.com'
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Middleware
|
|
219
|
+
|
|
220
|
+
Create custom middleware for request processing:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { MiddlewareHandler, Request, Response } from 'arikajs';
|
|
224
|
+
|
|
225
|
+
export default class AuthMiddleware implements MiddlewareHandler {
|
|
226
|
+
async handle(request: Request, response: Response, next: Function) {
|
|
227
|
+
if (!request.headers.authorization) {
|
|
228
|
+
return response.status(401).json({ error: 'Unauthorized' });
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return next();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Service Providers
|
|
237
|
+
|
|
238
|
+
Organize your application with service providers:
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import { ServiceProvider } from 'arikajs';
|
|
242
|
+
import { PaymentService } from './Services/PaymentService';
|
|
243
|
+
|
|
244
|
+
export class PaymentServiceProvider extends ServiceProvider {
|
|
245
|
+
async register() {
|
|
246
|
+
this.app.singleton('payment', () => {
|
|
247
|
+
return new PaymentService(this.app.config().get('payment'));
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async boot() {
|
|
252
|
+
// Bootstrap logic
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Database Migrations
|
|
258
|
+
|
|
259
|
+
Manage your database schema with migrations:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { Migration, SchemaBuilder } from 'arikajs';
|
|
263
|
+
|
|
264
|
+
export default class CreateUsersTable extends Migration {
|
|
265
|
+
async up(schema: SchemaBuilder) {
|
|
266
|
+
await schema.create('users', (table) => {
|
|
267
|
+
table.increments('id');
|
|
268
|
+
table.string('name');
|
|
269
|
+
table.string('email').unique();
|
|
270
|
+
table.string('password');
|
|
271
|
+
table.timestamps();
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async down(schema: SchemaBuilder) {
|
|
276
|
+
await schema.dropIfExists('users');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 🔧 Configuration
|
|
284
|
+
|
|
285
|
+
Configure your application in the `config/` directory:
|
|
286
|
+
|
|
287
|
+
**config/app.ts**
|
|
288
|
+
```typescript
|
|
289
|
+
export default {
|
|
290
|
+
name: process.env.APP_NAME || 'ArikaJS',
|
|
291
|
+
env: process.env.NODE_ENV || 'development',
|
|
292
|
+
key: process.env.APP_KEY,
|
|
293
|
+
timezone: 'UTC',
|
|
294
|
+
};
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**config/database.ts**
|
|
298
|
+
```typescript
|
|
299
|
+
export default {
|
|
300
|
+
default: 'mysql',
|
|
301
|
+
connections: {
|
|
302
|
+
mysql: {
|
|
303
|
+
driver: 'mysql',
|
|
304
|
+
host: process.env.DB_HOST || 'localhost',
|
|
305
|
+
port: parseInt(process.env.DB_PORT || '3306'),
|
|
306
|
+
database: process.env.DB_DATABASE,
|
|
307
|
+
username: process.env.DB_USERNAME,
|
|
308
|
+
password: process.env.DB_PASSWORD,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## 🎨 CLI Commands
|
|
317
|
+
|
|
318
|
+
ArikaJS comes with a powerful CLI for common tasks:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
# Create a new application
|
|
322
|
+
arika new my-app
|
|
323
|
+
|
|
324
|
+
# Start development server
|
|
325
|
+
arika serve --dev
|
|
326
|
+
|
|
327
|
+
# Generate application key
|
|
328
|
+
arika key:generate
|
|
329
|
+
|
|
330
|
+
# Database migrations
|
|
331
|
+
arika migrate
|
|
332
|
+
arika migrate:rollback
|
|
333
|
+
|
|
334
|
+
# Create migration
|
|
335
|
+
arika make:migration create_posts_table
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## 🧪 Testing
|
|
341
|
+
|
|
342
|
+
ArikaJS is built with testing in mind:
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { describe, it } from 'node:test';
|
|
346
|
+
import assert from 'node:assert';
|
|
347
|
+
import app from './bootstrap/app';
|
|
348
|
+
|
|
349
|
+
describe('User API', () => {
|
|
350
|
+
it('should return all users', async () => {
|
|
351
|
+
const response = await app.get('/api/users');
|
|
352
|
+
assert.strictEqual(response.status, 200);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 📖 Documentation
|
|
360
|
+
|
|
361
|
+
Comprehensive documentation is available in the [GitHub repository](https://github.com/arikajs/arikajs).
|
|
362
|
+
|
|
363
|
+
For guides and examples, check out:
|
|
364
|
+
- [Installation Guide](https://github.com/arikajs/arikajs#installation)
|
|
365
|
+
- [Routing](https://github.com/arikajs/arikajs#routing)
|
|
366
|
+
- [Controllers](https://github.com/arikajs/arikajs#controllers)
|
|
367
|
+
- [Database & ORM](https://github.com/arikajs/arikajs#models-active-record)
|
|
368
|
+
- [Examples](https://github.com/arikajs/examples)
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 🤝 Contributing
|
|
373
|
+
|
|
374
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
# Clone the repository
|
|
378
|
+
git clone https://github.com/arikajs/arikajs.git
|
|
379
|
+
|
|
380
|
+
# Install dependencies
|
|
381
|
+
npm install
|
|
382
|
+
|
|
383
|
+
# Run tests
|
|
384
|
+
npm test
|
|
385
|
+
|
|
386
|
+
# Build the project
|
|
387
|
+
npm run build
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## 📝 License
|
|
393
|
+
|
|
394
|
+
ArikaJS is open-sourced software licensed under the [MIT license](LICENSE).
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## 🙏 Acknowledgments
|
|
399
|
+
|
|
400
|
+
ArikaJS draws inspiration from the best practices and patterns of modern web frameworks, including elegant API design, developer experience focus, and enterprise-grade architecture.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## 💬 Community & Support
|
|
405
|
+
|
|
406
|
+
- 📖 [Documentation](https://github.com/arikajs/arikajs#readme)
|
|
407
|
+
- 💬 [Discord Community](https://discord.gg/arikajs)
|
|
408
|
+
- 🐦 [Twitter](https://twitter.com/arikajs)
|
|
409
|
+
- 🐛 [Issue Tracker](https://github.com/arikajs/arikajs/issues)
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
<div align="center">
|
|
414
|
+
|
|
415
|
+
**Built with ❤️ by the ArikaJS Team**
|
|
416
|
+
|
|
417
|
+
[GitHub](https://github.com/arikajs) • [npm](https://www.npmjs.com/package/arikajs)
|
|
418
|
+
|
|
419
|
+
</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 @@
|
|
|
1
|
+
{"version":3,"file":"Application.js","sourceRoot":"","sources":["../../src/Contracts/Application.ts"],"names":[],"mappings":""}
|
|
@@ -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"}
|