-
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.
- Loading branch information
1 parent
610fe79
commit bc46ee7
Showing
12 changed files
with
280 additions
and
0 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,58 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build-tax-calculator: | ||
name: Build the application for tax-calculator | ||
runs-on: ubuntu-latest | ||
env: | ||
CTP_CLIENT_ID: ${{ secrets.CTP_CLIENT_ID }} | ||
CTP_CLIENT_SECRET: ${{ secrets.CTP_CLIENT_SECRET }} | ||
CTP_PROJECT_KEY: ${{ secrets.CTP_PROJECT_KEY }} | ||
CTP_SCOPE: ${{ secrets.CTP_SCOPE }} | ||
CTP_REGION: ${{ secrets.CTP_REGION }} | ||
defaults: | ||
run: | ||
working-directory: tax-calculator | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
|
||
- name: Install modules | ||
run: npm ci | ||
|
||
- name: Check the coding style | ||
run: npm run lint && npm run prettier | ||
|
||
build-order-syncer: | ||
name: Build the application for order-syncer | ||
runs-on: ubuntu-latest | ||
env: | ||
CTP_CLIENT_ID: ${{ secrets.CTP_CLIENT_ID }} | ||
CTP_CLIENT_SECRET: ${{ secrets.CTP_CLIENT_SECRET }} | ||
CTP_PROJECT_KEY: ${{ secrets.CTP_PROJECT_KEY }} | ||
CTP_SCOPE: ${{ secrets.CTP_SCOPE }} | ||
CTP_REGION: ${{ secrets.CTP_REGION }} | ||
defaults: | ||
run: | ||
working-directory: order-syncer | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
|
||
- name: Install modules | ||
run: npm ci | ||
|
||
- name: Check the coding style | ||
run: npm run lint && npm run prettier |
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,38 @@ | ||
deployAs: | ||
- name: tax-calculator | ||
applicationType: service | ||
endpoint: / | ||
scripts: | ||
postDeploy: npm install | ||
configuration: | ||
standardConfiguration: | ||
- key: CTP_REGION | ||
description: region of commercetools composable commerce project | ||
securedConfiguration: | ||
- key: CTP_PROJECT_KEY | ||
description: project key from commercetools composable commerce project | ||
- key: CTP_CLIENT_ID | ||
description: client id from commercetools composable commerce project | ||
- key: CTP_CLIENT_SECRET | ||
description: client secret from commercetools composable commerce project | ||
- key: CTP_SCOPE | ||
description: scope from commercetools composable commerce project | ||
- name: order-syncer | ||
applicationType: event | ||
endpoint: / | ||
scripts: | ||
postDeploy: npm install && npm run connector:post-deploy | ||
preUndeploy: npm install && npm run connector:pre-undeploy | ||
configuration: | ||
standardConfiguration: | ||
- key: CTP_REGION | ||
description: region of commercetools composable commerce project | ||
securedConfiguration: | ||
- key: CTP_PROJECT_KEY | ||
description: project key from commercetools composable commerce project | ||
- key: CTP_CLIENT_ID | ||
description: client id from commercetools composable commerce project | ||
- key: CTP_CLIENT_SECRET | ||
description: client secret from commercetools composable commerce project | ||
- key: CTP_SCOPE | ||
description: scope from commercetools composable commerce project |
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 @@ | ||
{ | ||
"name": "order-syncher", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"main": "src/index.js", | ||
"private": true, | ||
"scripts": { | ||
"start": "node src/index.js", | ||
"start:dev": "node_modules/.bin/nodemon -q src/index.js", | ||
"lint": "node_modules/.bin/eslint src --ext .js", | ||
"prettier": "node_modules/.bin/prettier --write '**/*.{js,ts}'", | ||
"test": "echo Comment: It is npm command dedicated for running test in connect service", | ||
"test:ci": "node_modules/.bin/jest --config jest.config.cjs" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@babel/core": "^7.22.10", | ||
"@babel/preset-env": "^7.22.10", | ||
"babel-jest": "^29.6.2", | ||
"eslint": "^8.46.0", | ||
"jest": "^29.6.2", | ||
"nodemon": "^2.0.20", | ||
"prettier": "^2.8.8" | ||
}, | ||
"dependencies": { | ||
"@commercetools-backend/loggers": "^21.19.0", | ||
"@commercetools/platform-sdk": "^4.1.0", | ||
"@commercetools/sdk-client-v2": "^2.2.0", | ||
"body-parser": "^1.20.1", | ||
"dotenv": "^16.0.3", | ||
"express": "4.18.2", | ||
"supertest": "^6.3.3", | ||
"validator": "^13.11.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,15 @@ | ||
import { logger } from '../utils/logger.utils.js'; | ||
|
||
export const syncHandler = async (request, response) => { | ||
try { | ||
|
||
// TODO: implement | ||
} catch (err) { | ||
logger.error(err); | ||
if (err.statusCode) return response.status(err.statusCode).send(err); | ||
return response.status(500).send(err); | ||
} | ||
|
||
// Return the response for the client | ||
return response.status(200).send(); | ||
}; |
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,28 @@ | ||
import 'dotenv/config'; | ||
|
||
import express from 'express'; | ||
import bodyParser from 'body-parser'; | ||
|
||
// Import routes | ||
import SyncRoutes from './routes/sync.route.js'; | ||
import { logger } from './utils/logger.utils.js'; | ||
|
||
const PORT = 8080; | ||
|
||
// Create the express app | ||
const app = express(); | ||
|
||
// Define configurations | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
|
||
// Define routes | ||
// TODO: Give a specific route name | ||
app.use('/', SyncRoutes); | ||
|
||
// Listen the application | ||
const server = app.listen(PORT, () => { | ||
logger.info(`⚡️ Event application listening on port ${PORT}`); | ||
}); | ||
|
||
export default server; |
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 { Router } from 'express'; | ||
|
||
import { syncHandler } from '../controllers/sync.controller.js'; | ||
|
||
const syncRouter = Router(); | ||
|
||
// TODO: Give a specific route name | ||
syncRouter.post('/', syncHandler); | ||
|
||
export default syncRouter; |
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,3 @@ | ||
import { createApplicationLogger } from '@commercetools-backend/loggers'; | ||
|
||
export const logger = createApplicationLogger(); |
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,37 @@ | ||
{ | ||
"name": "tax-calculator", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"main": "src/index.js", | ||
"private": true, | ||
"scripts": { | ||
"start": "node src/index.js", | ||
"start:dev": "node_modules/.bin/nodemon -q src/index.js", | ||
"lint": "node_modules/.bin/eslint src --ext .js", | ||
"prettier": "node_modules/.bin/prettier --write '**/*.{js,ts}'", | ||
"test": "echo Comment: It is npm command dedicated for running test in connect service", | ||
"test:ci": "node_modules/.bin/jest --config jest.config.cjs" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@babel/core": "^7.22.10", | ||
"@babel/preset-env": "^7.22.10", | ||
"babel-jest": "^29.6.2", | ||
"eslint": "^8.46.0", | ||
"jest": "^29.6.2", | ||
"nodemon": "^2.0.20", | ||
"prettier": "^2.8.8" | ||
}, | ||
"dependencies": { | ||
"@commercetools-backend/loggers": "^21.19.0", | ||
"@commercetools/platform-sdk": "^4.1.0", | ||
"@commercetools/sdk-client-v2": "^2.2.0", | ||
"body-parser": "^1.20.1", | ||
"dotenv": "^16.0.3", | ||
"express": "4.18.2", | ||
"supertest": "^6.3.3", | ||
"validator": "^13.11.0" | ||
} | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
tax-calculator/src/controllers/tax.calculator.controller.js
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,15 @@ | ||
import { logger } from '../utils/logger.utils.js'; | ||
|
||
export const taxHandler = async (request, response) => { | ||
try { | ||
|
||
// TODO: implement | ||
} catch (err) { | ||
logger.error(err); | ||
if (err.statusCode) return response.status(err.statusCode).send(err); | ||
return response.status(500).send(err); | ||
} | ||
|
||
// Return the response for the client | ||
return response.status(200).send(); | ||
}; |
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,27 @@ | ||
import 'dotenv/config'; | ||
|
||
import express from 'express'; | ||
import bodyParser from 'body-parser'; | ||
|
||
// Import routes | ||
import SyncRoutes from './routes/tax.calculator.route.js'; | ||
import { logger } from './utils/logger.utils.js'; | ||
|
||
const PORT = 8080; | ||
|
||
// Create the express app | ||
const app = express(); | ||
|
||
// Define configurations | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
|
||
// Define routes | ||
app.use('/', SyncRoutes); | ||
|
||
// Listen the application | ||
const server = app.listen(PORT, () => { | ||
logger.info(`⚡️ Event application listening on port ${PORT}`); | ||
}); | ||
|
||
export default server; |
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 { Router } from 'express'; | ||
|
||
import {taxHandler} from '../controllers/tax.calculator.controller.js'; | ||
|
||
const syncRouter = Router(); | ||
|
||
// TODO: Give a specific route name | ||
syncRouter.post('/', taxHandler); | ||
|
||
export default syncRouter; |
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,3 @@ | ||
import { createApplicationLogger } from '@commercetools-backend/loggers'; | ||
|
||
export const logger = createApplicationLogger(); |