Skip to content

Commit

Permalink
feat: added load env capability
Browse files Browse the repository at this point in the history
  • Loading branch information
teclone committed Nov 14, 2020
1 parent 1d9d19b commit b57d579
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 178 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"typings": "tsc --p ./tsconfig.build.json",
"build": "rimraf lib && yarn typings --declarationDir ./lib && rollup-all",
"lint": "eslint src/**/*.ts --fix",
"compile": "tsc --noEmit",
"start": "npm run build && node app.js",
"postinstall": "bash ./scripts/gen-ssl-cert.sh && node ./scripts/create-unreadable.js",
"report-coverage": "jest --coverage --coverageReporters=text-lcov | coveralls",
Expand Down Expand Up @@ -73,7 +74,8 @@
"@babel/runtime": "7.4.3",
"@teclone/node-utils": "1.0.4",
"@teclone/regex": "1.0.3",
"@teclone/utils": "2.14.4",
"@teclone/utils": "^2.22.0",
"dotenv": "^8.2.0",
"mime-types": "2.1.24",
"uuid": "3.3.3"
}
Expand Down
3 changes: 2 additions & 1 deletion src/.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from 'path';
const rServerConfig: RServerConfig = {
entryPath: path.resolve(__dirname, '../'),

env: 'dev',
env: 'development',

errorLog: '.log/error.log',

Expand Down Expand Up @@ -34,6 +34,7 @@ const rServerConfig: RServerConfig = {

https: {
enabled: false,

/* can be overriden by setting process.env.HTTPS_PORT */
port: 9000,

Expand Down
10 changes: 6 additions & 4 deletions src/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { AddressInfo } from 'net';
import Request from '../modules/Request';
import Response from '../modules/Response';

export type Env = 'development' | 'production';

export interface RServerConfig {
entryPath: string;

env: 'dev' | 'prod';
env: Env;

errorLog: string;

Expand Down Expand Up @@ -49,7 +51,7 @@ export interface RServerConfig {
}

export interface Config {
env?: 'dev' | 'prod';
env?: Env;

errorLog?: string;

Expand Down Expand Up @@ -157,14 +159,14 @@ export type RouteInstance = [
RouteId,
Url,
Callback,
null | ResolvedCallbackOptions,
null | ResolvedCallbackOptions
];

export type MiddlewareInstance = [
MiddlewareId,
Url,
Middleware[],
null | ResolvedMiddlewareOptions,
null | ResolvedMiddlewareOptions
];

export interface FileEntry {
Expand Down

0 comments on commit b57d579

Please sign in to comment.