Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Development #116

Merged
merged 65 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
a83aa46
Merge pull request #105 from Tonomy-Foundation/testnet
theblockstalk Apr 22, 2024
21160ca
fix: fix for settings switch
theblockstalk Apr 22, 2024
4b50b29
Merge branch 'master' of github.com:Tonomy-Foundation/Tonomy-Communic…
theblockstalk Apr 22, 2024
1185eee
Merge pull request #106 from Tonomy-Foundation/hotfix/settings-switch
theblockstalk Apr 22, 2024
c7939bb
feat: upgrade yarn and all packages
theblockstalk Jun 27, 2024
1114269
added error details log
sadiabbasi Jul 4, 2024
0198ccd
update sdk
sadiabbasi Jul 4, 2024
4182b57
Merge pull request #107 from Tonomy-Foundation/feature/hcaptcha-error
sadiabbasi Jul 4, 2024
4cd1c84
feat: build to ESM modules
theblockstalk Jul 5, 2024
76f674e
build:
theblockstalk Jul 5, 2024
5b653c0
build: merge from development
theblockstalk Jul 6, 2024
08d6a73
ci: update CI node version
theblockstalk Jul 6, 2024
9021ffd
build: remove unused custom resolver
theblockstalk Jul 6, 2024
2f97a77
build: simplified the nodemon service and fixed tests for the new SDK…
theblockstalk Jul 6, 2024
d4c020c
fix: fixed settings import default error
theblockstalk Jul 7, 2024
7ce77ae
test: changed tests to use ESM
theblockstalk Jul 10, 2024
1624d07
ci: fixed test unit command
theblockstalk Jul 10, 2024
10f0756
docs: Updated README with nodejs version
theblockstalk Jul 10, 2024
2a39e87
fix: fixed error handling
theblockstalk Jul 11, 2024
0edd2d1
ci: test for outdated packages
theblockstalk Jul 11, 2024
137b127
style: upgraded eslint and fixed issues
theblockstalk Jul 11, 2024
9c56f83
docs: better yarn outdated message and README.md
theblockstalk Jul 16, 2024
3a30f6e
build: revert to npm sdk
theblockstalk Jul 16, 2024
28b7725
docs: updated sdk version.sh note
theblockstalk Jul 25, 2024
cfc5f5f
feat: latest SDK and fixed yarn errors
theblockstalk Jul 26, 2024
8dbe8ce
test: Added veramo tests
theblockstalk Jul 30, 2024
f83b244
feat: Debug package used
theblockstalk Jul 30, 2024
4213b0f
feat: SDK update
theblockstalk Jul 31, 2024
5e9a360
feat: upgrade to latest yarn
theblockstalk Aug 1, 2024
9c5dd91
ci: Test on all push, and branch protection
theblockstalk Aug 2, 2024
78997bf
ci: fixed corepack
theblockstalk Aug 2, 2024
f0831ab
style: fixed lint errors
theblockstalk Aug 2, 2024
edb4e4b
style: turn of ts comment lint errors
theblockstalk Aug 5, 2024
94ecf7e
comment testVeramo
sadiabbasi Aug 18, 2024
a127d4c
build: Upgrade to to latest SDK
theblockstalk Aug 19, 2024
a3d0ccd
Merge pull request #108 from Tonomy-Foundation/feature/336-upgrade-to…
theblockstalk Aug 19, 2024
399765b
build: specify engine
theblockstalk Aug 20, 2024
ec1c5aa
feat: updated SDK version
theblockstalk Aug 20, 2024
ffa38b8
Merge pull request #109 from Tonomy-Foundation/feature/336-upgrade-to…
theblockstalk Aug 20, 2024
c355ed0
build: build digitalocean
theblockstalk Aug 20, 2024
1abf884
Merge branch 'development' of github.com:Tonomy-Foundation/Tonomy-Com…
theblockstalk Aug 20, 2024
986a0f0
Merge pull request #110 from Tonomy-Foundation/feature/336-upgrade-to…
theblockstalk Aug 20, 2024
d316881
build: installed yarn binary
theblockstalk Aug 20, 2024
6e4526f
Merge branch 'development' of github.com:Tonomy-Foundation/Tonomy-Com…
theblockstalk Aug 20, 2024
132e35d
Merge pull request #111 from Tonomy-Foundation/feature/336-upgrade-to…
theblockstalk Aug 20, 2024
f3bbe87
build: change yarn specifier
theblockstalk Aug 20, 2024
9a8b528
Merge branch 'development' of github.com:Tonomy-Foundation/Tonomy-Com…
theblockstalk Aug 20, 2024
c474831
build: yarn version
theblockstalk Aug 20, 2024
ffb6ddf
build: remove yarn binary
theblockstalk Aug 20, 2024
59e954b
build: added yarn back
theblockstalk Aug 20, 2024
a3286f6
chore: remove comment yarnPath
theblockstalk Aug 20, 2024
cae9c0b
Merge pull request #112 from Tonomy-Foundation/feature/336-upgrade-to…
theblockstalk Aug 20, 2024
812dcfd
build: set engine
theblockstalk Aug 20, 2024
810fb5f
fix: fixed error response type
theblockstalk Aug 20, 2024
c0c7588
Merge pull request #113 from Tonomy-Foundation/bug/227-staging-except…
theblockstalk Aug 20, 2024
5efca32
build: fixed engine
theblockstalk Aug 20, 2024
de952e1
Merge branch 'development' of github.com:Tonomy-Foundation/Tonomy-Com…
theblockstalk Aug 20, 2024
184c5ad
Merge pull request #114 from Tonomy-Foundation/bug/227-staging-except…
theblockstalk Aug 20, 2024
ab94c0c
build: engine
theblockstalk Aug 20, 2024
5185736
Merge branch 'development' of github.com:Tonomy-Foundation/Tonomy-Com…
theblockstalk Aug 20, 2024
57144f1
Merge pull request #115 from Tonomy-Foundation/bug/227-staging-except…
theblockstalk Aug 20, 2024
c64bd42
Merge branch 'development' into fix/update-sdk-version
sadiabbasi Sep 20, 2024
189956d
update testnet sdk version
sadiabbasi Sep 20, 2024
51d4f8f
fix lint
sadiabbasi Sep 20, 2024
8da4da1
Merge pull request #117 from Tonomy-Foundation/fix/update-sdk-version
sadiabbasi Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions .eslintrc.js

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/check-sdk-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ jobs:
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v4

