From eff15f2c56c0b0dc1fe248c21e9bb481092dd619 Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:08:08 +0530 Subject: [PATCH 1/8] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..6cdebaf --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} From a34bca3ae98c32745e3c738e5c185931eabe4191 Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:09:06 +0530 Subject: [PATCH 2/8] Create datadog-synthetics.yml --- .github/workflows/datadog-synthetics.yml | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/datadog-synthetics.yml diff --git a/.github/workflows/datadog-synthetics.yml b/.github/workflows/datadog-synthetics.yml new file mode 100644 index 0000000..f7cb687 --- /dev/null +++ b/.github/workflows/datadog-synthetics.yml @@ -0,0 +1,38 @@ +# This workflow will trigger Datadog Synthetic tests within your Datadog organisation +# For more information on running Synthetic tests within your GitHub workflows see: https://docs.datadoghq.com/synthetics/cicd_integrations/github_actions/ + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# To get started: + +# 1. Add your Datadog API (DD_API_KEY) and Application Key (DD_APP_KEY) as secrets to your GitHub repository. For more information, see: https://docs.datadoghq.com/account_management/api-app-keys/. +# 2. Start using the action within your workflow + +name: Run Datadog Synthetic tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # Run Synthetic tests within your GitHub workflow. + # For additional configuration options visit the action within the marketplace: https://github.com/marketplace/actions/datadog-synthetics-ci + - name: Run Datadog Synthetic tests + uses: DataDog/synthetics-ci-github-action@2b56dc0cca9daa14ab69c0d1d6844296de8f941e + with: + api_key: ${{secrets.DD_API_KEY}} + app_key: ${{secrets.DD_APP_KEY}} + test_search_query: 'tag:e2e-tests' #Modify this tag to suit your tagging strategy + + From f048576feab0915eac6971eb89fa1ab27ef71a03 Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:09:30 +0530 Subject: [PATCH 3/8] Create deno.yml --- .github/workflows/deno.yml | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/deno.yml diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 0000000..c208d26 --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will install Deno then run `deno lint` and `deno test`. +# For more information see: https://github.com/denoland/setup-deno + +name: Deno + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Setup repo + uses: actions/checkout@v3 + + - name: Setup Deno + # uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2 + with: + deno-version: v1.x + + # Uncomment this step to verify the use of 'deno fmt' on each commit. + # - name: Verify formatting + # run: deno fmt --check + + - name: Run linter + run: deno lint + + - name: Run tests + run: deno test -A From 03c596e23f0c0b1c0bdd64b249eb9bc438bac92e Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:10:33 +0530 Subject: [PATCH 4/8] Delete .github/workflows/datadog-synthetics.yml --- .github/workflows/datadog-synthetics.yml | 38 ------------------------ 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/datadog-synthetics.yml diff --git a/.github/workflows/datadog-synthetics.yml b/.github/workflows/datadog-synthetics.yml deleted file mode 100644 index f7cb687..0000000 --- a/.github/workflows/datadog-synthetics.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflow will trigger Datadog Synthetic tests within your Datadog organisation -# For more information on running Synthetic tests within your GitHub workflows see: https://docs.datadoghq.com/synthetics/cicd_integrations/github_actions/ - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# To get started: - -# 1. Add your Datadog API (DD_API_KEY) and Application Key (DD_APP_KEY) as secrets to your GitHub repository. For more information, see: https://docs.datadoghq.com/account_management/api-app-keys/. -# 2. Start using the action within your workflow - -name: Run Datadog Synthetic tests - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - # Run Synthetic tests within your GitHub workflow. - # For additional configuration options visit the action within the marketplace: https://github.com/marketplace/actions/datadog-synthetics-ci - - name: Run Datadog Synthetic tests - uses: DataDog/synthetics-ci-github-action@2b56dc0cca9daa14ab69c0d1d6844296de8f941e - with: - api_key: ${{secrets.DD_API_KEY}} - app_key: ${{secrets.DD_APP_KEY}} - test_search_query: 'tag:e2e-tests' #Modify this tag to suit your tagging strategy - - From 3243cecea9bf9489779f2ac798a2f2697dab4c8e Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:10:45 +0530 Subject: [PATCH 5/8] Delete .github/workflows/deno.yml --- .github/workflows/deno.yml | 42 -------------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/deno.yml diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml deleted file mode 100644 index c208d26..0000000 --- a/.github/workflows/deno.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow will install Deno then run `deno lint` and `deno test`. -# For more information see: https://github.com/denoland/setup-deno - -name: Deno - -on: - push: - branches: ["main"] - pull_request: - branches: ["main"] - -permissions: - contents: read - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Setup repo - uses: actions/checkout@v3 - - - name: Setup Deno - # uses: denoland/setup-deno@v1 - uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2 - with: - deno-version: v1.x - - # Uncomment this step to verify the use of 'deno fmt' on each commit. - # - name: Verify formatting - # run: deno fmt --check - - - name: Run linter - run: deno lint - - - name: Run tests - run: deno test -A From 57fa9b8d89fc0e9fc4ca60266e4565a7b0f87754 Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:44:21 +0530 Subject: [PATCH 6/8] Update database.js --- database.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/database.js b/database.js index 43e3342..24113c6 100644 --- a/database.js +++ b/database.js @@ -1,9 +1,6 @@ var sqlite3 = require('sqlite3').verbose() var md5 = require('md5') - const DBSOURCE = "db.sqlite" - - let db = new sqlite3.Database(DBSOURCE, (err) => { if (err) { // Cannot open database @@ -37,9 +34,21 @@ let db = new sqlite3.Database(DBSOURCE, (err) => { db.run(`CREATE TABLE suppliers ( id INTEGER PRIMARY KEY AUTOINCREMENT, supplierName text, + db.run(`CREATE TABLE customer ( + customerId INTEGER PRIMARY KEY AUTOINCREMENT, + name text, address text, joinedDate text, mobileNo text + email text, + dateOfBirth text, + gender text, + age INTEGER, + cardHolderName text, + cardNumber INTEGER, + expiryDate text, + cvv INTERGER, + timeStamp text )`, (err) => { if (err) { // Table already created @@ -48,6 +57,8 @@ let db = new sqlite3.Database(DBSOURCE, (err) => { var insert = 'INSERT INTO suppliers (supplierName, address, joinedDate, mobileNo) VALUES (?,?,?,?)' db.run(insert, ["D.J.Ishara", "345A ,R.A De Mel Road, Colombo 3", "16/3/2022", "0776600933"]) + var insert = 'INSERT INTO customer (name, address, email, dateOfBirth, gender, age, cardHolderName, cardNumber, expiryDate, cvv,timeStamp) VALUES (?,?,?,?,?,?,?,?,?,?,?)' + db.run(insert, ["Jayantha De Silva", "345, Galle Road, Colombo 4", "customer2022@gmail.com", "2000.04.14", "Male", 22, "Laxshman Perera", 102030405060, "12/2023",888,"2022-12-31 23:59:59"]) } }) @@ -57,4 +68,3 @@ let db = new sqlite3.Database(DBSOURCE, (err) => { }) module.exports = db - From 70323020bc7ca812c624d8a4ba59f5252139d24c Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:46:08 +0530 Subject: [PATCH 7/8] Update server.js --- server.js | 84 +++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/server.js b/server.js index 9e2f78d..3a65808 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,6 @@ var bodyParser = require("body-parser"); const { request, response } = require("express"); app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); - let HTTP_PORT = 8080 const cors = require('cors'); app.use(cors({ @@ -125,6 +124,21 @@ app.post("/api/products/", (req, res, next) => { var sql = 'INSERT INTO products (productName, description, category, brand, expiredDate, manufacturedDate, batchNumber, unitPrice, quantity, createdDate) VALUES (?,?,?,?,?,?,?,?,?,?)' var params = [productName, description, category, brand, expiredDate, manufacturedDate, batchNumber, unitPrice, quantity, createdDate] + const { name, + address, + email, + dateOfBirth, + gender, + age, + cardHolderName, + cardNumber, + expiryDate, + cvv, + timeStamp + } = req.body; + + var sql = 'INSERT INTO customer (name, address, email, dateOfBirth, gender, age, cardHolderName, cardNumber, expiryDate, cvv,timeStamp) VALUES (?,?,?,?,?,?,?,?,?,?,?)' + var params = [name, address, email, dateOfBirth, gender, age, cardHolderName, cardNumber, expiryDate, cvv,timeStamp] db.run(sql, params, function (err, result) { if (err) { @@ -133,14 +147,14 @@ app.post("/api/products/", (req, res, next) => { } else { res.json({ "message": "success", + "message": "customer $name has registered", "data": req.body, "id": this.lastID + "customerId": this.lastID }) } - }); - } catch (E) { - res.status(400).send(E); +@@ -144,26 +60,24 @@ app.post("/api/products/", (req, res, next) => { } }); @@ -160,73 +174,58 @@ app.put("/api/products/", (req, res, next) => { unitPrice, quantity, createdDate + customerId, + name, + address, + email, + dateOfBirth, + gender, + age, + cardHolderName, + cardNumber, + expiryDate, + cvv, + timeStamp } = req.body; db.run(`UPDATE products set productName = ?, description = ?, category = ?, brand = ?,expiredDate=?,manufacturedDate=?,batchNumber=?,unitPrice=?,quantity=?,createdDate=? WHERE id = ?`, [productName, description, category, brand, expiredDate, manufacturedDate, batchNumber, unitPrice, quantity, createdDate, id], + db.run(`UPDATE customer. set name = ?, address = ?, email = ?, dateOfBirth = ?, gender=?,age=?,cardHolderName=?,cardNumber=?,expiryDate=?,cvv=?,timeStamp=? WHERE customerId = ?`, + [name,address,email,dateOfBirth,gender,age,cardHolderName,cardNumber,expiryDate,cvv,timeStamp,customerId], function (err, result) { if (err) { res.status(400).json({ "error": res.message }) - return; - } - res.status(200).json({ updated: this.changes }); - }); -}); - - +@@ -177,7 +91,7 @@ app.put("/api/products/", (req, res, next) => { app.delete("/api/products/delete/:id", (req, res, next) => { try { db.run( 'DELETE FROM products WHERE id = ?', + 'DELETE FROM customer WHERE customerId = ?', req.params.id, function (err, result) { if (err) { - res.status(400).json({ "error": res.message }) - return; - } - res.json({ "message": "deleted", rows: this.changes }) - }); - } catch (E) { - res.status(400).send(E); - } -}); - +@@ -194,7 +108,7 @@ app.delete("/api/products/delete/:id", (req, res, next) => { app.delete("/api/products/deleteAll/:id", (req, res, next) => { try { db.run( 'DELETE FROM products WHERE id > ?', + 'DELETE FROM customer WHERE customerId = ?', req.params.id, function (err, result) { if (err) { - res.status(400).json({ "error": res.message }) - return; - } - res.json({ "message": "deleted", rows: this.changes }) - }); - } catch (E) { - res.status(400).send(E); - } +@@ -209,9 +123,9 @@ app.delete("/api/products/deleteAll/:id", (req, res, next) => { }); app.get("/api/suppliers/", (req, res, next) => { +app.get("/api/products/", (req, res, next) => { try { var sql = "select * from suppliers" + var sql = "select * from customer" var params = [] db.all(sql, params, (err, rows) => { if (err) { - res.status(400).json({ "error": err.message }); - return; - } - res.json({ - "message": "success", - "data": rows - }) - }); - } catch (E) { - res.status(400).send(E); - } - +@@ -230,61 +144,7 @@ app.get("/api/suppliers/", (req, res, next) => { }); @@ -287,4 +286,5 @@ app.delete("/api/suppliers/deleteAll/:id", (req, res, next) => { // Root path app.get("/", (req, res, next) => { res.json({ "message": "University of Moratuwa" }) -}); \ No newline at end of file +}); +}); From b196cbe70b628eb87a7424f29f8876d83024099c Mon Sep 17 00:00:00 2001 From: MN Fathima Riham <90144970+rihamnazeer@users.noreply.github.com> Date: Tue, 3 Oct 2023 09:41:37 +0530 Subject: [PATCH 8/8] Update database.js