Skip to content

Commit

Permalink
refactor: added runmode for appserver.
Browse files Browse the repository at this point in the history
  • Loading branch information
eser committed Dec 13, 2023
1 parent d614b77 commit ab288bf
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions appserver/appserver.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.

import * as runModes from "../standards/run-modes.ts";
import { events } from "../events/events.ts";
import { di } from "../di/services.ts";

import { type Channel } from "./channel.ts";
import { type Module } from "./module.ts";

export class AppServer {
runMode: runModes.RunMode;
events: typeof events;
di: typeof di;
channels: Map<string, Channel>;
modules: Map<string, Module>;

constructor() {
this.runMode = runModes.RunMode.Development;
this.events = events;
this.di = di;
this.channels = new Map<string, Channel>();
Expand Down
38 changes: 38 additions & 0 deletions lime/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.

import * as appserver from "../appserver/mod.ts";

export class Lime extends appserver.AppServer {
constructor() {
super();
}

// deno-lint-ignore no-explicit-any
manifest(_manifest: any): Lime {
return this;
}

// deno-lint-ignore no-explicit-any
config(_config: any): Lime {
return this;
}

dev(): Lime {
return this;
}

start(): void {
}
}

export function lime() {
return new Lime();
}

/*
lime()
.manifest(manifest)
.config(config)
.dev() // <!— dev mode
.start();
*/
5 changes: 5 additions & 0 deletions standards/mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.

export * as functions from "./functions.ts";
export * as logging from "./logging.ts";
export * as patters from "./patterns.ts";
export * as promises from "./promises.ts";
export * as runModes from "./run-modes.ts";
export * as runtime from "./runtime.ts";
19 changes: 19 additions & 0 deletions standards/run-modes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.

export enum RunMode {
Development = 0,
Production = 1,
Test = 2,
}

export function inDevelopmentMode(mode: RunMode): boolean {
return (mode & RunMode.Production) !== RunMode.Production;
}

export function inProductionMode(mode: RunMode): boolean {
return (mode & RunMode.Production) === RunMode.Production;
}

export function inTestMode(mode: RunMode): boolean {
return (mode & RunMode.Test) === RunMode.Test;
}

0 comments on commit ab288bf

Please sign in to comment.