1.1.6 • Published 1 year ago

@cosmoosjs/core v1.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@cosmoosjs/core

Environnement

Environment Variables

Variable Validation

When introducing new environment variables, validate them in you'r environnement file using the Zod library:

Environment.validator export the zod library

export default {
  DATABASE_URL: Environment.validator.string(),
  ENV: Environment.validator.nativeEnum(ENV_STATE_ENUM),
  JWT_TOKEN: Environment.validator.string(),
  ORIGINS: Environment.validator.string(),
  PORT: Environment.validator.string().transform(Number),
  SALT_ROUND: Environment.validator.string(),
  SENTRY_DSN: Environment.validator.string(),
};

IOC

This project utilizes Inversify, an inversion of control container for JavaScript & Node.js apps powered by TypeScript.

Binding

There are several ways to inject classes, in the application we use service identifier binding.

Identifier binding

We use service identifier binding when we need to inject a class that will remain unique within its business context.

// utils/container.ts
const container = new Container();
container.bind(AppLogger).toSelf().inSingletonScope();

// src/index.ts
const appLogger = iocContainer.get(AppLogger);

// controllers/user/index.ts
// Updated file for example
@injectable()
export class UserController implements IController {
  public constructor(@inject(Logger) private logger: Logger) {}
}

For more information about name identifier, please refer to the Wiki

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago