diff --git a/.github/workflows/manual.yml b/.github/workflows/manual-gcp-expressjs.yml similarity index 94% rename from .github/workflows/manual.yml rename to .github/workflows/manual-gcp-expressjs.yml index 47035ced..be43f482 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual-gcp-expressjs.yml @@ -4,7 +4,7 @@ # actions appear from default branch - https://github.community/t/workflow-files-only-picked-up-from-master/16129/2 # manual workflow for js-node/expressjs -name: Manual workflow +name: Manual ExpressJS to GCP CloudRun workflow # Controls when the action will run. Workflow runs when manually triggered using the UI # or API. @@ -23,8 +23,8 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "greet" - greet: + # This workflow contains a single job called "deploy_to_cloudrun" + deploy_to_cloudrun: # The type of runner that the job will run on runs-on: ubuntu-latest # container: node:lts diff --git a/.github/workflows/manual-gcp-vue-vite.yml b/.github/workflows/manual-gcp-vue-vite.yml new file mode 100644 index 00000000..5a6ca38f --- /dev/null +++ b/.github/workflows/manual-gcp-vue-vite.yml @@ -0,0 +1,65 @@ +# This is a basic workflow that is manually triggered +# try to use as much shell scripting a possible +# actions appear from default branch - https://github.community/t/workflow-files-only-picked-up-from-master/16129/2 + +# manual workflow for js-node/expressjs +name: Manual Vue Vite to GCP Cloud Storage workflow + +# Controls when the action will run. Workflow runs when manually triggered using the UI +# or API. +on: + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + environment: + description: 'The environment (uat, prod)' + default: 'uat' + required: true + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "deploy_to_cloudrun" + deploy_to_cloudstorage: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # container: node:lts + strategy: + matrix: + node: [ '14' ] + + name: Deploying js-web/vue-vite - ${{ github.event.inputs.environment }}... Using Node ${{ matrix.node }} + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - uses: google-github-actions/setup-gcloud@master + with: + version: 'latest' + project_id: ${{ secrets.GCP_PROJECT_ID }} + service_account_key: ${{ secrets.GCP_SA_KEY }} + export_default_credentials: true + - uses: actions/checkout@v2 + # with: + # ref: if_you_need_to_specify_a_branch + - name: Show checkout branch name + run: echo checking out on branch ${GITHUB_REF##*/} + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + check-latest: false + - name: Make shell script executable + run: | + chmod +x ./js-web/vue-vite/deploy.sh + # Runs a single command using the runners shell + - name: Initiate Deployment + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} + GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} + # # VAULT_ to VAULT + # VAULT: ${{ secrets[format('VAULT_{0}', github.event.inputs.environment)] }} + run: | + # gcloud info + echo "CI: $CI" + echo "Branch: ${GITHUB_REF##*/}" + echo "Environment: ${{ github.event.inputs.environment }}" + cd js-web/vue-vite + ./deploy.sh ${{ github.event.inputs.environment }} diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/manual-gh-pages.yml similarity index 84% rename from .github/workflows/gh-pages.yml rename to .github/workflows/manual-gh-pages.yml index 43fabbc6..3d3faacb 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/manual-gh-pages.yml @@ -1,5 +1,5 @@ +# https://ais-one.github.io/cookbook -# TBD - to test # https://dev.to/rolanddoda/deploy-to-github-pages-like-a-pro-with-github-actions-4hdg # notes: # set package.json "homepage": "/name-of-your-project/", @@ -17,23 +17,22 @@ on: inputs: environment: description: 'The environment (uat, production)' - default: 'production' + default: 'uat' required: true defaults: run: - # abc/def working-directory: js-web/vue-vite jobs: - gh-pages-deploy: + gh-pages-deploy1: name: Deploying to gh-pages runs-on: ubuntu-latest steps: - name: Setup Node.js for use with actions - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: - version: 14.x + node-version: 14.x - name: Checkout branch uses: actions/checkout@v2 - name: Show checkout branch name @@ -44,18 +43,23 @@ jobs: # run: chmod +x deploy.sh # - name: Initiate Deployment # ./deploy.sh ${{ github.event.inputs.environment }} +# DOES NOT WORK THIS WAY +# gh-pages-deploy2: +# name: Deploying to gh-pages 2 +# runs-on: ubuntu-latest +# needs: [gh-pages-deploy1] +# steps: - name: Run deploy script # remember to change user.name and user.email - # TBD npx vite build -- mode ${{ github.event.inputs.environment }} run: | git config user.name "Your username" && git config user.email "your email" git checkout --orphan gh-pages - npm run build + npx vite build --mode ${{ github.event.inputs.environment }} git --work-tree dist add --all git --work-tree dist commit -m 'Deploy' git push origin HEAD:gh-pages --force rm -r dist - git checkout -f master + git checkout -f ${GITHUB_REF##*/} git branch -D gh-pages diff --git a/@es-labs/esm/bwc-table.js b/@es-labs/esm/bwc-table.js index 6eedfa86..4c9496e1 100644 --- a/@es-labs/esm/bwc-table.js +++ b/@es-labs/esm/bwc-table.js @@ -577,7 +577,7 @@ class Table extends HTMLElement { parent.remove() } - if (typeof this.#columns === 'object') { + if (this.#columns && typeof this.#columns === 'object') { // console.log('render thead') table = document.createElement('table') table.setAttribute('id', 'table') @@ -664,7 +664,7 @@ class Table extends HTMLElement { } // populate the data - if (typeof this.#items === 'object' && this.#items.length) { + if (this.#items && typeof this.#items === 'object' && this.#items.length) { // console.log('render tbody') const tbody = document.createElement('tbody') // TBD function to get checked rows... diff --git a/@es-labs/esm/package.json b/@es-labs/esm/package.json index 1ab33dc3..a13ac65a 100644 --- a/@es-labs/esm/package.json +++ b/@es-labs/esm/package.json @@ -1,6 +1,6 @@ { "name": "@es-labs/esm", - "version": "0.0.5", + "version": "0.0.6", "author": "Aaron Gong", "license": "MIT", "repository": { diff --git a/@es-labs/node/package.json b/@es-labs/node/package.json index b91c717b..7c541b0d 100644 --- a/@es-labs/node/package.json +++ b/@es-labs/node/package.json @@ -1,6 +1,6 @@ { "name": "@es-labs/node", - "version": "0.0.5", + "version": "0.0.6", "author": "Aaron Gong", "license": "MIT", "repository": { diff --git a/BACKLOG.md b/BACKLOG.md index 0668c418..a5600ba5 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -3,8 +3,8 @@ Always finding new things to implement / improve in this list! ### For next sprint / version +- [@es-labs/node] allow options to be passed in also, currently uses global.CONFIG through (**@es-labs/node/config**) - [js-node/expressjs] scale websockets... https://pushpin.org/ -- [js-web/vue-vite] add sentry when ready - [js-web/vue-vite] cypress e2e testing - [chore] migration to node 16 and npm 7 - [chore] update webauthnsimple to v3 @@ -13,7 +13,6 @@ Always finding new things to implement / improve in this list! ### For future product improvement - [@es-labs/esm/bwc-combobox.js] - enhancement: replace datalist (so can check multiple times on dropdown instead of closing after each check) - [@es-labs/esm/bwc-t4t-form.js] - handle multiple parent values use case of combobox..., handle reset of multiple child columns -- [fix] - ==='object' - handle null object - [backend-deployment] GKE, Kubernetes - [frontend] aria - [frontend] react example diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c2dce3..d45f8a9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### Version 0.6.3 +- [chore] update packages & cleanup & work on improving documentation +- [chore] improve github workflow and documentation +- [js-web/vue-vite] add sentry when ready +- [fix] typeof xx === 'object' - handle if xx is null +- [js-node/expressjs] make deployment application specific also, moved **deploy** folder to [js-node/expressjs/apps/app-template](js-node/expressjs/apps/app-template), migration and seeding, and GCP deployment config adjusted to address the folder location change + ### Version 0.6.2 - [chore] rename project diff --git a/README.md b/README.md index 66d2cde9..8710b054 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,7 @@ > **TL;DR** ExpressJS, VueJS cookbook, with evergreen recipes and templates (CRUD, CI/CD, Cloud container deployment, Web Components, ES Modules) to develop applications faster, while reducing the need for rewrite or refactoring due to changes in dependencies. -**NOTE!** project name vue-crud-x changed to cookbook - -Latest Version [0.6.2](https://github.com/ais-one/cookbook/releases/tag/0.6.2) - Released 2021 July 23 1230 +8GMT +Latest Version [0.6.3](https://github.com/ais-one/cookbook/releases/tag/0.6.3) - Released 2021 July 25 1215 +8GMT Considerations for this project are similar to [favv](https://github.com/ais-one/favv/blob/master/README.md#considerations). The difference between them are: - this repo is more of a cookbook and recipes are constantly being improved and updated @@ -74,16 +72,16 @@ npm i ../@es-labs/node ```bash # create and seed relational db on SQLite, (delete the dev.sqlite file each time before you run this) -# command: npm run knex -- -npm run knex -- development migrate -npm run knex -- development seed +# command: npm run knex -- +npm run knex -- development app-template migrate +npm run knex -- development app-template seed # create and seed MongoDB requires MongoDB - you can skip this but MongoDB examples will not work -# command: npm run mongo -- -npm run mongo -- development seed +# command: npm run mongo -- +npm run mongo -- development app-template seed # run the backend -# command: npm run app -- +# command: npm run app -- npm run app -- development # or npm run app:lint to include eslint checks @@ -113,19 +111,9 @@ npm run test ### Long Running Processes -Codes for long running processes such as tcp server (event mode, streaming mode), serial server, kafka producer, consumer, cron-triggered process, etc. - -``` -cd js-node/wip - -# Command to simulate long running process (do take note of caveats, for production need a monitor to handle restart strategy) -# command: npm run process-long -- development -npm run process-long +For long running processes such as tcp server (event mode, streaming mode), serial server, kafka producer, consumer, cron-triggered process, etc. -# Command to simulate process triggered by cron (**NOTE:** may be better to use cron to call API than trigger a process) -# command: npm run process-cron -- development -npm run process-cron -``` +See [js-node/README.md](js-node/README.md) --- @@ -198,16 +186,35 @@ You can override the configurations using .env.js files, e.g. **develo +- rest-cmd.http : rest commands for testing ``` -## CI/CD +## CI/CD & Cloud Deployment + +### Cloud Services + +The following Google Cloud Platform services are used +- Container Registry +- Cloud Run +- Cloud Storage + +Refer to [doc/deployment/home.md](doc/deployment/home.md) for documentation on deployments -Using github actions, deploy to GCP Cloud +### Deployment Using Github Actions -Manually triggered deployment on .github/workflows/manual.yml +- .github/workflows/manual-gcp-expressjs.yml (Manually deploy js-node/expressjs to GCP CloudRun) + - selectable inputs + - environment (uat for now, development does not deploy anything) + - service (default = app-template) + - branch +- .github/workflows/manual-gcp-vue-vite.yml (Manually deploy js-web/vue-vite to GCP Cloud Storage) + - selectable inputs + - environment (uat for now, development does not deploy anything) + - csutom_app (to be implemented) + - branch +- .github/workflows/manual-gh-pages.yml (Manually deploy js-web/vue-vite to Github Pages) + - selectable inputs + - environment (uat for now, development does not deploy anything) + - csutom_app (to be implemented) + - branch -selectable inputs -- environment (uat for now, development does not deploy anything) -- application (js-node/expressjs, js-web/vue-vite) -- code branch **NOTE** config/secret contents will not be in repo for CI/CD (so you can get errors), those should be put in VAULT @@ -229,7 +236,7 @@ VAULT={ secrets: { ... all your secrets here } } # base64 encoded ## VERSION CHANGE NOTES -- **v0.6+** Improve organization, graceful exit, logging, project rename, add more nodejs applications +- **v0.6+** Improve organization, graceful exit, logging, project rename, add more nodejs applications, repo name vue-crud-x changed to cookbook - **v0.5+** Improve organization and authentication, add new features - **v0.4+** Improve folders and structure organization, handle CI/CD better - **v0.3+** Reorganize folders and structure, for ease of developing and maintaining multiple applications. diff --git a/docs/deployment/home.md b/docs/deployment/home.md index 085de684..30a2dc20 100644 --- a/docs/deployment/home.md +++ b/docs/deployment/home.md @@ -80,12 +80,6 @@ deploy.sh uat --- -## Github Actions Deploymen - -See **.github/workflows/manual.yml** - ---- - # SCALING & DEPLOYMENT STRATEGIES There should always be alternatives to the service you are using. diff --git a/docs/sample.sh b/docs/sample.sh index 774e6bc2..abacb2eb 100644 --- a/docs/sample.sh +++ b/docs/sample.sh @@ -1,4 +1,7 @@ #!/bin/bash + +# THIS SCRIPT DOES NOT WORK - IT IS JUST A SAMPLE FOR LEARNING BASH COMMANDS + # $0. The name of script itself. # $$ Process id of current shell. # $* Values of all the arguments. ... diff --git a/docs/web/js.md b/docs/web/js.md index 3e5f02da..f1bdd711 100644 --- a/docs/web/js.md +++ b/docs/web/js.md @@ -30,6 +30,32 @@ const x2 = num => num * 2 compose(inc, x2)(5) // return value should be (5 * 2) + 1 = 11 ``` +### Truthy, falsy & typeof + +- Typeof + +```js +typeof null === 'object' +typeof [] === 'object' +typeof {} === 'object' +typeof '' === 'string' +typeof function () {} === 'function' +typeof 1 === 'number' +typeof true === 'boolean' +typeof undefined === 'undefined' +``` + +- Falsy + +``` +null, false, 0, undefined, '' +``` + +- Truthy + +``` +true, 1, 'a', [], {}, () => {}), +``` ### ES2020 diff --git a/js-node/README.md b/js-node/README.md index aff5fbb6..38b8298b 100644 --- a/js-node/README.md +++ b/js-node/README.md @@ -1,6 +1,7 @@ # Description -Projects +Below are a list of NodeJS applications + - expressjs - see [expressjs/README.md](expressjs/README.md) - openapi-file-joiner @@ -27,6 +28,26 @@ Projects - process-cron.js - process-long.js + +## + +To test out + +``` +cd js-node/wip + +# Command to simulate long running process (do take note of caveats, for production need a monitor to handle restart strategy) +# command: npm run process-long -- development +npm run process-long + +# Command to simulate process triggered by cron (**NOTE:** may be better to use cron to call API than trigger a process) +# command: npm run process-cron -- development +npm run process-cron +``` + + + + # Useful commands redirect to a file with date diff --git a/js-node/expressjs/README.md b/js-node/expressjs/README.md index 0df17983..57b14ab3 100644 --- a/js-node/expressjs/README.md +++ b/js-node/expressjs/README.md @@ -1,3 +1,52 @@ +## Project Strcuture + +``` ++- apps : custom apps are here in this folder +| +- app-template/ : sample custom application (prefixed with app) +| | +- config/ : application configs (see README.md within the config folder) +| | +- controllers/ +| +- deploy/ : deployment folder (see README.md within the deploy folder) +| | +- db/ : for seeding and migrating data +| | | +- knex/ +| | | | +- migrations/ +| | | | +- seeds/ +| | | +- mongo/ +| | +- models/ +| | +- openapi/ : OpenAPI yaml files +| | +- routes/ : application REST API & websocket setup +| | +- services/ : services used +| | +- tables/ : configurable table & crud +| | +- tests/ : Jest tests +| | +- graphql-schema.js : application GraphQL schemas and resolvers +| +- app-custom/ : your custom app, put under source control (app-* is git ignored) ++- common/ : common express setup ++- jobs/ : message queue jobs ++- logs/ ++- middlewares/ ++- public/ : for serving static files - website +| +- demo-express/ (127.0.0.1/) ++- router/ ++- sandbox/ : Useful scripts ++- uploads/ : for serving static files - files ++- .dockerignore ++- .eslintrc.js ++- .gitignore ++- app.js : the express app boilerplate ++- deploy-vm.sh: VM deployment script ++- deploy.sh: GCP deployment script ++- docker-compose.yml ++- Dockerfile ++- ecosystem.config.js ++- index.js ++- jest.config.js: JEST testing ++- knexfile.js: Knex query builder ++- package.json ++- README.md ++- test.py: run python from express + +``` + + ## Relational Database Schema ### Simple Relation @@ -61,46 +110,4 @@ * POST /books/:id/authors/:authorId - relate author to book * DELETE /books/:id/authors/:authorId - unrelate author to book -# Project Strcuture - -``` -+- apps : custom apps are here in this folder -| +- app-template/ : sample custom application (prefixed with app) -| | +- controllers/ -| | +- models/ -| | +- routes/ : rest API & websocket setup -| | +- tests/ : Jest tests -| +- app-custom/ : your custom app, put under source control (app-* is git ignored) -+- common/ : common express setup -+- config/ : centralized config folder (see README.md within the config folder) -+- deploy/ : deployment folder (see README.md within the deploy folder) -| +- db/ : for seeding and migrating data -| +- knex/ -| | +- migrations/ -| | +- seeds/ -| +- mongo/ -+- jobs/ : message queue jobs -+- logs/ -+- middlewares/ -+- public/ : for serving static files - website -| +- demo-express/ (127.0.0.1/) -+- router/ -+- sandbox/ : Useful scripts -+- uploads/ : for serving static files - files -+- .dockerignore -+- .eslintrc.js -+- .gitignore -+- app.js : the express app boilerplate -+- deploy-vm.sh: VM deployment script -+- deploy.sh: GCP deployment script -+- docker-compose.yml -+- Dockerfile -+- ecosystem.config.js -+- index.js -+- jest.config.js: JEST testing -+- knexfile.js: Knex query builder -+- package.json -+- README.md -+- test.py: run python from express -``` \ No newline at end of file diff --git a/js-node/expressjs/apps/app-template/.gitignore b/js-node/expressjs/apps/app-template/.gitignore index 85946fbb..543ff37b 100644 --- a/js-node/expressjs/apps/app-template/.gitignore +++ b/js-node/expressjs/apps/app-template/.gitignore @@ -1,3 +1,8 @@ # configs config/secret/* !config/secret/README.md + +# deploy +deploy/* +!deploy/README.md +!deploy/db diff --git a/js-node/expressjs/deploy/README.md b/js-node/expressjs/apps/app-template/deploy/README.md similarity index 100% rename from js-node/expressjs/deploy/README.md rename to js-node/expressjs/apps/app-template/deploy/README.md diff --git a/js-node/expressjs/deploy/db/icc.json b/js-node/expressjs/apps/app-template/deploy/db/icc.json similarity index 100% rename from js-node/expressjs/deploy/db/icc.json rename to js-node/expressjs/apps/app-template/deploy/db/icc.json diff --git a/js-node/expressjs/apps/app-template/deploy/db/knex/index.js b/js-node/expressjs/apps/app-template/deploy/db/knex/index.js new file mode 100644 index 00000000..513f4089 --- /dev/null +++ b/js-node/expressjs/apps/app-template/deploy/db/knex/index.js @@ -0,0 +1,14 @@ +console.log('Usage - npm run knex -- development app-template ') +// console.log(process.argv.length, process.argv) + +if (process.argv.length >= 5) { + if (process.argv[4] === 'migrate') { + console.log('migrate') + require('./migrations') + } else if (process.argv[4] === 'seed') { + console.log('seeding') + require('./seeds') + } else { + console.log('unknown', process.argv) + } +} diff --git a/js-node/expressjs/deploy/db/knex/migrations/20180927133438_create_users.js b/js-node/expressjs/apps/app-template/deploy/db/knex/migrations/20180927133438_create_users.js similarity index 100% rename from js-node/expressjs/deploy/db/knex/migrations/20180927133438_create_users.js rename to js-node/expressjs/apps/app-template/deploy/db/knex/migrations/20180927133438_create_users.js diff --git a/js-node/expressjs/deploy/db/knex/migrations/20181022165031_create_test.js b/js-node/expressjs/apps/app-template/deploy/db/knex/migrations/20181022165031_create_test.js similarity index 79% rename from js-node/expressjs/deploy/db/knex/migrations/20181022165031_create_test.js rename to js-node/expressjs/apps/app-template/deploy/db/knex/migrations/20181022165031_create_test.js index ab179c59..f11c7a9e 100644 --- a/js-node/expressjs/deploy/db/knex/migrations/20181022165031_create_test.js +++ b/js-node/expressjs/apps/app-template/deploy/db/knex/migrations/20181022165031_create_test.js @@ -19,7 +19,6 @@ exports.up = async (knex) => { table.increments('id').primary() table.string('content') table.integer('bookId').references('books.id') - // table.integer('ownerId').unsigned().references('id').inTable('persons').onDelete('SET NULL'); table.timestamps(true, true) }) await knex.schema @@ -31,11 +30,8 @@ exports.up = async (knex) => { }) await knex.schema .createTable('books_authors', (table) => { // many books, many authors - // table.increments('id').primary() table.integer('bookId').unsigned().references('books.id') - // table.integer('bookId').unsigned().references('id').inTable('books').onDelete('CASCADE') table.integer('authorId').unsigned().references('authors.id') - // table.integer('authorId').unsigned().references('id').inTable('authors').onDelete('CASCADE') table.unique(['bookId', 'authorId']) // remove this and you will have duplicates }) @@ -92,30 +88,3 @@ exports.down = async (knex) => { await knex.schema.dropTableIfExists('person') await knex.schema.dropTableIfExists('grade') } - - -/* bookshelf -var Book = bookshelf.Model.extend({ - tableName: 'books', - authors: function() { - return this.belongsToMany(Author); - }, - pages: function() { - return this.hasMany(Page); - } -}); - -var Page = bookshelf.Model.extend({ - tableName: 'pages', - book: function() { - return this.belongsTo(Book); - } -}); - -var Author = bookshelf.Model.extend({ - tableName: 'authors', - books: function() { - return this.belongsToMany(Book); - } -}); -*/ \ No newline at end of file diff --git a/js-node/expressjs/deploy/db/knex/migrations/index.js b/js-node/expressjs/apps/app-template/deploy/db/knex/migrations/index.js similarity index 100% rename from js-node/expressjs/deploy/db/knex/migrations/index.js rename to js-node/expressjs/apps/app-template/deploy/db/knex/migrations/index.js diff --git a/js-node/expressjs/deploy/db/knex/seeds/development/seed_test.js b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/development/seed_test.js similarity index 100% rename from js-node/expressjs/deploy/db/knex/seeds/development/seed_test.js rename to js-node/expressjs/apps/app-template/deploy/db/knex/seeds/development/seed_test.js diff --git a/js-node/expressjs/deploy/db/knex/seeds/uat/seed_users.js b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/development/seed_users.js similarity index 88% rename from js-node/expressjs/deploy/db/knex/seeds/uat/seed_users.js rename to js-node/expressjs/apps/app-template/deploy/db/knex/seeds/development/seed_users.js index 710966dc..57f383eb 100644 --- a/js-node/expressjs/deploy/db/knex/seeds/uat/seed_users.js +++ b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/development/seed_users.js @@ -14,11 +14,9 @@ exports.seed = async function(knex) { username: 'test', email: 'test', githubId: null, - password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', // test + password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', //NOSONAR gaKey: 'IZDXCUDYNQ4ESMZZNY4HGZSDJRAVGZCO', sms: '6596935500', - // smsLastSent - // smsOtpPin smsVerified: 0, telegramId: '183535134', telegramUsername: 'aaronjxz', @@ -32,11 +30,9 @@ exports.seed = async function(knex) { username: 'ais-one', email: 'ais-one', githubId: 4284574, - password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', // test + password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', //NOSONAR gaKey: 'IZDXCUDYNQ4ESMZZNY4HGZSDJRAVGZCO', sms: '6596935500', - // smsLastSent - // smsOtpPin smsVerified: 0, telegramId: '183535134', telegramUsername: 'aaronjxz', @@ -50,11 +46,9 @@ exports.seed = async function(knex) { username: 'aaronjxz', email: 'aaronjxz', githubId: null, - password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', // test + password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', //NOSONAR gaKey: 'IZDXCUDYNQ4ESMZZNY4HGZSDJRAVGZCO', sms: '6596935500', - // smsLastSent - // smsOtpPin smsVerified: 0, telegramId: '183535134', telegramUsername: 'aaronjxz', diff --git a/js-node/expressjs/deploy/db/knex/seeds/index.js b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/index.js similarity index 100% rename from js-node/expressjs/deploy/db/knex/seeds/index.js rename to js-node/expressjs/apps/app-template/deploy/db/knex/seeds/index.js diff --git a/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/uat/seed_test.js b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/uat/seed_test.js new file mode 100644 index 00000000..798c9688 --- /dev/null +++ b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/uat/seed_test.js @@ -0,0 +1,2 @@ +const { seed } = require('./development/seed_test') +exports.seed = seed diff --git a/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/uat/seed_users.js b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/uat/seed_users.js new file mode 100644 index 00000000..c7e3548e --- /dev/null +++ b/js-node/expressjs/apps/app-template/deploy/db/knex/seeds/uat/seed_users.js @@ -0,0 +1,2 @@ +const { seed } = require('./development/seed_users') +exports.seed = seed diff --git a/js-node/expressjs/apps/app-template/deploy/db/mongo/index.js b/js-node/expressjs/apps/app-template/deploy/db/mongo/index.js new file mode 100644 index 00000000..16405426 --- /dev/null +++ b/js-node/expressjs/apps/app-template/deploy/db/mongo/index.js @@ -0,0 +1,14 @@ +console.log('Usage - npm run mongo -- development app-template ') +// console.log(process.argv.length, process.argv) + +if (process.argv.length >= 5) { + if (process.argv[4] === 'update') { + console.log('updating') + require('./update') + } else if (process.argv[4] === 'seed') { + console.log('seeding') + require('./seed') + } else { + console.log('unknown', process.argv) + } +} diff --git a/js-node/expressjs/deploy/db/mongo/seed.js b/js-node/expressjs/apps/app-template/deploy/db/mongo/seed.js similarity index 98% rename from js-node/expressjs/deploy/db/mongo/seed.js rename to js-node/expressjs/apps/app-template/deploy/db/mongo/seed.js index 5865ca6e..7a5e1b12 100644 --- a/js-node/expressjs/deploy/db/mongo/seed.js +++ b/js-node/expressjs/apps/app-template/deploy/db/mongo/seed.js @@ -3,7 +3,8 @@ async function run() { require('@es-labs/node/config')(process.cwd()) // first thing to include const mongodb = await require('@es-labs/node/services/db/mongodb').open() const mongo = mongodb.get() - ObjectID = mongo.ObjectID + + //NOSONAR // const ObjectID = mongo.ObjectID // Create JWT User Session Store // const { JWT_REFRESH_STORE, JWT_REFRESH_EXPIRY, JWT_REFRESH_STORE_NAME } = global.CONFIG @@ -77,6 +78,7 @@ async function run() { { personId: personIdStr, subject: 'PHY', grade: '70' } ]) */ + await mongo.db.collection('grade-todelete').insertMany([ { subject: 'EM', gradex: '80' }, { subject: 'AM', gradex: '90' }, diff --git a/js-node/expressjs/deploy/db/mongo/update.js b/js-node/expressjs/apps/app-template/deploy/db/mongo/update.js similarity index 92% rename from js-node/expressjs/deploy/db/mongo/update.js rename to js-node/expressjs/apps/app-template/deploy/db/mongo/update.js index 16e1d7f7..a86e6952 100644 --- a/js-node/expressjs/deploy/db/mongo/update.js +++ b/js-node/expressjs/apps/app-template/deploy/db/mongo/update.js @@ -1,12 +1,12 @@ -// const { bcrypt } = require('@es-labs/node/auth') -// const WINDOW_SIZE = 100 // update batch window size - async function run() { try { require('@es-labs/node/config')(process.cwd()) // first thing to include const mongodb = await require('@es-labs/node/services/db/mongodb').open() - const mongo = mongodb.get() - ObjectID = mongo.ObjectID + + //NOSONAR // const mongo = mongodb.get() + //NOSONAR // const ObjectID = mongo.ObjectID + //NOSONAR // const { bcrypt } = require('@es-labs/node/auth') + //NOSONAR // const WINDOW_SIZE = 100 // update batch window size // rename field // await mongo.db.collection('job').updateMany({}, { $rename: { 'customerCode': 'agencyCode' } } ) diff --git a/js-node/expressjs/deploy/db/state.json b/js-node/expressjs/apps/app-template/deploy/db/state.json similarity index 100% rename from js-node/expressjs/deploy/db/state.json rename to js-node/expressjs/apps/app-template/deploy/db/state.json diff --git a/js-node/expressjs/deploy.sh b/js-node/expressjs/deploy.sh index ab98ba59..07020c61 100644 --- a/js-node/expressjs/deploy.sh +++ b/js-node/expressjs/deploy.sh @@ -44,7 +44,7 @@ else # test vault # VAULT="{ \"url\": \"http://127.0.0.1:8200/v1/secret/data/test?version=1\", \"token\": \"roottoken\" }" VAULT= - gcloud auth activate-service-account --key-file=deploy/$1.gcp.json + gcloud auth activate-service-account --key-file=apps/$APP_NAME/deploy/$1.gcp.json gcloud config set project $GCP_PROJECT_ID fi diff --git a/js-node/expressjs/deploy/db/knex/index.js b/js-node/expressjs/deploy/db/knex/index.js deleted file mode 100644 index 30d68dbf..00000000 --- a/js-node/expressjs/deploy/db/knex/index.js +++ /dev/null @@ -1,11 +0,0 @@ -if (process.argv.length >= 4) { - if (process.argv[3] === 'migrate') { - console.log('migrate') - require('./migrations') - } else if (process.argv[3] === 'seed') { - console.log('seeding') - require('./seeds') - } else { - console.log('unknown', process.argv) - } -} diff --git a/js-node/expressjs/deploy/db/knex/seeds/development/seed_users.js b/js-node/expressjs/deploy/db/knex/seeds/development/seed_users.js deleted file mode 100644 index 710966dc..00000000 --- a/js-node/expressjs/deploy/db/knex/seeds/development/seed_users.js +++ /dev/null @@ -1,65 +0,0 @@ - -exports.seed = async function(knex) { - // Deletes ALL existing entries - try { - await knex('users').del() - } catch (e) { - console.log(e.toString()) - } - await knex('users').insert([ - { - id: 1, - groups: 'TestGroup', - orgId: 1, - username: 'test', - email: 'test', - githubId: null, - password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', // test - gaKey: 'IZDXCUDYNQ4ESMZZNY4HGZSDJRAVGZCO', - sms: '6596935500', - // smsLastSent - // smsOtpPin - smsVerified: 0, - telegramId: '183535134', - telegramUsername: 'aaronjxz', - revoked: '', // if not empty means user has been revoked - refreshToken: '' // to match user with refreshToken to extend access token - }, - { - id: 2, - groups: 'TestGithub', - orgId: 1, - username: 'ais-one', - email: 'ais-one', - githubId: 4284574, - password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', // test - gaKey: 'IZDXCUDYNQ4ESMZZNY4HGZSDJRAVGZCO', - sms: '6596935500', - // smsLastSent - // smsOtpPin - smsVerified: 0, - telegramId: '183535134', - telegramUsername: 'aaronjxz', - revoked: '', - refreshToken: '' - }, - { - id: 3, - groups: 'TestGmail,TestGroup', - orgId: 1, - username: 'aaronjxz', - email: 'aaronjxz', - githubId: null, - password: '$2b$12$Rr1kYTVjZ.9Mnz8EpvRHk.EccoXNtt574A5mwvDn97S5Gu2xIMFhO', // test - gaKey: 'IZDXCUDYNQ4ESMZZNY4HGZSDJRAVGZCO', - sms: '6596935500', - // smsLastSent - // smsOtpPin - smsVerified: 0, - telegramId: '183535134', - telegramUsername: 'aaronjxz', - revoked: '', - refreshToken: '' - } - ]) -} diff --git a/js-node/expressjs/deploy/db/knex/seeds/uat/seed_test.js b/js-node/expressjs/deploy/db/knex/seeds/uat/seed_test.js deleted file mode 100644 index a0fb622f..00000000 --- a/js-node/expressjs/deploy/db/knex/seeds/uat/seed_test.js +++ /dev/null @@ -1,58 +0,0 @@ -const mkDt = () => (new Date()).toISOString() - -new Intl.DateTimeFormat('default', { - year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone: 'UTC', hour12: false, formatMatcher: 'basic' -}).format(new Date()) - -exports.seed = async (knex) => { - // Deletes ALL existing entries - await knex('books_authors').del() - await knex('pages').del() - await knex('books').del() - await knex('authors').del() - await knex('categories').del() - - await knex('person').del() - await knex('country').del() - - await knex('authors').insert([ - {id: 1, name: 'author1', avatar: '', created_at: mkDt() }, - {id: 2, name: 'author2', avatar: '', created_at: mkDt() }, - {id: 3, name: 'author3', avatar: '', created_at: mkDt() }, - {id: 4, name: 'author4', avatar: '', created_at: mkDt() }, - {id: 5, name: 'author5', avatar: '', created_at: mkDt() } - ]) - await knex('categories').insert([ - {id: 1, name: 'cat1', created_at: mkDt() }, - {id: 2, name: 'cat2', created_at: mkDt() }, - {id: 3, name: 'cat3', created_at: mkDt() } - ]) - - await knex('books').insert([ - {id: 1, name: 'book1', categoryId: 1, rating: 5, yearPublished: '2004', created_at: mkDt() }, - {id: 2, name: 'book2', categoryId: 2, rating: 4, yearPublished: '2003', created_at: mkDt() }, - {id: 3, name: 'book3', categoryId: 1, rating: 3, yearPublished: '2010', created_at: mkDt() }, - {id: 4, name: 'book4', categoryId: 1, rating: 2, yearPublished: '2009', created_at: mkDt() }, - {id: 5, name: 'book5', categoryId: 2, rating: 1, yearPublished: '2007', created_at: mkDt() } - ]) - await knex('books_authors').insert([ - {authorId: 1, bookId: 1}, - {authorId: 2, bookId: 2}, - {authorId: 3, bookId: 3}, - {authorId: 1, bookId: 4}, - {authorId: 2, bookId: 4}, - {authorId: 2, bookId: 5} - ]) - await knex('pages').insert([ - {id: 1, content: 'page1', bookId: 1, created_at: mkDt()}, - {id: 2, content: 'page2', bookId: 1, created_at: mkDt()}, - {id: 3, content: 'page3', bookId: 1, created_at: mkDt()}, - {id: 4, content: 'page4', bookId: 2, created_at: mkDt()}, - {id: 5, content: 'page5', bookId: 3, created_at: mkDt()}, - {id: 6, content: 'page6', bookId: 4, created_at: mkDt()}, - {id: 7, content: 'page7', bookId: 4, created_at: mkDt()}, - {id: 8, content: 'page8', bookId: 5, created_at: mkDt()} - ]) - - await knex('country').insert( require('../../../icc.json') ) -} diff --git a/js-node/expressjs/deploy/db/mongo/index.js b/js-node/expressjs/deploy/db/mongo/index.js deleted file mode 100644 index bb65d0f7..00000000 --- a/js-node/expressjs/deploy/db/mongo/index.js +++ /dev/null @@ -1,14 +0,0 @@ -console.log('Usage - windows: npm run mongo update, npm run mongo seed') -console.log('Usage - unix: npm run mongo:unix update, npm run mongo:unix seed') - -if (process.argv.length >= 4) { - if (process.argv[3] === 'update') { - console.log('updating') - require('./update') - } else if (process.argv[3] === 'seed') { - console.log('seeding') - require('./seed') - } else { - console.log('unknown', process.argv) - } -} diff --git a/js-node/expressjs/package-lock.json b/js-node/expressjs/package-lock.json index b651c9ee..4c0b6b8b 100644 --- a/js-node/expressjs/package-lock.json +++ b/js-node/expressjs/package-lock.json @@ -1,6 +1,6 @@ { "name": "expressjs", - "version": "0.6.2", + "version": "0.6.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js-node/expressjs/package.json b/js-node/expressjs/package.json index 92b8eca9..1a443c24 100644 --- a/js-node/expressjs/package.json +++ b/js-node/expressjs/package.json @@ -1,15 +1,15 @@ { "name": "expressjs", - "version": "0.6.2", - "description": "example express application", + "version": "0.6.3", + "description": "express application", "main": "index.js", "directories": { "test": "tests" }, "scripts": { "dev": "cross-env NODE_ENV=development PORT=3001 DEBUG=app:* nodemon --ignore tests/ --ignore public/ --watch src bin/www", - "knex": "node deploy/db/knex/index.js", - "mongo": "node deploy/db/mongo/index.js", + "knex": "node apps/app-template/deploy/db/knex/index.js", + "mongo": "node apps/app-template/deploy/db/mongo/index.js", "app": "nodemon --trace-warnings index.js", "app:lint": "nodemon --ignore tests/ --ignore public/ --exec \"npm run lint && node\" index.js", "test": "cross-env NODE_ENV=development jest --config=jest.config.js", diff --git a/js-node/expressjs/public/demo-express/mq.html b/js-node/expressjs/public/demo-express/mq.html index 5836166e..aa988ac2 100644 --- a/js-node/expressjs/public/demo-express/mq.html +++ b/js-node/expressjs/public/demo-express/mq.html @@ -23,18 +23,18 @@

