@avleon/core 0.0.38 → 0.0.40
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 +76 -23
- package/dist/environment-variables.js +1 -1
- package/dist/event-dispatcher.js +0 -1
- package/dist/icore.d.ts +0 -9
- package/dist/icore.js +19 -4
- package/dist/middleware.d.ts +3 -0
- package/dist/middleware.js +7 -0
- package/dist/route-methods.d.ts +9 -40
- package/dist/route-methods.js +37 -71
- package/package.json +94 -62
package/README.md
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Avleon
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
 
|
|
4
|
+
## ⚠️ WARNING
|
|
4
5
|
|
|
5
6
|
> **🚧 This project is in active development.**
|
|
6
|
-
>
|
|
7
|
-
> It is **not stable** and **not ready** for live environments.
|
|
8
|
-
> Use **only for testing, experimentation, or internal evaluation**.
|
|
9
|
-
>
|
|
10
|
-
> ####❗ Risks of using this in production:
|
|
11
|
-
>
|
|
12
|
-
> - 🔄 Breaking changes may be introduced at any time
|
|
13
|
-
> - 🧪 Features are experimental and may be unstable
|
|
14
|
-
> - 🔐 Security has not been audited
|
|
15
|
-
> - 💥 Potential for data loss or critical errors
|
|
16
|
-
>
|
|
17
|
-
> **Please do not deploy this in production environments.**
|
|
18
7
|
|
|
19
8
|
## Overview
|
|
20
9
|
|
|
@@ -69,11 +58,11 @@ Avleon is a powerful, TypeScript-based web framework built on top of Fastify, de
|
|
|
69
58
|
## Installation
|
|
70
59
|
|
|
71
60
|
```bash
|
|
72
|
-
|
|
61
|
+
npx @avleon/cli new myapp
|
|
73
62
|
# or
|
|
74
|
-
yarn
|
|
63
|
+
yarn dlx @avleon/cli new myapp
|
|
75
64
|
# or
|
|
76
|
-
pnpm
|
|
65
|
+
pnpm dlx @avleon/cli new myapp
|
|
77
66
|
```
|
|
78
67
|
|
|
79
68
|
## Quick Start
|
|
@@ -81,7 +70,7 @@ pnpm add @avleon/core
|
|
|
81
70
|
### Minimal
|
|
82
71
|
|
|
83
72
|
```typescript
|
|
84
|
-
import { Avleon
|
|
73
|
+
import { Avleon } from "@avleon/core";
|
|
85
74
|
|
|
86
75
|
const app = Avleon.createApplication();
|
|
87
76
|
app.mapGet("/", () => "Hello, Avleon");
|
|
@@ -123,7 +112,9 @@ const app = Avleon.createApplication();
|
|
|
123
112
|
// Configure and run the application
|
|
124
113
|
app.useCors();
|
|
125
114
|
app.useControllers([UserController]);
|
|
126
|
-
app.
|
|
115
|
+
// For auto register controller `app.useControllers({auto:true});`
|
|
116
|
+
|
|
117
|
+
app.run(); // or app.run(port)
|
|
127
118
|
```
|
|
128
119
|
|
|
129
120
|
### Controllers
|
|
@@ -253,7 +244,9 @@ class UserController {
|
|
|
253
244
|
Secure your API with authentication and authorization:
|
|
254
245
|
|
|
255
246
|
```typescript
|
|
256
|
-
@
|
|
247
|
+
import { CanAuthorize } from "@avleon/core";
|
|
248
|
+
|
|
249
|
+
@CanAuthorize
|
|
257
250
|
class JwtAuthorization extends AuthorizeMiddleware {
|
|
258
251
|
authorize(roles: string[]) {
|
|
259
252
|
return async (req: IRequest) => {
|
|
@@ -382,6 +375,66 @@ app.useOpenApi(OpenApiConfig, (config) => {
|
|
|
382
375
|
|
|
383
376
|
### Database Integration
|
|
384
377
|
|
|
378
|
+
## 1. Knex
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
const app = Avleon.createApplication();
|
|
382
|
+
app.useKnex({
|
|
383
|
+
client: 'mysql',
|
|
384
|
+
connection: {
|
|
385
|
+
host: '127.0.0.1',
|
|
386
|
+
port: 3306,
|
|
387
|
+
user: 'your_database_user',
|
|
388
|
+
password: 'your_database_password',
|
|
389
|
+
database: 'myapp_test',
|
|
390
|
+
},
|
|
391
|
+
})
|
|
392
|
+
```
|
|
393
|
+
or using config class
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
@AppConfig
|
|
397
|
+
export class KnexConfig implements IConfig {
|
|
398
|
+
// config method is mendatory
|
|
399
|
+
// config method has access to environment variables by default
|
|
400
|
+
config(env: Environment) {
|
|
401
|
+
return {
|
|
402
|
+
client: 'mysql',
|
|
403
|
+
connection: {
|
|
404
|
+
host: env.get("DB_HOST") || '127.0.0.1',
|
|
405
|
+
port: env.get("DB_PORT") || 3306,
|
|
406
|
+
user: env.get("DB_USER")|| 'your_database_user',
|
|
407
|
+
password: env.get("DB_PASS") || 'your_database_password',
|
|
408
|
+
database: env.get("DB_NAME") || 'myapp_test',
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// now we can register it with our app
|
|
415
|
+
|
|
416
|
+
app.useKenx(KnexConfig)
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Exmaple uses
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
import { DB, AppService } from "@avleon/core";
|
|
423
|
+
|
|
424
|
+
@AppService
|
|
425
|
+
export class UsersService{
|
|
426
|
+
constructor(
|
|
427
|
+
private readonly db: DB
|
|
428
|
+
){}
|
|
429
|
+
|
|
430
|
+
async findAll(){
|
|
431
|
+
const result = await this.db.client.select("*").from("users");
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## 2. Typeorm
|
|
385
438
|
Connect to databases using TypeORM:
|
|
386
439
|
|
|
387
440
|
```typescript
|
|
@@ -402,9 +455,9 @@ Or use the config class:
|
|
|
402
455
|
|
|
403
456
|
```typescript
|
|
404
457
|
// datasource.config.ts
|
|
405
|
-
import {
|
|
458
|
+
import { AppConfig, IConfig } from "@avleon/core";
|
|
406
459
|
|
|
407
|
-
@
|
|
460
|
+
@AppConfig
|
|
408
461
|
export class DataSourceConfig implements IConfig {
|
|
409
462
|
// config method is mendatory
|
|
410
463
|
// config method has access to environment variables by default
|
|
@@ -552,7 +605,7 @@ app
|
|
|
552
605
|
// Handler function
|
|
553
606
|
})
|
|
554
607
|
.useMiddleware([AuthMiddleware])
|
|
555
|
-
.
|
|
608
|
+
.useOpenApi({
|
|
556
609
|
summary: "Get all users",
|
|
557
610
|
description: "Retrieves a list of all users",
|
|
558
611
|
tags: ["users"],
|
|
@@ -54,7 +54,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
54
54
|
const fs_1 = __importStar(require("fs"));
|
|
55
55
|
const typedi_1 = require("typedi");
|
|
56
56
|
const system_exception_1 = require("./exceptions/system-exception");
|
|
57
|
-
dotenv_1.default.config({ path: path_1.default.join(process.cwd(), ".env") });
|
|
57
|
+
dotenv_1.default.config({ path: path_1.default.join(process.cwd(), ".env"), quiet: true });
|
|
58
58
|
/**
|
|
59
59
|
* @class Environment
|
|
60
60
|
* @description A service class to manage access to environment variables.
|
package/dist/event-dispatcher.js
CHANGED
|
@@ -60,7 +60,6 @@ let EventDispatcher = class EventDispatcher {
|
|
|
60
60
|
for (const transport of transports) {
|
|
61
61
|
if (transport === "socket") {
|
|
62
62
|
const io = typedi_1.Container.get(socket_io_1.Server);
|
|
63
|
-
//console.log('SOckert', Container.get(SocketContextService));
|
|
64
63
|
const context = typedi_1.Container.get(SocketContextService);
|
|
65
64
|
const socket = context.getSocket();
|
|
66
65
|
if (options.broadcast && socket) {
|
package/dist/icore.d.ts
CHANGED
|
@@ -208,15 +208,6 @@ export declare class AvleonApplication {
|
|
|
208
208
|
getTestApp(buildOptions?: any): TestApplication;
|
|
209
209
|
}
|
|
210
210
|
export type Application = typeof AvleonApplication;
|
|
211
|
-
export interface ITestBuilder {
|
|
212
|
-
getTestApplication(): AvleonTestAppliction;
|
|
213
|
-
createTestApplication(options: any): AvleonTestAppliction;
|
|
214
|
-
}
|
|
215
|
-
export interface IAppBuilder {
|
|
216
|
-
registerPlugin<T extends Function, S extends {}>(plugin: T, options: S): Promise<void>;
|
|
217
|
-
addDataSource<T extends IConfig<R>, R = ReturnType<InstanceType<Constructable<T>>["config"]>>(ConfigClass: Constructable<T>, modifyConfig?: (config: R) => R): void;
|
|
218
|
-
build<T extends IAvleonApplication>(): T;
|
|
219
|
-
}
|
|
220
211
|
export declare class AvleonTest {
|
|
221
212
|
private constructor();
|
|
222
213
|
static getController<T>(controller: Constructor<T>, deps?: any[]): T;
|
package/dist/icore.js
CHANGED
|
@@ -528,7 +528,6 @@ class AvleonApplication {
|
|
|
528
528
|
const module = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s)));
|
|
529
529
|
for (const exported of Object.values(module)) {
|
|
530
530
|
if (typeof exported === "function" && (0, container_1.isApiController)(exported)) {
|
|
531
|
-
console.log("adding", exported.name);
|
|
532
531
|
if (!this.controllers.some((con) => exported.name == con.name)) {
|
|
533
532
|
this.controllers.push(exported);
|
|
534
533
|
}
|
|
@@ -651,7 +650,6 @@ class AvleonApplication {
|
|
|
651
650
|
}
|
|
652
651
|
_mapFeatures() {
|
|
653
652
|
const features = typedi_1.default.get("features");
|
|
654
|
-
console.log("Features", features);
|
|
655
653
|
}
|
|
656
654
|
async initializeDatabase() {
|
|
657
655
|
if (this.dataSourceOptions && this.dataSource) {
|
|
@@ -707,7 +705,6 @@ class AvleonApplication {
|
|
|
707
705
|
await this.app.io.use((socket, next) => {
|
|
708
706
|
const token = socket.handshake.auth.token;
|
|
709
707
|
try {
|
|
710
|
-
console.log("token", token);
|
|
711
708
|
const user = { id: 1, name: "tareq" };
|
|
712
709
|
socket.data.user = user; // this powers @AuthUser()
|
|
713
710
|
next();
|
|
@@ -766,13 +763,31 @@ class AvleonApplication {
|
|
|
766
763
|
};
|
|
767
764
|
}
|
|
768
765
|
catch (error) {
|
|
769
|
-
console.log(error);
|
|
770
766
|
throw new system_exception_1.SystemUseError("Can't get test appliction");
|
|
771
767
|
}
|
|
772
768
|
}
|
|
773
769
|
}
|
|
774
770
|
exports.AvleonApplication = AvleonApplication;
|
|
775
771
|
AvleonApplication.buildOptions = {};
|
|
772
|
+
// Applciation Builder
|
|
773
|
+
// export interface ITestBuilder {
|
|
774
|
+
// getTestApplication(): AvleonTestAppliction;
|
|
775
|
+
// createTestApplication(options: any): AvleonTestAppliction;
|
|
776
|
+
// }
|
|
777
|
+
// export interface IAppBuilder {
|
|
778
|
+
// registerPlugin<T extends Function, S extends {}>(
|
|
779
|
+
// plugin: T,
|
|
780
|
+
// options: S,
|
|
781
|
+
// ): Promise<void>;
|
|
782
|
+
// addDataSource<
|
|
783
|
+
// T extends IConfig<R>,
|
|
784
|
+
// R = ReturnType<InstanceType<Constructable<T>>["config"]>,
|
|
785
|
+
// >(
|
|
786
|
+
// ConfigClass: Constructable<T>,
|
|
787
|
+
// modifyConfig?: (config: R) => R,
|
|
788
|
+
// ): void;
|
|
789
|
+
// build<T extends IAvleonApplication>(): T;
|
|
790
|
+
// }
|
|
776
791
|
class AvleonTest {
|
|
777
792
|
constructor() {
|
|
778
793
|
process.env.NODE_ENV = "test";
|
package/dist/middleware.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export type AuthReturnTypes = IRequest | Promise<IRequest>;
|
|
|
14
14
|
interface AuthorizeClass {
|
|
15
15
|
authorize(req: IRequest, options?: any): AuthReturnTypes;
|
|
16
16
|
}
|
|
17
|
+
export declare function CanAuthorize(target: {
|
|
18
|
+
new (...args: any[]): AuthorizeClass;
|
|
19
|
+
}): void;
|
|
17
20
|
export declare function AppAuthorization(target: {
|
|
18
21
|
new (...args: any[]): AuthorizeClass;
|
|
19
22
|
}): void;
|
package/dist/middleware.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthorizeMiddleware = exports.AvleonMiddleware = void 0;
|
|
4
|
+
exports.CanAuthorize = CanAuthorize;
|
|
4
5
|
exports.AppAuthorization = AppAuthorization;
|
|
5
6
|
exports.Authorized = Authorized;
|
|
6
7
|
exports.AppMiddleware = AppMiddleware;
|
|
@@ -19,6 +20,12 @@ exports.AvleonMiddleware = AvleonMiddleware;
|
|
|
19
20
|
class AuthorizeMiddleware {
|
|
20
21
|
}
|
|
21
22
|
exports.AuthorizeMiddleware = AuthorizeMiddleware;
|
|
23
|
+
function CanAuthorize(target) {
|
|
24
|
+
if (typeof target.prototype.authorize !== "function") {
|
|
25
|
+
throw new Error(`Class "${target.name}" must implement an "authorize" method.`);
|
|
26
|
+
}
|
|
27
|
+
(0, typedi_1.Service)()(target);
|
|
28
|
+
}
|
|
22
29
|
function AppAuthorization(target) {
|
|
23
30
|
if (typeof target.prototype.authorize !== "function") {
|
|
24
31
|
throw new Error(`Class "${target.name}" must implement an "authorize" method.`);
|
package/dist/route-methods.d.ts
CHANGED
|
@@ -6,51 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { OpenApiOptions } from "./openapi";
|
|
8
8
|
export type RouteMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "ALL";
|
|
9
|
-
/**
|
|
10
|
-
* Options for defining a route's method and metadata.
|
|
11
|
-
*/
|
|
12
9
|
export type RouteMethodOptions = {
|
|
13
|
-
/**
|
|
14
|
-
* HTTP method for the route (e.g., GET, POST, PUT, DELETE).
|
|
15
|
-
*/
|
|
16
10
|
method?: RouteMethods;
|
|
17
|
-
/**
|
|
18
|
-
* The path or endpoint for the route (e.g., "/users/:id").
|
|
19
|
-
*/
|
|
20
11
|
path?: string;
|
|
21
|
-
/**
|
|
22
|
-
* OpenAPI metadata for the route, including summary and description.
|
|
23
|
-
*/
|
|
24
12
|
openapi?: OpenApiOptions;
|
|
25
|
-
/**
|
|
26
|
-
* Name of the route.
|
|
27
|
-
*
|
|
28
|
-
* @description If Swagger is enabled in the project, this will appear as a tag in the generated documentation.
|
|
29
|
-
*/
|
|
30
13
|
name?: string;
|
|
31
14
|
};
|
|
32
|
-
export declare function createRouteDecorator(method?: RouteMethods): (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
33
|
-
/**
|
|
34
|
-
* @description HTTP Get method
|
|
35
|
-
* @param {string} path
|
|
36
|
-
*/
|
|
37
|
-
export declare function Get(path?: string): MethodDecorator;
|
|
38
|
-
export declare function Get(path: string | RouteMethodOptions): MethodDecorator;
|
|
39
15
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {string} path
|
|
42
|
-
* @param {RouteMethodOptions} options
|
|
16
|
+
* Generic Route decorator factory
|
|
43
17
|
*/
|
|
44
|
-
export declare function
|
|
45
|
-
export declare
|
|
46
|
-
export declare
|
|
47
|
-
export declare
|
|
48
|
-
export declare
|
|
49
|
-
export declare
|
|
50
|
-
export declare
|
|
51
|
-
export declare
|
|
52
|
-
export declare function Delete(path: string | RouteMethodOptions): MethodDecorator;
|
|
53
|
-
export declare function Delete(path: string, options: RouteMethodOptions): MethodDecorator;
|
|
54
|
-
export declare const Patch: (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
55
|
-
export declare const Options: (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
56
|
-
export declare const All: (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
18
|
+
export declare function Route(method: RouteMethods, pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions): MethodDecorator;
|
|
19
|
+
export declare const Get: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
20
|
+
export declare const Post: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
21
|
+
export declare const Put: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
22
|
+
export declare const Delete: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
23
|
+
export declare const Patch: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
24
|
+
export declare const Options: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
|
25
|
+
export declare const All: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
|
package/dist/route-methods.js
CHANGED
|
@@ -6,78 +6,44 @@
|
|
|
6
6
|
* @url https://github.com/xtareq
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.All = exports.Options = exports.Patch = void 0;
|
|
10
|
-
exports.
|
|
9
|
+
exports.All = exports.Options = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
10
|
+
exports.Route = Route;
|
|
11
|
+
const container_1 = require("./container");
|
|
12
|
+
/**
|
|
13
|
+
* Generic Route decorator factory
|
|
14
|
+
*/
|
|
15
|
+
function Route(method, pathOrOptions, maybeOptions) {
|
|
16
|
+
return function (target, propertyKey, descriptor) {
|
|
17
|
+
let path = "/";
|
|
18
|
+
let options = {};
|
|
19
|
+
if (typeof pathOrOptions === "string") {
|
|
20
|
+
path = pathOrOptions;
|
|
21
|
+
options = maybeOptions || {};
|
|
22
|
+
}
|
|
23
|
+
else if (typeof pathOrOptions === "object") {
|
|
24
|
+
options = pathOrOptions;
|
|
25
|
+
path = options.name || "/";
|
|
26
|
+
}
|
|
27
|
+
// Define metadata
|
|
28
|
+
Reflect.defineMetadata("route:path", path, target, propertyKey);
|
|
29
|
+
Reflect.defineMetadata("route:method", method, target, propertyKey);
|
|
30
|
+
Reflect.defineMetadata(container_1.ROUTE_META_KEY, { ...options, method, path, controller: target.constructor.name }, target, propertyKey);
|
|
31
|
+
if (options) {
|
|
32
|
+
Reflect.defineMetadata("route:options", options, target, propertyKey);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const Get = (pathOrOptions, maybeOptions) => Route("GET", pathOrOptions, maybeOptions);
|
|
11
37
|
exports.Get = Get;
|
|
38
|
+
const Post = (pathOrOptions, maybeOptions) => Route("POST", pathOrOptions, maybeOptions);
|
|
12
39
|
exports.Post = Post;
|
|
40
|
+
const Put = (pathOrOptions, maybeOptions) => Route("PUT", pathOrOptions, maybeOptions);
|
|
13
41
|
exports.Put = Put;
|
|
42
|
+
const Delete = (pathOrOptions, maybeOptions) => Route("DELETE", pathOrOptions, maybeOptions);
|
|
14
43
|
exports.Delete = Delete;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function createRouteDecorator(method = "GET") {
|
|
22
|
-
return function (pathOrOptions, maybeOptions) {
|
|
23
|
-
return function (target, propertyKey, descriptor) {
|
|
24
|
-
let path = "/";
|
|
25
|
-
let options = {};
|
|
26
|
-
if (typeof pathOrOptions === "string") {
|
|
27
|
-
path = pathOrOptions;
|
|
28
|
-
options = maybeOptions || {};
|
|
29
|
-
}
|
|
30
|
-
else if (typeof pathOrOptions === "object") {
|
|
31
|
-
options = pathOrOptions;
|
|
32
|
-
path = options.name || "/";
|
|
33
|
-
}
|
|
34
|
-
// Define metadata
|
|
35
|
-
Reflect.defineMetadata("route:path", path, target, propertyKey);
|
|
36
|
-
Reflect.defineMetadata("route:method", method || "GET", target, propertyKey);
|
|
37
|
-
Reflect.getMetadata(container_1.CONTROLLER_META_KEY, target.constructor);
|
|
38
|
-
Reflect.defineMetadata(container_1.ROUTE_META_KEY, { ...options, method, path, controller: target.constructor.name }, target, propertyKey);
|
|
39
|
-
if (options) {
|
|
40
|
-
Reflect.defineMetadata("route:options", options, target, propertyKey);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function Get(path, options) {
|
|
46
|
-
const parsedPath = !path && !options ? "/" : path;
|
|
47
|
-
if (options) {
|
|
48
|
-
return createRouteDecorator("GET")(parsedPath, options);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return createRouteDecorator("GET")(parsedPath);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function Post(path, options) {
|
|
55
|
-
const parsedPath = !path && !options ? "/" : path;
|
|
56
|
-
if (options) {
|
|
57
|
-
return createRouteDecorator("POST")(parsedPath, options);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return createRouteDecorator("POST")(parsedPath);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function Put(path, options) {
|
|
64
|
-
const parsedPath = !path && !options ? "/" : path;
|
|
65
|
-
if (options) {
|
|
66
|
-
return createRouteDecorator("PUT")(parsedPath, options);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return createRouteDecorator("PUT")(parsedPath);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function Delete(path, options) {
|
|
73
|
-
const parsedPath = !path && !options ? "/" : path;
|
|
74
|
-
if (options) {
|
|
75
|
-
return createRouteDecorator("DELETE")(parsedPath, options);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return createRouteDecorator("DELETE")(parsedPath);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.Patch = createRouteDecorator("PATCH");
|
|
82
|
-
exports.Options = createRouteDecorator("OPTIONS");
|
|
83
|
-
exports.All = createRouteDecorator("ALL");
|
|
44
|
+
const Patch = (pathOrOptions, maybeOptions) => Route("PATCH", pathOrOptions, maybeOptions);
|
|
45
|
+
exports.Patch = Patch;
|
|
46
|
+
const Options = (pathOrOptions, maybeOptions) => Route("OPTIONS", pathOrOptions, maybeOptions);
|
|
47
|
+
exports.Options = Options;
|
|
48
|
+
const All = (pathOrOptions, maybeOptions) => Route("ALL", pathOrOptions, maybeOptions);
|
|
49
|
+
exports.All = All;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avleon/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"keywords": [
|
|
@@ -11,64 +11,69 @@
|
|
|
11
11
|
],
|
|
12
12
|
"author": "Tareq Hossain",
|
|
13
13
|
"license": "ISC",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"husky": "^8.0.0",
|
|
25
|
-
"ioredis": "^5.6.1",
|
|
26
|
-
"jest": "^29.7.0",
|
|
27
|
-
"knex": "^3.1.0",
|
|
28
|
-
"lint-staged": "^16.0.0",
|
|
29
|
-
"mssql": "^11.0.1",
|
|
30
|
-
"mysql2": "^3.14.1",
|
|
31
|
-
"nodemon": "^3.1.7",
|
|
32
|
-
"pg": "^8.16.0",
|
|
33
|
-
"prettier": "^3.5.3",
|
|
34
|
-
"sharp": "^0.33.5",
|
|
35
|
-
"sqlite": "^5.1.1",
|
|
36
|
-
"sqlite3": "^5.1.7",
|
|
37
|
-
"ts-jest": "^29.2.5",
|
|
38
|
-
"ts-node": "^10.9.2",
|
|
39
|
-
"tsc-watch": "^6.2.1",
|
|
40
|
-
"typeorm": "^0.3.20",
|
|
41
|
-
"typescript": "^5.7.2"
|
|
14
|
+
"description": "avleon core",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/avleonjs/avleon-core"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"directories": {
|
|
23
|
+
"test": "."
|
|
42
24
|
},
|
|
43
25
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"@fastify/swagger-ui": "^5.1.0",
|
|
49
|
-
"@fastify/view": "^11.0.0",
|
|
50
|
-
"@types/mssql": "^9.1.7",
|
|
51
|
-
"bcryptjs": "^3.0.2",
|
|
52
|
-
"cross-env": "^7.0.3",
|
|
53
|
-
"dotenv": "^16.4.7",
|
|
54
|
-
"fastify": "^5.1.0",
|
|
55
|
-
"fastify-socket.io": "^5.1.0",
|
|
56
|
-
"highlight.js": "^11.9.0",
|
|
57
|
-
"pino": "^9.6.0",
|
|
58
|
-
"pino-pretty": "^13.0.0",
|
|
26
|
+
"class-transformer": "^0.5.1",
|
|
27
|
+
"class-validator": "^0.14.2",
|
|
28
|
+
"fastify": "^5.6.0",
|
|
29
|
+
"pino": "^9.10.0",
|
|
59
30
|
"reflect-metadata": "^0.2.2",
|
|
60
|
-
"rimraf": "^6.0.1",
|
|
61
|
-
"socket.io": "^4.8.1",
|
|
62
31
|
"typedi": "^0.10.0"
|
|
63
32
|
},
|
|
64
33
|
"peerDependencies": {
|
|
34
|
+
"@fastify/cors": "*",
|
|
35
|
+
"@fastify/multipart": "*",
|
|
36
|
+
"@fastify/static": "*",
|
|
37
|
+
"@fastify/swagger": "*",
|
|
38
|
+
"@fastify/swagger-ui": "*",
|
|
39
|
+
"@fastify/view": "*",
|
|
65
40
|
"@scalar/fastify-api-reference": "*",
|
|
41
|
+
"bcryptjs": "3.0.2",
|
|
42
|
+
"dotenv": "*",
|
|
43
|
+
"fastify-socket.io": "*",
|
|
44
|
+
"highlight.js": "*",
|
|
66
45
|
"ioredis": "*",
|
|
46
|
+
"knex": "*",
|
|
47
|
+
"mssql": "*",
|
|
48
|
+
"mysql2": "*",
|
|
49
|
+
"pg": "*",
|
|
67
50
|
"sharp": "*",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
51
|
+
"socket.io": "*",
|
|
52
|
+
"sqlite3": "*",
|
|
53
|
+
"typeorm": "*"
|
|
70
54
|
},
|
|
71
55
|
"peerDependenciesMeta": {
|
|
56
|
+
"bcryptjs": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"@fastify/cors": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"@fastify/multipart": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"@fastify/static": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@fastify/swagger": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"@fastify/swagger-ui": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"@fastify/view": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
72
77
|
"@scalar/fastify-api-reference": {
|
|
73
78
|
"optional": true
|
|
74
79
|
},
|
|
@@ -83,8 +88,49 @@
|
|
|
83
88
|
},
|
|
84
89
|
"knex": {
|
|
85
90
|
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"mssql": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"mysql2": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"pg": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"sqlite3": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"fastify-socket.io": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"socket.io": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"dotenv": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"highlight.js": {
|
|
114
|
+
"optional": true
|
|
86
115
|
}
|
|
87
116
|
},
|
|
117
|
+
"devDependencies": {
|
|
118
|
+
"@types/bcryptjs": "^3.0.0",
|
|
119
|
+
"@types/jest": "^29.5.14",
|
|
120
|
+
"@types/node": "^20.19.17",
|
|
121
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
122
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
123
|
+
"eslint": "^9.36.0",
|
|
124
|
+
"eslint-config-prettier": "^10.1.8",
|
|
125
|
+
"husky": "^8.0.3",
|
|
126
|
+
"jest": "^29.7.0",
|
|
127
|
+
"lint-staged": "^16.1.6",
|
|
128
|
+
"prettier": "^3.6.2",
|
|
129
|
+
"rimraf": "^6.0.1",
|
|
130
|
+
"ts-jest": "^29.4.4",
|
|
131
|
+
"tsc-watch": "^6.3.1",
|
|
132
|
+
"typescript": "^5.7.2"
|
|
133
|
+
},
|
|
88
134
|
"lint-staged": {
|
|
89
135
|
"*.{js,ts,json,md}": "pnpm format",
|
|
90
136
|
"*.{js,ts}": [
|
|
@@ -92,20 +138,6 @@
|
|
|
92
138
|
"cross-env CI=true jest --bail --findRelatedTests --passWithNoTests --config=jest.config.js"
|
|
93
139
|
]
|
|
94
140
|
},
|
|
95
|
-
"optionalDependencies": {
|
|
96
|
-
"typeorm": "*"
|
|
97
|
-
},
|
|
98
|
-
"directories": {
|
|
99
|
-
"test": "."
|
|
100
|
-
},
|
|
101
|
-
"description": "avleon core",
|
|
102
|
-
"repository": {
|
|
103
|
-
"type": "git",
|
|
104
|
-
"url": "git+https://github.com/avleonjs/avleon-core"
|
|
105
|
-
},
|
|
106
|
-
"files": [
|
|
107
|
-
"dist"
|
|
108
|
-
],
|
|
109
141
|
"scripts": {
|
|
110
142
|
"build": "npm run clean && tsc",
|
|
111
143
|
"clean": "rimraf dist",
|