@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.
@@ -1,11 +1,11 @@
1
1
  declare enum Env {
2
- production = 0,
3
- testing = 1,
4
- staging = 2,
5
- development = 3
2
+ production = "production",
3
+ testing = "testing",
4
+ staging = "staging",
5
+ development = "development"
6
6
  }
7
7
  export declare class EnvValidator {
8
- readonly env: Env;
9
- readonly DB_URL: string;
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
- private validators?;
17
+ readonly validators?: ValidatorType;
17
18
  private cors;
18
19
  private logger;
19
- constructor(name: string, cors?: string[]);
20
+ constructor(options: AppConfigOptions);
20
21
  init(): void;
21
22
  /**
22
23
  * Serve static files from a directory
@@ -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 { Validator } from './types';
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.bgAnsi256(214)(source_default.blue(`${message}`)));
26333
+ console.log(source_default.blue(`Info : ${message}`));
26334
26334
  }
26335
26335
  warn(message) {
26336
- console.log(source_default.bgYellow(source_default.red(`${message}`)));
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.bgMagenta(source_default.ansi256(214)(`${message}`)));
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(name, cors2) {
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 = { env: ["asdkjabds"] };
26776
+ this.validators = options2.validators;
26777
26777
  this.logger = new Logger;
26778
- this.cors = cors2 || ["*"];
26778
+ this.cors = options2.cors || ["*"];
26779
26779
  this.init();
26780
26780
  }
26781
26781
  init() {
26782
- this.app.use(cors({
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
- this.logger.info(` STATIC ${path}/* -> ${root}`);
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
- this.logger.info(` ${route.method.toUpperCase().padEnd(7)} ${fullPath}`);
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 (target) => {
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
@@ -1,3 +1,8 @@
1
- export type Validator = {
1
+ export type ValidatorType = {
2
2
  env: [unknown];
3
3
  };
4
+ export interface AppConfigOptions {
5
+ name: string;
6
+ validators: ValidatorType;
7
+ cors: string[];
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razvan11/paladin",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A Bun-based backend framework with decorators, dependency injection, and controller registration",
5
5
  "keywords": [
6
6
  "bun",