- name: Enable Corepack before setting up Node
run: corepack enable

- name: 📦 Check it is using the latest version of the SDK
uses: actions/setup-node@v4
with:
node-version: 18.12.1
- run: corepack enable
- run: yarn -v
node-version: 22.3.0
- run: yarn install --immutable
- run: yarn run updateSdkVersion $GITHUB_BASE_REF check
24 changes: 12 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
name: Test - Pull Requests

on:
pull_request:
branches:
- development
push

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Enable Corepack before setting up Node
run: corepack enable

- name: Install dependencies
uses: actions/setup-node@v4
with:
node-version: 18.12.1
- run: corepack enable
- run: yarn -v
node-version: 22.3.0
- run: yarn install --immutable

- name: Run lint and test
uses: actions/setup-node@v4
with:
node-version: 18.12.1
node-version: 22.3.0
- run: yarn run build
- run: yarn run lint
- run: yarn run test
- run: yarn run test:unit
- run: yarn run test:e2e

- name: Build and push
Expand Down Expand Up @@ -55,13 +54,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack before setting up Node
run: corepack enable

- name: Build and run server
uses: actions/setup-node@v4
with:
node-version: 18.12.1
- run: corepack enable
# corepack is needed to run yarn through npm
node-version: 22.3.0
- run: yarn install --immutable
- run: yarn run build
- run: yarn run start:prod &
Expand Down Expand Up @@ -94,4 +94,4 @@ jobs:
name: zap-scan-output
path: "zap-api-scan-report.html"
# Exit with the exit code of the ZAP scan
- run: exit "${{ steps.zap_scan.outputs.EXIT_CODE }}"
- run: exit "${{ steps.zap_scan.outputs.EXIT_CODE }}"
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"typescriptreact"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.eslint": "explicit"
},
"jest.autoRun": {
"onSave": false,
Expand All @@ -17,4 +17,10 @@
"jest.testExplorer": {
"enabled": true
},
"git.branchPrefix": "feature/",
"git.branchProtection": [
"master",
"main",
"development"
],
}
768 changes: 0 additions & 768 deletions .yarn/releases/yarn-3.1.1.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.1.1.cjs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.12.1 AS tonomy_communication_base
FROM node:22.3.0 AS tonomy_communication_base

WORKDIR /app
COPY . .
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

Requires nodejs v20+

## Installation

```bash
Expand All @@ -13,13 +15,11 @@ yarn install
## Running the app

```bash
# development
# development with watch mode
yarn run start

# watch mode
yarn run start:dev

# production mode
yarn run build
yarn run start:prod
```

Expand Down Expand Up @@ -50,6 +50,10 @@ yarn run test:e2e
yarn run test:cov
```