Message Queues Back

try { const res = await fetch('/api/mq-agenda', { method: 'GET' }) const rv = await res.json() - document.querySelector('#output').innerHTML = typeof rv === 'object' ? JSON.stringify(rv, null, 2) : rv.toString() + document.querySelector('#output').innerHTML = rv && typeof rv === 'object' ? JSON.stringify(rv, null, 2) : rv.toString() } catch (e) { - document.querySelector('#output').innerHTML = typeof e === 'object' ? JSON.stringify(e, null, 2) : e.toString() + document.querySelector('#output').innerHTML = e && typeof e === 'object' ? JSON.stringify(e, null, 2) : e.toString() } } async function mqBull() { try { const res = await fetch('/api/mq-bull', { method: 'GET' }) const rv = await res.json() - document.querySelector('#output').innerHTML = typeof rv === 'object' ? JSON.stringify(rv, null, 2) : rv.toString() + document.querySelector('#output').innerHTML = rv && typeof rv === 'object' ? JSON.stringify(rv, null, 2) : rv.toString() } catch (e) { - document.querySelector('#output').innerHTML = typeof e === 'object' ? JSON.stringify(e, null, 2) : e.toString() + document.querySelector('#output').innerHTML = e && typeof e === 'object' ? JSON.stringify(e, null, 2) : e.toString() } } diff --git a/js-node/openapi-file-joiner/README.md b/js-node/openapi-file-joiner/README.md index 6e7e07fc..15bc0948 100644 --- a/js-node/openapi-file-joiner/README.md +++ b/js-node/openapi-file-joiner/README.md @@ -17,7 +17,7 @@ Better to combine to a single file for use. npm i ``` -Refer to .env file for openapi folder (relative to this script), root file and output file (will be generated in the openapi folder) +Refer to **.env** file for openapi folder (relative to this script), root file and output file (will be generated in the openapi folder) ``` node index.js diff --git a/js-web/vue-vite/package-lock.json b/js-web/vue-vite/package-lock.json index d83ad861..50b87e49 100644 --- a/js-web/vue-vite/package-lock.json +++ b/js-web/vue-vite/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-vite", - "version": "0.6.2", + "version": "0.6.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -456,6 +456,137 @@ "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", "dev": true }, + "@sentry/browser": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.10.0.tgz", + "integrity": "sha512-H0Blgp8f8bomebkkGWIgxHVjabtQAlsKJDiFXBg7gIc75YcarRxwH0R3hMog1/h8mmv4CGGUsy5ljYW6jsNnvA==", + "requires": { + "@sentry/core": "6.10.0", + "@sentry/types": "6.10.0", + "@sentry/utils": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, + "@sentry/core": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.10.0.tgz", + "integrity": "sha512-5KlxHJlbD7AMo+b9pMGkjxUOfMILtsqCtGgI7DMvZNfEkdohO8QgUY+hPqr540kmwArFS91ipQYWhqzGaOhM3Q==", + "requires": { + "@sentry/hub": "6.10.0", + "@sentry/minimal": "6.10.0", + "@sentry/types": "6.10.0", + "@sentry/utils": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, + "@sentry/hub": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.10.0.tgz", + "integrity": "sha512-MV8wjhWiFAXZAhmj7Ef5QdBr2IF93u8xXiIo2J+dRZ7eVa4/ZszoUiDbhUcl/TPxczaw4oW2a6tINBNFLzXiig==", + "requires": { + "@sentry/types": "6.10.0", + "@sentry/utils": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, + "@sentry/minimal": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.10.0.tgz", + "integrity": "sha512-yarm046UgUFIBoxqnBan2+BEgaO9KZCrLzsIsmALiQvpfW92K1lHurSawl5W6SR7wCYBnNn7CPvPE/BHFdy4YA==", + "requires": { + "@sentry/hub": "6.10.0", + "@sentry/types": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, + "@sentry/tracing": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.10.0.tgz", + "integrity": "sha512-jZj6Aaf8kU5wgyNXbAJHosHn8OOFdK14lgwYPb/AIDsY35g9a9ncTOqIOBp8X3KkmSR8lcBzAEyiUzCxAis2jA==", + "requires": { + "@sentry/hub": "6.10.0", + "@sentry/minimal": "6.10.0", + "@sentry/types": "6.10.0", + "@sentry/utils": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, + "@sentry/types": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.10.0.tgz", + "integrity": "sha512-M7s0JFgG7/6/yNVYoPUbxzaXDhnzyIQYRRJJKRaTD77YO4MHvi4Ke8alBWqD5fer0cPIfcSkBqa9BLdqRqcMWw==" + }, + "@sentry/utils": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.10.0.tgz", + "integrity": "sha512-F9OczOcZMFtazYVZ6LfRIe65/eOfQbiAedIKS0li4npuMz0jKYRbxrjd/U7oLiNQkPAp4/BujU4m1ZIwq6a+tg==", + "requires": { + "@sentry/types": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, + "@sentry/vue": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@sentry/vue/-/vue-6.10.0.tgz", + "integrity": "sha512-pCmycL9EglfywdUKU6KJ6QqUfCKZmyZkZma6b2mpWjAgeMnuRFcc1arz/HvjtIY6hDKVsIFzgIBeVfcKcdCrnQ==", + "requires": { + "@sentry/browser": "6.10.0", + "@sentry/core": "6.10.0", + "@sentry/minimal": "6.10.0", + "@sentry/types": "6.10.0", + "@sentry/utils": "6.10.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } + } + }, "@simonwep/pickr": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@simonwep/pickr/-/pickr-1.8.1.tgz", @@ -1076,9 +1207,9 @@ "integrity": "sha512-u1wmTI1jJGzCJzWndZo8mk4wnPTZd1eOIYTYvuEyOQGfmDl3TrabCCfKnOC86FZwW/9djqTl933UF/cS425i9A==" }, "cypress": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-7.7.0.tgz", - "integrity": "sha512-uYBYXNoI5ym0UxROwhQXWTi8JbUEjpC6l/bzoGZNxoKGsLrC1SDPgIDJMgLX/MeEdPL0UInXLDUWN/rSyZUCjQ==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-8.0.0.tgz", + "integrity": "sha512-Hhbc7FtbeCSg5Ui2zxXQLynk7IYGIygG8NqTauS4EtCWyp2k6s4g8P4KUZXwRbhuryN/+/dCd1kPtFbhBx8MuQ==", "dev": true, "requires": { "@cypress/request": "^2.88.5", @@ -2591,9 +2722,9 @@ } }, "listr2": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.10.0.tgz", - "integrity": "sha512-eP40ZHihu70sSmqFNbNy2NL1YwImmlMmPh9WO5sLmPDleurMHt3n+SwEWNu2kzKScexZnkyFtc1VI0z/TGlmpw==", + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.11.0.tgz", + "integrity": "sha512-XLJVe2JgXCyQTa3FbSv11lkKExYmEyA4jltVo8z4FX10Vt1Yj8IMekBfwim0BSOM9uj1QMTJvDQQpHyuPbB/dQ==", "dev": true, "requires": { "cli-truncate": "^2.1.0", diff --git a/js-web/vue-vite/package.json b/js-web/vue-vite/package.json index b1b0cb0f..e8d26f94 100644 --- a/js-web/vue-vite/package.json +++ b/js-web/vue-vite/package.json @@ -1,6 +1,6 @@ { "name": "vue-vite", - "version": "0.6.2", + "version": "0.6.3", "description": "vue 3 SPA + vite example", "author": "aaronjxz@gmail.com", "license": "MIT", @@ -16,6 +16,8 @@ "@antv/data-set": "^0.11.8", "@antv/g2": "^4.1.21", "@antv/g2plot": "^2.3.27", + "@sentry/tracing": "^6.10.0", + "@sentry/vue": "^6.10.0", "ant-design-vue": "^2.2.2", "echarts": "^5.1.2", "leaflet": "^1.7.1", @@ -27,7 +29,7 @@ "devDependencies": { "@vitejs/plugin-vue": "^1.2.5", "@vue/compiler-sfc": "^3.1.5", - "cypress": "^7.7.0", + "cypress": "^8.0.0", "dotenv": "^10.0.0", "eslint": "^7.31.0", "eslint-config-prettier": "^8.3.0", diff --git a/js-web/vue-vite/src/main.js b/js-web/vue-vite/src/main.js index 81412512..bb2d6714 100644 --- a/js-web/vue-vite/src/main.js +++ b/js-web/vue-vite/src/main.js @@ -6,6 +6,10 @@ import App from './App.vue' import Antd from 'ant-design-vue' import 'ant-design-vue/dist/antd.css' +// Sentry +import * as Sentry from '@sentry/vue' +import { Integrations } from '@sentry/tracing' + // pwa import '../firebase.config.js' import '../pwa-init.js' @@ -20,6 +24,24 @@ const app = createApp(App) // console.log(tag) // return tag.startsWith('bwc-') || tag.startsWith('vcxwc-') // } + +Sentry.init({ + app, + dsn: 'https://3326314072fc4706bf8492e292b674b2@o406131.ingest.sentry.io/5869551', + integrations: [ + new Integrations.BrowserTracing({ + routingInstrumentation: Sentry.vueRouterInstrumentation(router), + tracingOrigins: ['localhost', 'my-site-url.com', /^\//], + }) + ], + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0 +}) + +// Sentry.captureMessage('Something went wrong Vue Vute' + Date.now()) + const theme = 'dark' // const ThemeSymbol = Symbol() app.provide('MyTheme', theme) // provide & inject diff --git a/package-lock.json b/package-lock.json index 32e0ed11..28b14b5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cookbook", - "version": "0.6.2", + "version": "0.6.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index de0e3754..d2177cae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cookbook", - "version": "0.6.2", + "version": "0.6.3", "description": "Fullstack JS Application Cookbook", "author": "aaronjxz@gmail.com", "license": "MIT",