-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move service controllers to api gateway
- Loading branch information
Showing
29 changed files
with
288 additions
and
39 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 |
---|---|---|
@@ -1 +0,0 @@ | ||
Should we have a single api gateway that has all the controllers which then calls the Restate services? | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Framework | ||
SERVER_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,18 @@ | ||
{ | ||
"extends": ["../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,100 @@ | ||
{ | ||
"name": "api-gateway", | ||
"$schema": "../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "application", | ||
"prefix": "ftgo", | ||
"sourceRoot": "api-gateway/src", | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/vite:build", | ||
"outputs": ["{options.outputPath}"], | ||
"defaultConfiguration": "development", | ||
"options": { | ||
"outputPath": "dist/api-gateway", | ||
"ssr": "src/main.ts", | ||
"outputFileName": "main.mjs" | ||
}, | ||
"configurations": { | ||
"development": { | ||
"mode": "development" | ||
}, | ||
"production": { | ||
"mode": "production" | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"executor": "@nx/js:node", | ||
"defaultConfiguration": "development", | ||
"options": { | ||
"buildTarget": "api-gateway:build", | ||
"watch": false | ||
}, | ||
"configurations": { | ||
"development": { | ||
"buildTarget": "api-gateway:build:development", | ||
"args": ["api-gateway:start"], | ||
"watch": true | ||
}, | ||
"production": { | ||
"buildTarget": "api-gateway:build:production" | ||
}, | ||
"staging": { | ||
"buildTarget": "api-gateway:build:staging" | ||
} | ||
} | ||
}, | ||
"container": { | ||
"executor": "@nx-tools/nx-container:build", | ||
"dependsOn": ["build"], | ||
"options": { | ||
"engine": "docker", | ||
"push": true, | ||
"cache-from": ["type=gha"], | ||
"cache-to": ["type=gha,mode=max"], | ||
"metadata": { | ||
"images": ["ghcr.io/zapxme/api-gateway"], | ||
"tags": [ | ||
"type=schedule", | ||
"type=ref,event=branch", | ||
"type=ref,event=tag", | ||
"type=ref,event=pr", | ||
"type=sha,prefix=sha-" | ||
] | ||
} | ||
} | ||
}, | ||
"create-migration": { | ||
"executor": "@nx/js:node", | ||
"defaultConfiguration": "development", | ||
"options": { | ||
"buildTarget": "api-gateway:build", | ||
"args": [ | ||
"migration:create", | ||
"--migrationDir", | ||
"api-gateway/src/migrations" | ||
], | ||
"watch": false | ||
}, | ||
"configurations": { | ||
"development": { | ||
"buildTarget": "api-gateway:build:development" | ||
}, | ||
"production": { | ||
"buildTarget": "api-gateway:build:production" | ||
}, | ||
"staging": { | ||
"buildTarget": "api-gateway:build:staging" | ||
} | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint" | ||
}, | ||
"test": { | ||
"executor": "@nx/vite:test", | ||
"outputs": ["{projectRoot}/coverage"] | ||
} | ||
} | ||
} |
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 @@ | ||
import { http } from '@deepkit/http'; | ||
|
||
@http.controller('accounting') | ||
export class AccountingController {} |
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 { createModule } from '@deepkit/app'; | ||
|
||
import { provideAccountingServiceApi } from '@ftgo/accounting-service-api'; | ||
|
||
import { AccountingController } from './accounting.controller.js'; | ||
|
||
export class AccountingModule extends createModule({ | ||
controllers: [AccountingController], | ||
providers: [provideAccountingServiceApi()], | ||
}) {} |
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,7 @@ | ||
import { RestateConfig } from 'deepkit-restate'; | ||
import { FrameworkConfig } from '@deepkit/framework'; | ||
|
||
export class ApiGatewayConfig { | ||
readonly restate: RestateConfig; | ||
readonly server: FrameworkConfig = new FrameworkConfig(); | ||
} |
2 changes: 1 addition & 1 deletion
2
consumer-service/src/consumer.controller.ts → ...teway/src/consumer/consumer.controller.ts
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,4 +1,4 @@ | ||
import { http } from '@deepkit/http'; | ||
|
||
@http.controller('') | ||
@http.controller('consumer') | ||
export class ConsumerController {} |
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 { createModule } from '@deepkit/app'; | ||
|
||
import { provideConsumerServiceApi } from '@ftgo/consumer-service-api'; | ||
|
||
import { ConsumerController } from './consumer.controller.js'; | ||
|
||
export class ConsumerModule extends createModule({ | ||
controllers: [ConsumerController], | ||
providers: [provideConsumerServiceApi()], | ||
}) {} |
2 changes: 1 addition & 1 deletion
2
delivery-service/src/delivery.controller.ts → ...teway/src/delivery/delivery.controller.ts
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,4 +1,4 @@ | ||
import { http } from '@deepkit/http'; | ||
|
||
@http.controller('') | ||
@http.controller('delivery') | ||
export class DeliveryController {} |
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 { createModule } from '@deepkit/app'; | ||
|
||
import { provideDeliveryServiceApi } from '@ftgo/delivery-service-api'; | ||
|
||
import { DeliveryController } from './delivery.controller.js'; | ||
|
||
export class DeliveryModule extends createModule({ | ||
controllers: [DeliveryController], | ||
providers: [provideDeliveryServiceApi()], | ||
}) {} |
2 changes: 1 addition & 1 deletion
2
kitchen-service/src/kitchen.controller.ts → ...gateway/src/kitchen/kitchen.controller.ts
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,4 +1,4 @@ | ||
import { http } from '@deepkit/http'; | ||
|
||
@http.controller('') | ||
@http.controller('kitchen') | ||
export class KitchenController {} |
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 { createModule } from '@deepkit/app'; | ||
|
||
import { provideKitchenServiceApi } from '@ftgo/kitchen-service-api'; | ||
|
||
import { KitchenController } from './kitchen.controller.js'; | ||
|
||
export class KitchenModule extends createModule({ | ||
controllers: [KitchenController], | ||
providers: [provideKitchenServiceApi()], | ||
}) {} |
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,36 @@ | ||
import { App } from '@deepkit/app'; | ||
import { FrameworkModule } from '@deepkit/framework'; | ||
import { RestateModule } from 'deepkit-restate'; | ||
|
||
import { ApiGatewayConfig } from './config.js'; | ||
import { AccountingModule } from './accounting/accounting.module.js'; | ||
import { ConsumerModule } from './consumer/consumer.module.js'; | ||
import { DeliveryModule } from './delivery/delivery.module.js'; | ||
import { KitchenModule } from './kitchen/kitchen.module.js'; | ||
import { OrderModule } from './order/order.module.js'; | ||
import { RestaurantModule } from './restaurant/restaurant.module.js'; | ||
|
||
void new App({ | ||
config: ApiGatewayConfig, | ||
imports: [ | ||
new FrameworkModule(), | ||
new RestateModule(), | ||
new AccountingModule(), | ||
new ConsumerModule(), | ||
new DeliveryModule(), | ||
new KitchenModule(), | ||
new OrderModule(), | ||
new RestateModule(), | ||
new RestaurantModule(), | ||
], | ||
controllers: [], | ||
}) | ||
.setup((module, config: ApiGatewayConfig) => { | ||
module.getImportedModuleByClass(FrameworkModule).configure(config.server); | ||
|
||
module.getImportedModuleByClass(RestateModule).configure({ | ||
ingress: config.restate.ingress, | ||
}); | ||
}) | ||
.loadConfigFromEnv({ prefix: '' }) | ||
.run(); |
2 changes: 1 addition & 1 deletion
2
order-service/src/order.controller.ts → api-gateway/src/order/order.controller.ts
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,4 +1,4 @@ | ||
import { http } from '@deepkit/http'; | ||
|
||
@http.controller('') | ||
@http.controller('order') | ||
export class OrderController {} |
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 { createModule } from '@deepkit/app'; | ||
|
||
import { provideOrderServiceApi } from '@ftgo/order-service-api'; | ||
|
||
import { OrderController } from './order.controller.js'; | ||
|
||
export class OrderModule extends createModule({ | ||
controllers: [OrderController], | ||
providers: [provideOrderServiceApi()], | ||
}) {} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createModule } from '@deepkit/app'; | ||
|
||
import { provideRestaurantServiceApi } from '@ftgo/restaurant-service-api'; | ||
|
||
import { RestaurantController } from './restaurant.controller.js'; | ||
|
||
export class RestaurantModule extends createModule({ | ||
controllers: [RestaurantController], | ||
providers: [provideRestaurantServiceApi()], | ||
}) {} |
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,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../dist/out-tsc", | ||
"types": [] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["src/**/*.test.ts", "src/**/*.spec.ts"] | ||
} |
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,17 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"compilerOptions": { | ||
"strictPropertyInitialization": false, | ||
"types": ["vite/client"] | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.app.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
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,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../dist/out-tsc", | ||
"types": ["vitest/globals"] | ||
}, | ||
"include": ["src/**/*.ts"] | ||
} |
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 @@ | ||
// eslint-disable-next-line @nx/enforce-module-boundaries | ||
import { defineNodeConfig } from '../node-vite-config'; | ||
|
||
export default defineNodeConfig({ | ||
root: __dirname, | ||
}); |
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
Oops, something went wrong.