## Debugging

Uses [debug](https://www.npmjs.com/package/debug) package. Use `export DEBUG="tonomy*"` to see all debug logs.

## API Documentation

<https://localhost:5000/openapi> (for REST API with Open API)
Expand All @@ -59,12 +63,10 @@ yarn run test:cov

Run in a Digital Ocean App which runs the nodejs project: <https://docs.digitalocean.com/products/app-platform/>

Using Ubuntu 22.04 with Nodejs 18.x is enabled:
Using Ubuntu 22.04 with Nodejs 20+ is enabled:

- <https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/#ubuntu-2204-stack-supporting-nodejs-18>

Build command: `yarn -v && yarn install && yarn run build`

- NOTE: we need to run `yarn install` again so that we install with `[email protected]` which we force via`.yarnrc.yml` and `.yarn/releases/yarn-3.1.1.cjs`. See <https://github.com/Tonomy-Foundation/Tonomy-Communication/issues/85> for more details.
Build command: `yarn run build`

Run command: `yarn run start:prod`
37 changes: 37 additions & 0 deletions add-js-extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import fs from 'fs';
import path from 'path';

const directory = './dist';

console.log('Adding .js extension to local imports...');

function addJsExtension(filePath) {
const data = fs.readFileSync(filePath, 'utf8');
// Replace all local imports (Regex: from './filename') with .js extension (from './filename.js'
const data2 = data.replace(/from '(\.\/[^']+)'/g, "from '$1.js'");

// Replace all local imports (Regex: from '../filename') with .js extension (from '../filename.js'
const result = data2.replace(/from '\.\.\/([^']+)'/g, "from '../$1.js'");

fs.writeFileSync(filePath, result, 'utf8');
}

function fromDir(startPath, filter) {
if (!fs.existsSync(startPath)) {
console.log('Directory not found', startPath);
return;
}

const files = fs.readdirSync(startPath);

for (let i = 0; i < files.length; i++) {
const filename = path.join(startPath, files[i]);
const stat = fs.lstatSync(filename);

if (stat.isDirectory()) {
fromDir(filename, filter); // Recurse into subdirectories
} else if (filter.test(filename)) addJsExtension(filename);
}
}

fromDir(directory, /\.js$/); // Look for .js files
53 changes: 53 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettier from 'eslint-plugin-prettier/recommended';
import globals from 'globals';

export default [
eslint.configs.recommended,
...tseslint.configs.recommended,
prettier,
{
rules: {
eqeqeq: 'error',
'no-console': 'warn',
'prettier/prettier': 'error',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'padding-line-between-statements': [
'warn',
{ blankLine: 'always', prev: 'block-like', next: '*' },
{ blankLine: 'always', prev: 'block', next: '*' },
{ blankLine: 'always', prev: '*', next: ['block', 'block-like'] },
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{
blankLine: 'any',
prev: ['const', 'let', 'var'],
next: ['const', 'let', 'var'],
},
{ blankLine: 'always', prev: ['export', 'import'], next: '*' },
{ blankLine: 'any', prev: 'import', next: 'import' },
{ blankLine: 'any', prev: 'export', next: 'export' },
],
},
languageOptions: {
ecmaVersion: 6,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.node,
...globals.es6,
...globals.jest,
},
},
files: ['**/*.js', '**/*.ts'],
ignores: ['dist/**'],
},
];
41 changes: 41 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { Config } from 'jest';

// https://www.jenchan.biz/blog/dissecting-the-hell-jest-setup-esm-typescript-setup
// https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/
const baseConfig: Config = {
moduleFileExtensions: ['js', 'json', 'ts'],
collectCoverageFrom: ['**/*.(t|j)s'],
coverageDirectory: '../coverage',
testEnvironment: 'node',
transform: {
'^.+\\.m?tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: './tsconfig.json',
diagnostics: process.env.CI ? true : false,
},
],
},
transformIgnorePatterns: [],
extensionsToTreatAsEsm: ['.ts'],
};

const config: Config = {
projects: [
{
...baseConfig,
displayName: 'Unit tests',
rootDir: './src',
testRegex: '.*\\.spec\\.ts$',
},
{
...baseConfig,
displayName: 'End-to-end tests',
rootDir: './test',
testRegex: '.e2e-spec.ts$',
},
],
};

export default config;
11 changes: 11 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"watch": [
"src",
"test"
],
"ext": "ts",
"ignore": [
"src/**/*.spec.ts"
],
"exec": "node start-dev.js"
}
Loading
Loading