Skip to content

Commit

Permalink
fix: constant naming & remove const enum (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahziheng authored May 31, 2022
1 parent 0528c9d commit 062f190
Show file tree
Hide file tree
Showing 27 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/application.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';
import { Container } from '@artus/injection';
import { ArtusInjectEnum } from './constraints';
import { ArtusInjectEnum } from './constant';
import { ArtusStdError, ExceptionHandler } from './exception';
import { HookFunction, LifecycleManager } from './lifecycle';
import { LoaderFactory, Manifest } from './loader';
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HOOK_CONFIG_HANDLE } from "../constraints";
import { HOOK_CONFIG_HANDLE } from "../constant";

export function DefineConfigHandle(handleName?: string): PropertyDecorator {
return (target: any, propertyKey: string | symbol) => {
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@artus/injection';
import { ARTUS_DEFAULT_CONFIG_ENV, ARTUS_SERVER_ENV } from '../constraints';
import { ARTUS_DEFAULT_CONFIG_ENV, ARTUS_SERVER_ENV } from '../constant';
import { ManifestItem } from '../loader';
import { mergeConfig } from '../loader/utils/merge';
import compatibleRequire from '../utils/compatible_require';
Expand Down
2 changes: 1 addition & 1 deletion src/constraints.ts → src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const LOADER_NAME_META = 'loader:name';

export const ArtusInjectPrefix = 'artus#';

export const enum ArtusInjectEnum {
export enum ArtusInjectEnum {
Application = 'artus#application',
Config = 'artus#config',
DefaultContainerName = 'artus#default_container',
Expand Down
2 changes: 1 addition & 1 deletion src/decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
HOOK_NAME_META_PREFIX,
CONSTRUCTOR_PARAMS_CONTEXT,
HOOK_FILE_LOADER,
} from './constraints';
} from './constant';

export function LifecycleHookUnit(): ClassDecorator {
return (target: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/exception/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ARTUS_EXCEPTION_DEFAULT_LOCALE } from '../constraints';
import { ARTUS_EXCEPTION_DEFAULT_LOCALE } from '../constant';
import { ExceptionItem } from './types';

export const ErrorCodeUtils = {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {

export {
ArtusInjectEnum
} from './constraints';
} from './constant';
export * from './loader';
export * from './logger';
export * from './lifecycle';
Expand All @@ -17,7 +17,7 @@ export * from './application';
export * from './scanner';
export * from './decorator';
export * from './types';
export * from './constraints';
export * from './constant';

import ConfigurationHandler from './configuration';
export { ConfigurationHandler };
Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CONSTRUCTOR_PARAMS_APP,
CONSTRUCTOR_PARAMS_CONTAINER,
HOOK_NAME_META_PREFIX
} from '../constraints';
} from '../constant';

export type HookFunction = <T = unknown>(hookProps : {
app: Application,
Expand Down
2 changes: 1 addition & 1 deletion src/loader/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LOADER_NAME_META } from '../constraints';
import { LOADER_NAME_META } from '../constant';

export const DefineLoader = (loaderName: string): ClassDecorator =>
(target: Function) => {
Expand Down
2 changes: 1 addition & 1 deletion src/loader/factory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import { Container } from '@artus/injection';
import { ArtusInjectEnum, DEFAULT_LOADER, HOOK_FILE_LOADER, LOADER_NAME_META } from '../constraints';
import { ArtusInjectEnum, DEFAULT_LOADER, HOOK_FILE_LOADER, LOADER_NAME_META } from '../constant';
import { Manifest, ManifestItem, LoaderConstructor, LoaderHookUnit, LoaderCheckOptions } from './types';
import ConfigurationHandler from '../configuration';
import { LifecycleManager } from '../lifecycle';
Expand Down
2 changes: 1 addition & 1 deletion src/loader/impl/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path';
import { Container } from '@artus/injection';
import ConfigurationHandler from '../../configuration';
import { ArtusInjectEnum, ARTUS_DEFAULT_CONFIG_ENV, CONFIG_PATTERN } from '../../constraints';
import { ArtusInjectEnum, ARTUS_DEFAULT_CONFIG_ENV, CONFIG_PATTERN } from '../../constant';
import { DefineLoader } from '../decorator';
import { ManifestItem, Loader, LoaderCheckOptions } from '../types';
import compatibleRequire from '../../utils/compatible_require';
Expand Down
2 changes: 1 addition & 1 deletion src/loader/impl/exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ManifestItem, Loader, LoaderCheckOptions } from '../types';
import { ExceptionItem } from '../../exception/types';
import { ExceptionHandler } from '../../exception';
import { loadMetaFile } from '../../utils/load_meta_file';
import { EXCEPTION_FILE } from '../../constraints';
import { EXCEPTION_FILE } from '../../constant';
import { isMatch } from '../../utils';

@DefineLoader('exception')
Expand Down
2 changes: 1 addition & 1 deletion src/loader/impl/framework_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ConfigurationHandler from '../../configuration';
import { DefineLoader } from '../decorator';
import { ManifestItem, Loader, LoaderCheckOptions } from '../types';
import compatibleRequire from '../../utils/compatible_require';
import { ArtusInjectEnum, ARTUS_DEFAULT_CONFIG_ENV, FRAMEWORK_PATTERN } from '../../constraints';
import { ArtusInjectEnum, ARTUS_DEFAULT_CONFIG_ENV, FRAMEWORK_PATTERN } from '../../constant';
import ConfigLoader from './config';
import { isMatch } from '../../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/loader/impl/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Constructable, Container } from '@artus/injection';
import { ArtusInjectEnum } from '../../constraints';
import { ArtusInjectEnum } from '../../constant';
import { LifecycleManager } from '../../lifecycle';
import { ApplicationLifecycle } from '../../types';
import { DefineLoader } from '../decorator';
Expand Down
2 changes: 1 addition & 1 deletion src/loader/impl/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ConfigurationHandler from '../../configuration';
import { DefineLoader } from '../decorator';
import { ManifestItem, Loader, LoaderCheckOptions } from '../types';
import compatibleRequire from '../../utils/compatible_require';
import { PACKAGE_JSON } from '../../constraints';
import { PACKAGE_JSON } from '../../constant';
import { isMatch } from '../../utils';

@DefineLoader('package-json')
Expand Down
2 changes: 1 addition & 1 deletion src/loader/impl/plugin_config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PLUGIN_CONFIG_PATTERN } from '../../constraints';
import { PLUGIN_CONFIG_PATTERN } from '../../constant';
import { isMatch } from '../../utils';
import { DefineLoader } from '../decorator';
import { ManifestItem, Loader, LoaderCheckOptions } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion src/logger/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject } from '@artus/injection';
import { ArtusInjectEnum } from '../constraints';
import { ArtusInjectEnum } from '../constant';
import { LoggerLevel, LOGGER_LEVEL_MAP } from './level';
import { Logger, LoggerOptions, LogOptions } from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/logger/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, InjectableOption, ScopeEnum } from '@artus/injection';
import { ArtusInjectEnum } from '../constraints';
import { ArtusInjectEnum } from '../constant';

