@razvan11/paladin 1.0.0 → 1.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.
- package/dist/EnvValidator.d.ts +6 -6
- package/dist/app/app.d.ts +3 -2
- package/dist/functions/env.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -11
- package/dist/types.d.ts +6 -1
- package/package.json +1 -1
package/dist/EnvValidator.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare enum Env {
|
|
2
|
-
production =
|
|
3
|
-
testing =
|
|
4
|
-
staging =
|
|
5
|
-
development =
|
|
2
|
+
production = "production",
|
|
3
|
+
testing = "testing",
|
|
4
|
+
staging = "staging",
|
|
5
|
+
development = "development"
|
|
6
6
|
}
|
|
7
7
|
export declare class EnvValidator {
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
8
|
+
readonly APP_ENV: Env;
|
|
9
|
+
readonly APP_DATABASE_URL: string;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
package/dist/app/app.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import 'reflect-metadata';
|
|
|
2
2
|
import type { Server } from 'bun';
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
4
|
import '../container/container';
|
|
5
|
+
import type { AppConfigOptions, ValidatorType } from '../types';
|
|
5
6
|
type ControllerClass = new (...args: any[]) => any;
|
|
6
7
|
export interface StaticOptions {
|
|
7
8
|
/** URL path prefix (e.g., '/static') */
|
|
@@ -13,10 +14,10 @@ export declare class App {
|
|
|
13
14
|
private app;
|
|
14
15
|
name: string;
|
|
15
16
|
private container;
|
|
16
|
-
|
|
17
|
+
readonly validators?: ValidatorType;
|
|
17
18
|
private cors;
|
|
18
19
|
private logger;
|
|
19
|
-
constructor(
|
|
20
|
+
constructor(options: AppConfigOptions);
|
|
20
21
|
init(): void;
|
|
21
22
|
/**
|
|
22
23
|
* Serve static files from a directory
|
package/dist/functions/env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function env(): PropertyDecorator;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ export { database } from './functions/database';
|
|
|
14
14
|
export { default as config } from './functions/config';
|
|
15
15
|
export { default as validator } from './functions/validator';
|
|
16
16
|
export { render, renderElement, createRenderer } from './functions/render';
|
|
17
|
-
export { LayoutView, PageLoader, type LayoutViewProps } from './components/LayoutView';
|
|
18
|
-
export { asset, publicAsset, setAssetBasePath, getAssetBasePath } from './functions/asset';
|
|
19
|
-
export type {
|
|
17
|
+
export { LayoutView, PageLoader, type LayoutViewProps, } from './components/LayoutView';
|
|
18
|
+
export { asset, publicAsset, setAssetBasePath, getAssetBasePath, } from './functions/asset';
|
|
19
|
+
export type { ValidatorType } from './types';
|
package/dist/index.js
CHANGED
|
@@ -26330,16 +26330,16 @@ class Logger {
|
|
|
26330
26330
|
this.pe.start();
|
|
26331
26331
|
}
|
|
26332
26332
|
info(message) {
|
|
26333
|
-
console.log(source_default.
|
|
26333
|
+
console.log(source_default.blue(`Info : ${message}`));
|
|
26334
26334
|
}
|
|
26335
26335
|
warn(message) {
|
|
26336
|
-
console.log(source_default.
|
|
26336
|
+
console.log(source_default.yellow("Warning"), source_default.red(`${message}`));
|
|
26337
26337
|
}
|
|
26338
26338
|
error(err) {
|
|
26339
26339
|
console.error(this.pe.render(err));
|
|
26340
26340
|
}
|
|
26341
26341
|
success(message) {
|
|
26342
|
-
console.log(source_default.
|
|
26342
|
+
console.log(source_default.magenta(`${message}`));
|
|
26343
26343
|
}
|
|
26344
26344
|
}
|
|
26345
26345
|
var logger = new Logger;
|
|
@@ -26769,18 +26769,20 @@ class App {
|
|
|
26769
26769
|
validators;
|
|
26770
26770
|
cors;
|
|
26771
26771
|
logger;
|
|
26772
|
-
constructor(
|
|
26772
|
+
constructor(options2) {
|
|
26773
26773
|
this.app = new Hono2;
|
|
26774
|
-
this.name = name;
|
|
26774
|
+
this.name = options2.name;
|
|
26775
26775
|
this.container = getContainer2();
|
|
26776
|
-
this.validators =
|
|
26776
|
+
this.validators = options2.validators;
|
|
26777
26777
|
this.logger = new Logger;
|
|
26778
|
-
this.cors =
|
|
26778
|
+
this.cors = options2.cors || ["*"];
|
|
26779
26779
|
this.init();
|
|
26780
26780
|
}
|
|
26781
26781
|
init() {
|
|
26782
|
-
this.
|
|
26782
|
+
console.log(this.cors);
|
|
26783
|
+
this.app.use("/*", cors({
|
|
26783
26784
|
origin: this.cors,
|
|
26785
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
|
26784
26786
|
allowMethods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
|
|
26785
26787
|
}));
|
|
26786
26788
|
}
|
|
@@ -26788,7 +26790,8 @@ class App {
|
|
|
26788
26790
|
const { path = "/static", root = "./public" } = options2;
|
|
26789
26791
|
setAssetBasePath(path);
|
|
26790
26792
|
this.app.use(`${path}/*`, serveStatic2({ root }));
|
|
26791
|
-
|
|
26793
|
+
if (Bun.env.NODE_ENV === "development")
|
|
26794
|
+
this.logger.info(` STATIC ${path}/* -> ${root}`);
|
|
26792
26795
|
return this;
|
|
26793
26796
|
}
|
|
26794
26797
|
registerController(ControllerClass) {
|
|
@@ -26804,7 +26807,8 @@ class App {
|
|
|
26804
26807
|
} else {
|
|
26805
26808
|
app[route.method](fullPath, handler);
|
|
26806
26809
|
}
|
|
26807
|
-
|
|
26810
|
+
if (Bun.env.APP_ENV === "local")
|
|
26811
|
+
this.logger.info(` ${route.method.toUpperCase().padEnd(7)} ${fullPath}`);
|
|
26808
26812
|
}
|
|
26809
26813
|
return this;
|
|
26810
26814
|
}
|
|
@@ -26894,7 +26898,7 @@ function database() {
|
|
|
26894
26898
|
// src/functions/config.ts
|
|
26895
26899
|
var getContainer6 = () => globalThis.container;
|
|
26896
26900
|
function config() {
|
|
26897
|
-
return (
|
|
26901
|
+
return (_target) => {
|
|
26898
26902
|
for (const [key, value] of Object.entries(CONTAINER_KEYS)) {
|
|
26899
26903
|
getContainer6().bind(value).toConstantValue(Bun.env[key]);
|
|
26900
26904
|
}
|
package/dist/types.d.ts
CHANGED