-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yashpokar/lib/config
added shared library
- Loading branch information
Showing
16 changed files
with
585 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
API_PORT= | ||
API_URL= | ||
|
||
UI_PORT= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,9 @@ build/ | |
package-lock.json | ||
|
||
.nx/ | ||
|
||
.env | ||
.env.local | ||
.env.development | ||
.env.test | ||
.env.production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pnpm exec lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"author": "Yash Patel <[email protected]>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"core": "workspace:^", | ||
"express": "^4.19.2", | ||
"socket.io": "^4.7.5" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import express from 'express' | ||
import { createServer } from 'node:http' | ||
|
||
import { API_PORT, API_URL } from 'core' | ||
import logger from 'core/dist/logger' | ||
|
||
const app = express() | ||
const server = createServer(app) | ||
|
||
server.listen(8000, () => { | ||
console.log('server running at http://localhost:8000') | ||
server.listen(API_PORT, () => { | ||
logger.info(`server running at ${API_URL}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
import 'dotenv/config' | ||
|
||
// TODO: refer this from the core package | ||
const port = parseInt(process.env.UI_PORT || '3000') | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
server: { | ||
port: 3000 | ||
port | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,23 @@ | |
"version": "0.0.1", | ||
"description": "The Manas AI", | ||
"scripts": { | ||
"ui:dev": "nx run ui:dev", | ||
"ui:dev": "concurrently \"nx run core:build:watch\" \"nx run ui:dev\"", | ||
"ui:build": "nx run ui:build", | ||
"ui:lint": "nx run ui:lint", | ||
"ui:test": "nx run ui:test", | ||
"api:dev": "nx run api:dev", | ||
"api:dev": "concurrently \"nx run core:build:watch\" \"nx run api:dev\"", | ||
"api:build": "nx run api:build", | ||
"api:lint": "nx run api:lint", | ||
"api:test": "nx run api:test", | ||
"lint": "nx run-many --target=lint --all", | ||
"test": "nx run-many --target=test --all", | ||
"build": "nx run-many --target=build --all" | ||
"build": "nx run-many --target=build --all", | ||
"prepare": "husky" | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts,tsx,json,css,scss,md}": [ | ||
"prettier --write" | ||
] | ||
}, | ||
"keywords": [ | ||
"ManasAI", | ||
|
@@ -26,6 +32,9 @@ | |
"author": "Yash Patel <[email protected]>", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"concurrently": "^8.2.2", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.2", | ||
"nx": "^18.2.1", | ||
"prettier": "3.2.5" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "core", | ||
"private": true, | ||
"version": "0.0.1", | ||
"description": "Core utilities for the project", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "rm -rf dist/ && tsc", | ||
"build:watch": "tsc -w" | ||
}, | ||
"keywords": [], | ||
"author": "Yash Patel <[email protected]>", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/node": "^20.11.30", | ||
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"dotenv": "^16.4.5", | ||
"winston": "^3.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'dotenv/config' | ||
|
||
export const API_PORT = parseInt(process.env.API_PORT || '8000') | ||
export const API_URL = process.env.API_URL || `http://localhost:${API_PORT}` | ||
|
||
export const UI_PORT = parseInt(process.env.UI_PORT || '3000') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './config' | ||
export * from './logger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import winston from 'winston' | ||
|
||
const logger = winston.createLogger({ | ||
level: 'info', | ||
format: winston.format.json(), | ||
defaultMeta: { service: 'api' }, | ||
transports: [new winston.transports.Console()] | ||
}) | ||
|
||
export default logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "CommonJS", | ||
"declaration": true, | ||
"lib": ["ESNext"], | ||
"outDir": "./dist", | ||
"rootDir": "./src", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"resolveJsonModule": true, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
Oops, something went wrong.