Skip to content

Commit

Permalink
feat(microservice): base app
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Apr 20, 2022
1 parent 62e33a3 commit f8708cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/starter/microservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@
"watch:ts": "yarn build:ts --watch --preserveWatchOutput"
},
"dependencies": {
"@alwatr/logger": "^0.11.0",
"@alwatr/math": "^0.11.0",
"dotenv": "^16.0.0"
},
"devDependencies": {
"@types/node": "^17.0.25",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"nodemon": "^2.0.15",
"eslint": "^8.13.0",
"eslint-config-google": "^0.14.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0",
"nodemon": "^2.0.15",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/starter/microservice/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {AlwatrMicroServer} from './common/micro-server.js';
import {config} from './config.js';

export const app = new AlwatrMicroServer(config.port);
9 changes: 8 additions & 1 deletion packages/starter/microservice/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import {createLogger} from '@alwatr/logger';
import {isNumber} from '@alwatr/math';
import {config as loadDotEnv} from 'dotenv';

loadDotEnv();

export const config = {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT ?? 8000,
port: isNumber(process.env.PORT) ? +process.env.PORT! : 8000,
};

export const logger = createLogger('microservice');

logger.logProperty('config', config);
8 changes: 3 additions & 5 deletions packages/starter/microservice/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {config} from './config.js';

console.log(`..:: Alwatr Microservice Starter Kit ::..`);

console.dir(config);
import {logger} from './config.js';
import './route/home.js';
logger.logOther(`..:: Alwatr Microservice Starter Kit ::..`);

0 comments on commit f8708cc

Please sign in to comment.