Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uniquely/com-api): new uniquely service #535

Merged
merged 8 commits into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions uniquely/com-api/demo.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@apiUrl = http://127.0.0.1:8000
@apiVersion = v0
@token = YOUR_SECRET_TOKEN

### Home
GET {{apiUrl}}/{{apiVersion}}
51 changes: 51 additions & 0 deletions uniquely/com-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@alwatr/com-api",
"version": "0.27.0",
"description": "Alwatr Customer Order Management API Microservice",
"type": "module",
"author": "S. Ali Mihandoost <[email protected]> (https://ali.mihandoost.com)",
"contributors": [
"S. Amir Mohammad Najafi <[email protected]> (https://njfamirm.ir)"
],
"private": true,
"engines": {
"node": ">=19.0.0",
"npm": ">=8.0.0",
"yarn": ">=1.22.0"
},
"repository": {
"type": "git",
"url": "https://github.com/AliMD/alwatr",
"directory": "uniquely/com-api"
},
"scripts": {
"b": "yarn build",
"c": "yarn clean",
"cb": "run-s clean build",
"s": "yarn start",
"w": "yarn watch",
"start": "NODE_OPTIONS=--enable-source-maps run-s clean build serve",
"build": "yarn build:es --analyze=verbose",
"build:ts": "tsc --build",
"build:es": "esbuild src/index.ts --platform=node --target=node19 --bundle --format=esm --minify --sourcemap --outdir=dist --out-extension:.js=.mjs",
"clean": "rimraf dist build .tsbuildinfo **/*.{d.ts,map} src/**/*.{js,cjs,mjs}",
"serve": "node --enable-source-maps dist/index.mjs",
"serve:debug": "node --inspect --enable-source-maps dist/index.mjs",
"watch": "run-s clean build && run-p watch:es watch:node",
"watch:node": "nodemon -w dist/ --enable-source-maps dist/index.mjs",
"watch:debug-node": "nodemon -w dist/ --inspect --enable-source-maps dist/index.mjs",
"watch:ts": "yarn build:ts --watch --preserveWatchOutput",
"watch:es": "yarn build:es --watch"
},
"devDependencies": {
"@alwatr/logger": "~0.27.0",
njfamirm marked this conversation as resolved.
Show resolved Hide resolved
"@alwatr/nano-server": "~0.27.0",
"@alwatr/storage-client": "~0.27.0",
"@types/node": "~18.11.18",
"esbuild": "~0.16.11",
"nodemon": "~2.0.20",
"npm-run-all": "~4.1.5",
"rimraf": "~3.0.2",
"typescript": "~4.9.4"
}
}
20 changes: 20 additions & 0 deletions uniquely/com-api/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {createLogger} from '@alwatr/logger';

export const logger = createLogger('com-api');

export const config = {
storage: {
host: process.env.STORAGE_HOST ?? '127.0.0.1',
port: process.env.STORAGE_PORT != null ? +process.env.STORAGE_PORT : 9000,
name: process.env.STORAGE_NAME ?? 'job',
token: process.env.STORAGE_TOKEN ?? 'YOUR_SECRET_TOKEN',
},
nanoServer: {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT != null ? +process.env.PORT : 8000,
accessToken: process.env.ACCESS_TOKEN ?? 'YOUR_SECRET_TOKEN',
allowAllOrigin: true,
},
};

logger.logProperty('config', config);
4 changes: 4 additions & 0 deletions uniquely/com-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import './route/home.js';
import {logger} from './config.js';

logger.logOther('..:: Customer Order Management API ::..');
5 changes: 5 additions & 0 deletions uniquely/com-api/src/lib/nano-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {AlwatrNanoServer} from '@alwatr/nano-server';

import {config} from '../config.js';

export const nanoServer = new AlwatrNanoServer(config.nanoServer);
5 changes: 5 additions & 0 deletions uniquely/com-api/src/lib/storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {AlwatrStorageClient} from '@alwatr/storage-client';

import {config} from '../config.js';

export const storageClient = new AlwatrStorageClient(config.storage);
9 changes: 9 additions & 0 deletions uniquely/com-api/src/route/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {nanoServer} from '../lib/nano-server.js';

nanoServer.route('GET', '/', () => ({
ok: true,
data: {
app: 'Alwatr Customer Order Management API Microservice',
message: 'Hello ;)',
},
}));
19 changes: 19 additions & 0 deletions uniquely/com-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base",
"compilerOptions": {
"target": "ESNext",
"composite": true,
"tsBuildInfoFile": ".tsbuildinfo",
"rootDir": "src",
"outDir": "build",
// "noEmit": true
},

"include": ["src/**/*.ts"],
"exclude": [],
"references": [
{"path": "../../core/nano-server"},
{"path": "../../core/logger"},
{"path": "../../core/storage-client"},
]
}
7 changes: 5 additions & 2 deletions uniquely/flight-finder-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"description": "Alwatr Flight Finder API Microservice",
"type": "module",
"author": "S. Ali Mihandoost <[email protected]> (https://ali.mihandoost.com)",
"contributors": [
"S. Amir Mohammad Najafi <[email protected]> (https://njfamirm.ir)"
],
"private": true,
"engines": {
"node": ">=19.0.0",
Expand All @@ -12,8 +15,8 @@
},
"repository": {
"type": "git",
"url": "https://github.com/AliMD/flight-finder",
"directory": "api"
"url": "https://github.com/AliMD/alwatr",
"directory": "uniquely/flight-finder-api"
},
"scripts": {
"b": "yarn build",
Expand Down
4 changes: 2 additions & 2 deletions uniquely/flight-finder-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"browserslist": "> 0.1%, not dead",
"repository": {
"type": "git",
"url": "https://github.com/AliMD/flight-finder",
"directory": "pwa"
"url": "https://github.com/AliMD/alwatr",
"directory": "uniquely/flight-finder-pwa"
},
"scripts": {
"b": "yarn build",
Expand Down