@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.
- package/README.md +99 -6
- package/dist/bin/arika.js +2 -2
- package/dist/bin/arika.js.map +1 -1
- package/dist/src/ApplicationLoader.d.ts +5 -0
- package/dist/src/ApplicationLoader.d.ts.map +1 -1
- package/dist/src/ApplicationLoader.js +24 -2
- package/dist/src/ApplicationLoader.js.map +1 -1
- package/dist/src/Bootstrap.d.ts.map +1 -1
- package/dist/src/Bootstrap.js +35 -0
- package/dist/src/Bootstrap.js.map +1 -1
- package/dist/src/Commands/AuthApiInstallCommand.d.ts +24 -0
- package/dist/src/Commands/AuthApiInstallCommand.d.ts.map +1 -0
- package/dist/src/Commands/AuthApiInstallCommand.js +751 -0
- package/dist/src/Commands/AuthApiInstallCommand.js.map +1 -0
- package/dist/src/Commands/AuthInstallCommand.d.ts +7 -0
- package/dist/src/Commands/AuthInstallCommand.d.ts.map +1 -0
- package/dist/src/Commands/AuthInstallCommand.js +46 -0
- package/dist/src/Commands/AuthInstallCommand.js.map +1 -0
- package/dist/src/Commands/AuthWebInstallCommand.d.ts +31 -0
- package/dist/src/Commands/AuthWebInstallCommand.d.ts.map +1 -0
- package/dist/src/Commands/AuthWebInstallCommand.js +1100 -0
- package/dist/src/Commands/AuthWebInstallCommand.js.map +1 -0
- package/dist/src/Commands/BenchmarkCommand.d.ts +7 -0
- package/dist/src/Commands/BenchmarkCommand.d.ts.map +1 -0
- package/dist/src/Commands/BenchmarkCommand.js +25 -0
- package/dist/src/Commands/BenchmarkCommand.js.map +1 -0
- package/dist/src/Commands/CacheClearCommand.d.ts +7 -0
- package/dist/src/Commands/CacheClearCommand.d.ts.map +1 -0
- package/dist/src/Commands/CacheClearCommand.js +33 -0
- package/dist/src/Commands/CacheClearCommand.js.map +1 -0
- package/dist/src/Commands/CacheTableCommand.d.ts.map +1 -1
- package/dist/src/Commands/CacheTableCommand.js +21 -9
- package/dist/src/Commands/CacheTableCommand.js.map +1 -1
- package/dist/src/Commands/ConfigCacheCommand.d.ts +7 -0
- package/dist/src/Commands/ConfigCacheCommand.d.ts.map +1 -0
- package/dist/src/Commands/ConfigCacheCommand.js +86 -0
- package/dist/src/Commands/ConfigCacheCommand.js.map +1 -0
- package/dist/src/Commands/ConfigClearCommand.d.ts +7 -0
- package/dist/src/Commands/ConfigClearCommand.d.ts.map +1 -0
- package/dist/src/Commands/ConfigClearCommand.js +29 -0
- package/dist/src/Commands/ConfigClearCommand.js.map +1 -0
- package/dist/src/Commands/DocsGenerateCommand.d.ts +0 -1
- package/dist/src/Commands/DocsGenerateCommand.d.ts.map +1 -1
- package/dist/src/Commands/DocsGenerateCommand.js +68 -77
- package/dist/src/Commands/DocsGenerateCommand.js.map +1 -1
- package/dist/src/Commands/EnvValidateCommand.d.ts +7 -0
- package/dist/src/Commands/EnvValidateCommand.d.ts.map +1 -0
- package/dist/src/Commands/EnvValidateCommand.js +51 -0
- package/dist/src/Commands/EnvValidateCommand.js.map +1 -0
- package/dist/src/Commands/ListCommand.d.ts.map +1 -1
- package/dist/src/Commands/ListCommand.js +15 -8
- package/dist/src/Commands/ListCommand.js.map +1 -1
- package/dist/src/Commands/MakeCommand.d.ts +7 -0
- package/dist/src/Commands/MakeCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeCommand.js +110 -0
- package/dist/src/Commands/MakeCommand.js.map +1 -0
- package/dist/src/Commands/MakeCommandCommand.d.ts +20 -0
- package/dist/src/Commands/MakeCommandCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeCommandCommand.js +82 -0
- package/dist/src/Commands/MakeCommandCommand.js.map +1 -0
- package/dist/src/Commands/MakeControllerCommand.d.ts +17 -0
- package/dist/src/Commands/MakeControllerCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeControllerCommand.js +90 -0
- package/dist/src/Commands/MakeControllerCommand.js.map +1 -0
- package/dist/src/Commands/MakeEventCommand.d.ts +8 -0
- package/dist/src/Commands/MakeEventCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeEventCommand.js +48 -0
- package/dist/src/Commands/MakeEventCommand.js.map +1 -0
- package/dist/src/Commands/MakeJobCommand.d.ts +8 -0
- package/dist/src/Commands/MakeJobCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeJobCommand.js +55 -0
- package/dist/src/Commands/MakeJobCommand.js.map +1 -0
- package/dist/src/Commands/MakeListenerCommand.d.ts +8 -0
- package/dist/src/Commands/MakeListenerCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeListenerCommand.js +55 -0
- package/dist/src/Commands/MakeListenerCommand.js.map +1 -0
- package/dist/src/Commands/MakeMiddlewareCommand.d.ts +17 -0
- package/dist/src/Commands/MakeMiddlewareCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeMiddlewareCommand.js +69 -0
- package/dist/src/Commands/MakeMiddlewareCommand.js.map +1 -0
- package/dist/src/Commands/MakeMigrationCommand.js +4 -4
- package/dist/src/Commands/MakeMigrationCommand.js.map +1 -1
- package/dist/src/Commands/MakeModelCommand.d.ts +26 -0
- package/dist/src/Commands/MakeModelCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeModelCommand.js +193 -0
- package/dist/src/Commands/MakeModelCommand.js.map +1 -0
- package/dist/src/Commands/MakeProviderCommand.d.ts +17 -0
- package/dist/src/Commands/MakeProviderCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeProviderCommand.js +72 -0
- package/dist/src/Commands/MakeProviderCommand.js.map +1 -0
- package/dist/src/Commands/MakeViewCommand.d.ts +7 -0
- package/dist/src/Commands/MakeViewCommand.d.ts.map +1 -0
- package/dist/src/Commands/MakeViewCommand.js +37 -0
- package/dist/src/Commands/MakeViewCommand.js.map +1 -0
- package/dist/src/Commands/MigrateFreshCommand.d.ts +10 -0
- package/dist/src/Commands/MigrateFreshCommand.d.ts.map +1 -0
- package/dist/src/Commands/MigrateFreshCommand.js +129 -0
- package/dist/src/Commands/MigrateFreshCommand.js.map +1 -0
- package/dist/src/Commands/NewCommand.d.ts.map +1 -1
- package/dist/src/Commands/NewCommand.js +92 -24
- package/dist/src/Commands/NewCommand.js.map +1 -1
- package/dist/src/Commands/QueueFailedCommand.d.ts +7 -0
- package/dist/src/Commands/QueueFailedCommand.d.ts.map +1 -0
- package/dist/src/Commands/QueueFailedCommand.js +30 -0
- package/dist/src/Commands/QueueFailedCommand.js.map +1 -0
- package/dist/src/Commands/QueueFailedTableCommand.d.ts +7 -0
- package/dist/src/Commands/QueueFailedTableCommand.d.ts.map +1 -0
- package/dist/src/Commands/QueueFailedTableCommand.js +55 -0
- package/dist/src/Commands/QueueFailedTableCommand.js.map +1 -0
- package/dist/src/Commands/QueueFlushCommand.d.ts +7 -0
- package/dist/src/Commands/QueueFlushCommand.d.ts.map +1 -0
- package/dist/src/Commands/QueueFlushCommand.js +21 -0
- package/dist/src/Commands/QueueFlushCommand.js.map +1 -0
- package/dist/src/Commands/QueueRetryCommand.d.ts +7 -0
- package/dist/src/Commands/QueueRetryCommand.d.ts.map +1 -0
- package/dist/src/Commands/QueueRetryCommand.js +36 -0
- package/dist/src/Commands/QueueRetryCommand.js.map +1 -0
- package/dist/src/Commands/QueueTableCommand.d.ts.map +1 -1
- package/dist/src/Commands/QueueTableCommand.js +19 -13
- package/dist/src/Commands/QueueTableCommand.js.map +1 -1
- package/dist/src/Commands/QueueWorkCommand.d.ts +8 -0
- package/dist/src/Commands/QueueWorkCommand.d.ts.map +1 -0
- package/dist/src/Commands/QueueWorkCommand.js +88 -0
- package/dist/src/Commands/QueueWorkCommand.js.map +1 -0
- package/dist/src/Commands/RouteListCommand.d.ts +7 -0
- package/dist/src/Commands/RouteListCommand.d.ts.map +1 -0
- package/dist/src/Commands/RouteListCommand.js +108 -0
- package/dist/src/Commands/RouteListCommand.js.map +1 -0
- package/dist/src/Commands/ScheduleRunCommand.d.ts +9 -0
- package/dist/src/Commands/ScheduleRunCommand.d.ts.map +1 -0
- package/dist/src/Commands/ScheduleRunCommand.js +80 -0
- package/dist/src/Commands/ScheduleRunCommand.js.map +1 -0
- package/dist/src/Commands/ScheduleWorkCommand.d.ts +9 -0
- package/dist/src/Commands/ScheduleWorkCommand.d.ts.map +1 -0
- package/dist/src/Commands/ScheduleWorkCommand.js +81 -0
- package/dist/src/Commands/ScheduleWorkCommand.js.map +1 -0
- package/dist/src/Commands/ServeCommand.d.ts +1 -0
- package/dist/src/Commands/ServeCommand.d.ts.map +1 -1
- package/dist/src/Commands/ServeCommand.js +111 -21
- package/dist/src/Commands/ServeCommand.js.map +1 -1
- package/dist/src/TemplateManager.d.ts +4 -0
- package/dist/src/TemplateManager.d.ts.map +1 -1
- package/dist/src/TemplateManager.js +35 -6
- package/dist/src/TemplateManager.js.map +1 -1
- package/dist/templates/app/.env.example +47 -0
- package/dist/templates/app/README.md +62 -0
- package/dist/templates/app/app/Exceptions/Handler.ts +19 -0
- package/dist/templates/app/app/Http/Controllers/UserController.ts +90 -0
- package/dist/templates/app/app/Http/Kernel.ts +43 -0
- package/dist/templates/app/app/Http/Middleware/Authenticate.ts +10 -0
- package/dist/templates/app/app/Http/Middleware/EnsureEmailIsVerified.ts +18 -0
- package/dist/templates/app/app/Http/Middleware/ExampleMiddleware.ts +12 -0
- package/dist/templates/app/app/Http/Middleware/RedirectIfAuthenticated.ts +18 -0
- package/dist/templates/app/app/Http/Middleware/TrimStrings.ts +12 -0
- package/dist/templates/app/app/Http/Middleware/TrustProxies.ts +23 -0
- package/dist/templates/app/app/Http/Middleware/VerifyCsrfToken.ts +10 -0
- package/dist/templates/app/app/Models/User.ts +15 -0
- package/dist/templates/app/app/Providers/AppServiceProvider.ts +17 -0
- package/dist/templates/app/app/Providers/RouteServiceProvider.ts +35 -0
- package/dist/templates/app/bootstrap/app.ts +41 -0
- package/dist/templates/app/config/app.ts +10 -0
- package/dist/templates/app/config/cache.ts +44 -0
- package/dist/templates/app/config/database.ts +63 -0
- package/dist/templates/app/config/filesystems.ts +35 -0
- package/dist/templates/app/config/http.ts +6 -0
- package/dist/templates/app/config/logging.ts +37 -0
- package/dist/templates/app/config/mail.ts +29 -0
- package/dist/templates/app/config/queue.ts +42 -0
- 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
- package/dist/templates/app/database/migrations/2024_01_01_000002_create_password_resets_table.ts +22 -0
- package/dist/templates/app/database/migrations/2024_01_01_000003_create_failed_jobs_table.ts +25 -0
- package/dist/templates/app/package.json +22 -0
- package/dist/templates/app/public/assets/img/favicon.png +0 -0
- package/dist/templates/app/public/assets/img/logo.png +0 -0
- package/dist/templates/app/resources/views/errors/401.ark.html +320 -0
- package/dist/templates/app/resources/views/errors/403.ark.html +320 -0
- package/dist/templates/app/resources/views/errors/404.ark.html +320 -0
- package/dist/templates/app/resources/views/errors/419.ark.html +320 -0
- package/dist/templates/app/resources/views/errors/429.ark.html +320 -0
- package/dist/templates/app/resources/views/errors/500.ark.html +320 -0
- package/dist/templates/app/resources/views/errors/503.ark.html +320 -0
- package/dist/templates/app/resources/views/welcome.ark.html +846 -0
- package/dist/templates/app/routes/api.ts +39 -0
- package/dist/templates/app/routes/web.ts +10 -0
- package/dist/templates/app/server.ts +15 -0
- package/dist/templates/app/tsconfig.json +27 -0
- package/package.json +16 -10
- package/templates/app/.env.example +2 -2
- package/templates/app/README.md +62 -0
- package/templates/app/app/Exceptions/Handler.ts +19 -0
- package/templates/app/app/Http/Controllers/UserController.ts +90 -0
- package/templates/app/app/Http/Kernel.ts +39 -14
- package/templates/app/app/Http/Middleware/Authenticate.ts +10 -0
- package/templates/app/app/Http/Middleware/EnsureEmailIsVerified.ts +18 -0
- package/templates/app/app/Http/Middleware/ExampleMiddleware.ts +12 -0
- package/templates/app/app/Http/Middleware/RedirectIfAuthenticated.ts +18 -0
- package/templates/app/app/Http/Middleware/TrimStrings.ts +12 -0
- package/templates/app/app/Http/Middleware/TrustProxies.ts +23 -0
- package/templates/app/app/Http/Middleware/VerifyCsrfToken.ts +10 -0
- package/templates/app/app/Models/User.ts +5 -5
- package/templates/app/app/Providers/AppServiceProvider.ts +17 -0
- package/templates/app/app/Providers/RouteServiceProvider.ts +35 -0
- package/templates/app/bootstrap/app.ts +30 -2
- package/templates/app/config/app.ts +7 -6
- package/templates/app/config/cache.ts +14 -7
- package/templates/app/config/database.ts +48 -21
- package/templates/app/config/filesystems.ts +11 -9
- package/templates/app/config/http.ts +3 -2
- package/templates/app/config/logging.ts +6 -4
- package/templates/app/config/mail.ts +10 -8
- package/templates/app/config/queue.ts +6 -4
- package/templates/app/database/migrations/2024_01_01_000001_create_users_table.ts +25 -0
- package/templates/app/database/migrations/2024_01_01_000002_create_password_resets_table.ts +22 -0
- package/templates/app/database/migrations/2024_01_01_000003_create_failed_jobs_table.ts +25 -0
- package/templates/app/package.json +4 -3
- package/templates/app/public/assets/img/favicon.png +0 -0
- package/templates/app/public/assets/img/logo.png +0 -0
- package/templates/app/resources/views/welcome.ark.html +846 -0
- package/templates/app/routes/api.ts +8 -3
- package/templates/app/routes/web.ts +8 -4
- package/templates/app/server.ts +3 -4
- package/templates/app/tsconfig.json +12 -0
- package/dist/tests/Cli.test.d.ts +0 -2
- package/dist/tests/Cli.test.d.ts.map +0 -1
- package/dist/tests/Cli.test.js +0 -16
- package/dist/tests/Cli.test.js.map +0 -1
- package/templates/app/app/Controllers/UserController.ts +0 -88
- package/templates/app/resources/views/welcome.html +0 -470
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
APP_NAME=ArikaJs
|
|
2
|
+
APP_ENV=development
|
|
3
|
+
APP_PORT=3000
|
|
4
|
+
APP_DEBUG=true
|
|
5
|
+
APP_KEY=
|
|
6
|
+
APP_URL=http://localhost:3000
|
|
7
|
+
APP_TIMEZONE=UTC
|
|
8
|
+
|
|
9
|
+
DB_CONNECTION=mysql
|
|
10
|
+
DB_HOST=127.0.0.1
|
|
11
|
+
DB_PORT=3306
|
|
12
|
+
DB_DATABASE=arikajs
|
|
13
|
+
DB_USERNAME=root
|
|
14
|
+
DB_PASSWORD=
|
|
15
|
+
|
|
16
|
+
REDIS_CLIENT=ioredis
|
|
17
|
+
REDIS_HOST=127.0.0.1
|
|
18
|
+
REDIS_PASSWORD=null
|
|
19
|
+
REDIS_PORT=6379
|
|
20
|
+
REDIS_DB=0
|
|
21
|
+
|
|
22
|
+
MAIL_MAILER=log
|
|
23
|
+
MAIL_HOST=127.0.0.1
|
|
24
|
+
MAIL_PORT=2525
|
|
25
|
+
MAIL_USERNAME=
|
|
26
|
+
MAIL_PASSWORD=
|
|
27
|
+
MAIL_ENCRYPTION=tls
|
|
28
|
+
MAIL_FROM_ADDRESS="hello@example.com"
|
|
29
|
+
MAIL_FROM_NAME="${APP_NAME}"
|
|
30
|
+
|
|
31
|
+
FILESYSTEM_DISK=local
|
|
32
|
+
|
|
33
|
+
AWS_ACCESS_KEY_ID=
|
|
34
|
+
AWS_SECRET_ACCESS_KEY=
|
|
35
|
+
AWS_DEFAULT_REGION=us-east-1
|
|
36
|
+
AWS_BUCKET=
|
|
37
|
+
AWS_URL=
|
|
38
|
+
AWS_ENDPOINT=
|
|
39
|
+
AWS_USE_PATH_STYLE_ENDPOINT=false
|
|
40
|
+
|
|
41
|
+
LOG_CHANNEL=stack
|
|
42
|
+
LOG_LEVEL=debug
|
|
43
|
+
|
|
44
|
+
QUEUE_CONNECTION=sync
|
|
45
|
+
|
|
46
|
+
CACHE_STORE=file
|
|
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
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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';
|
|
8
|
+
|
|
9
|
+
export class Kernel extends BaseKernel {
|
|
10
|
+
constructor(app: any) {
|
|
11
|
+
super(app);
|
|
12
|
+
|
|
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
|
+
}
|
|
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,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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createApp } from 'arikajs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
const app = createApp(
|
|
5
|
+
path.resolve(__dirname, '../')
|
|
6
|
+
);
|
|
7
|
+
|
|
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';
|
|
37
|
+
|
|
38
|
+
app.singleton(BaseKernel, () => new Kernel(app));
|
|
39
|
+
app.singleton(BaseHandler, () => new Handler());
|
|
40
|
+
|
|
41
|
+
export default app;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { env } from 'arikajs';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
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'),
|
|
10
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { env } from 'arikajs';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
/**
|
|
5
|
+
* Default Cache Store
|
|
6
|
+
*/
|
|
7
|
+
default: env('CACHE_STORE', 'file'),
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Cache Stores
|
|
11
|
+
*/
|
|
12
|
+
stores: {
|
|
13
|
+
file: {
|
|
14
|
+
driver: 'file',
|
|
15
|
+
path: 'storage/cache/data',
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
memory: {
|
|
19
|
+
driver: 'memory',
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
database: {
|
|
23
|
+
driver: 'database',
|
|
24
|
+
table: 'cache',
|
|
25
|
+
connection: null,
|
|
26
|
+
lock_connection: null,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
redis: {
|
|
30
|
+
driver: 'redis',
|
|
31
|
+
connection: 'default',
|
|
32
|
+
mode: env('REDIS_MODE', 'standalone'), // standalone, sentinel, cluster
|
|
33
|
+
host: env('REDIS_HOST', '127.0.0.1'),
|
|
34
|
+
password: env('REDIS_PASSWORD', null),
|
|
35
|
+
port: env('REDIS_PORT', 6379),
|
|
36
|
+
database: env('REDIS_DB', 0),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Cache Key Prefix
|
|
42
|
+
*/
|
|
43
|
+
prefix: env('CACHE_PREFIX', 'arika_cache'),
|
|
44
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { env } from 'arikajs';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
/**
|
|
5
|
+
* Default Database Connection Name
|
|
6
|
+
*/
|
|
7
|
+
default: env('DB_CONNECTION', 'mysql'),
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Database Connections
|
|
11
|
+
*/
|
|
12
|
+
connections: {
|
|
13
|
+
sqlite: {
|
|
14
|
+
driver: 'sqlite',
|
|
15
|
+
database: env('DB_DATABASE', './database.sqlite'),
|
|
16
|
+
charset: 'utf8',
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
mysql: {
|
|
20
|
+
driver: 'mysql',
|
|
21
|
+
host: env('DB_HOST', '127.0.0.1'),
|
|
22
|
+
port: env('DB_PORT', 3306),
|
|
23
|
+
database: env('DB_DATABASE', 'arikajs'),
|
|
24
|
+
username: env('DB_USERNAME', 'root'),
|
|
25
|
+
password: env('DB_PASSWORD', ''),
|
|
26
|
+
charset: 'utf8mb4',
|
|
27
|
+
timezone: 'local',
|
|
28
|
+
pool: {
|
|
29
|
+
min: 2,
|
|
30
|
+
max: 20
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
pgsql: {
|
|
35
|
+
driver: 'pgsql',
|
|
36
|
+
host: env('DB_HOST', '127.0.0.1'),
|
|
37
|
+
port: env('DB_PORT', 5432),
|
|
38
|
+
database: env('DB_DATABASE', 'arikajs'),
|
|
39
|
+
username: env('DB_USERNAME', 'postgres'),
|
|
40
|
+
password: env('DB_PASSWORD', ''),
|
|
41
|
+
charset: 'utf8',
|
|
42
|
+
timezone: 'local',
|
|
43
|
+
pool: {
|
|
44
|
+
min: 2,
|
|
45
|
+
max: 20
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
mongodb: {
|
|
50
|
+
driver: 'mongodb',
|
|
51
|
+
host: env('DB_HOST', '127.0.0.1'),
|
|
52
|
+
port: env('DB_PORT', 27017),
|
|
53
|
+
database: env('DB_DATABASE', 'arikajs'),
|
|
54
|
+
username: env('DB_USERNAME', ''),
|
|
55
|
+
password: env('DB_PASSWORD', ''),
|
|
56
|
+
options: {
|
|
57
|
+
useUnifiedTopology: true,
|
|
58
|
+
maxPoolSize: 10,
|
|
59
|
+
minPoolSize: 2
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { env } from 'arikajs';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
/**
|
|
5
|
+
* Default Filesystem Disk
|
|
6
|
+
*/
|
|
7
|
+
default: env('FILESYSTEM_DISK', 'local'),
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Filesystem Disks
|
|
11
|
+
*/
|
|
12
|
+
disks: {
|
|
13
|
+
local: {
|
|
14
|
+
driver: 'local',
|
|
15
|
+
root: './storage/app',
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
public: {
|
|
19
|
+
driver: 'local',
|
|
20
|
+
root: './storage/public',
|
|
21
|
+
url: env('APP_URL', 'http://localhost:3000') + '/storage',
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
s3: {
|
|
25
|
+
driver: 's3',
|
|
26
|
+
key: env('AWS_ACCESS_KEY_ID'),
|
|
27
|
+
secret: env('AWS_SECRET_ACCESS_KEY'),
|
|
28
|
+
region: env('AWS_DEFAULT_REGION', 'us-east-1'),
|
|
29
|
+
bucket: env('AWS_BUCKET'),
|
|
30
|
+
url: env('AWS_URL'),
|
|
31
|
+
endpoint: env('AWS_ENDPOINT'),
|
|
32
|
+
forcePathStyle: env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|