export const DefineLogger = (injectableOpts: InjectableOption = {}): ClassDecorator => {
return Injectable({
Expand Down
2 changes: 1 addition & 1 deletion src/logger/level.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum LoggerLevel {
export enum LoggerLevel {
TRACE = 'TRACE',
DEBUG = 'DEBUG',
INFO = 'INFO',
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum PluginType {
export enum PluginType {
simple = 'simple',
module = 'module',
}
Expand Down
2 changes: 1 addition & 1 deletion src/scanner/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
DEFAULT_EXCLUDES,
DEFAULT_LOADER_LIST_WITH_ORDER,
LOADER_NAME_META,
} from '../constraints';
} from '../constant';
import { Manifest, ManifestItem } from '../loader';
import { ScannerOptions, WalkOptions } from './types';
import ConfigurationHandler, { ConfigObject } from '../configuration';
Expand Down
2 changes: 1 addition & 1 deletion src/scanner/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ArtusInjectEnum,
DEFAULT_LOADER,
PLUGIN_META
} from '../constraints';
} from '../constant';
import { LoaderFactory, ManifestItem } from '../loader';
import { WalkOptions } from './types';
import { isMatch } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion src/trigger/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, ScopeEnum } from '@artus/injection';
import { ArtusInjectEnum } from '../constraints';
import { ArtusInjectEnum } from '../constant';

export function DefineTrigger(): ClassDecorator {
return (target:any) => Injectable({
Expand Down
2 changes: 1 addition & 1 deletion src/trigger/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExecutionContainer, Inject } from '@artus/injection';
import { Input, Context, MiddlewareInput, Pipeline, Output } from '@artus/pipeline';
import { ArtusInjectEnum } from '../constraints';
import { ArtusInjectEnum } from '../constant';
import { Application } from '../types';
import { DefineTrigger } from './decorator';

Expand Down
2 changes: 1 addition & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'reflect-metadata';
import { ARTUS_SERVER_ENV } from '../src/constraints';
import { ARTUS_SERVER_ENV } from '../src/constant';

describe('test/app.test.ts', () => {
describe('app with config', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/frameworks/bar/src/http.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'reflect-metadata';
import { Context, Next } from '@artus/pipeline';
import { Constructable } from '@artus/injection';
import { CONSTRUCTOR_PARAMS, CONSTRUCTOR_PARAMS_CONTEXT } from '../../../../../src/constraints';
import { CONSTRUCTOR_PARAMS, CONSTRUCTOR_PARAMS_CONTEXT } from '../../../../../src/constant';
import { HttpTrigger } from '../../abstract/foo';
import { Injectable, ScopeEnum } from '@artus/injection';

Expand Down
2 changes: 1 addition & 1 deletion test/framework.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Scanner } from '../src/scanner';
import path from 'path';
import axios from 'axios';
import assert from 'assert';
import { ARTUS_SERVER_ENV } from '../src/constraints';
import { ARTUS_SERVER_ENV } from '../src/constant';

describe('test/framework.test.ts', () => {
beforeEach(async function () {
Expand Down

0 comments on commit 062f190

Please sign in to comment.