Skip to content
Snippets Groups Projects
Unverified Commit 5bc9dc86 authored by Konstantin Tsabolov's avatar Konstantin Tsabolov Committed by GitHub
Browse files

Merge pull request #7 from spherity/chore/dx

Developer Experience stuff
parents d7014eb0 c5ef6fe2
No related branches found
No related tags found
No related merge requests found
Pipeline #34760 failed
Showing
with 539 additions and 212 deletions
node_modules
.dockerignore
.editorconfig
.eslintignore
.eslintrc.*
.git
.gitattributes
.gitignore
*.md
dist
\ No newline at end of file
.gitlab-ci.yml
.lintstagedrc
.prettierignore
.prettierrc*
**/.env*
**/*.md
**/*.postman_collection.json
**/*.tsbuildinfo
**/coverage
**/deployment
**/dist
**/test
commitlint.config.cjs
Dockerfile
jest.config.*
node_modules
# Ignore everything
*
# Except for these files
# Except these files
!*.ts
!*.d.ts
!jest.config.js
# .. also in subdirectories
!*/
# ... in these ones
!src/*
# ... in these directories
!apps/**/src/*
# Explicitly ignore these locations
node_modules
dist
apps/**/dist
compose
documentation
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:workspaces/recommended',
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
plugins: ['workspaces'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
},
settings: {
'import/extensions': ['.js', '.ts'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
project: 'packages/*/tsconfig.json',
alwaysTryTypes: true,
},
},
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false, variables: true }],
'@typescript-eslint/explicit-member-accessibility': 'error',
'no-console': 'error',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'import/no-cycle': 'error',
'import/newline-after-import': ['error', { count: 1 }],
'import/order': [
'error',
{
groups: ['type', ['builtin', 'external'], 'parent', 'sibling', 'index'],
alphabetize: {
order: 'asc',
},
'newlines-between': 'always',
},
],
'@typescript-eslint/no-non-null-assertion': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
},
],
'no-restricted-imports': [
'error',
{
patterns: ['packages/*'],
},
],
// Do not allow const enums
// https://github.com/typescript-eslint/typescript-eslint/issues/561#issuecomment-593059472
// https://ncjamieson.com/dont-export-const-enums/
'no-restricted-syntax': [
'error',
{
selector: 'TSEnumDeclaration[const=true]',
message: "Don't declare const enums",
},
],
},
overrides: [
{
files: [
'*.spec.ts',
'*.e2e-spec.ts',
'**/tests/**',
],
env: {
jest: true,
node: false,
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
},
}
]
}
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# Swap the comments on the following lines if you don't wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
# !.yarn/cache
.pnp.*
node_modules
.idea
# Created by https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,jetbrains+all,macos,windows,linux
# Edit at https://www.toptal.com/developers/gitignore?templates=node,visualstudiocode,jetbrains+all,macos,windows,linux
**/*.env
### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# compiled output
node_modules/
apps/*/node_modules
dist
/apps/**/dist/
*.tsbuildinfo
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### JetBrains+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.
.idea/*
!.idea/codeStyles
!.idea/runConfigurations
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### Node ###
# Logs
/logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
apps/**/logs/log.json
.pnpm-debug.log*
# OS
.DS_Store
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Tests
/coverage
/.nyc_output
# Bower dependency directory (https://bower.io/)
bower_components
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# node-waf configuration
.lock-wscript
# IDE - VSCode
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Node Patch ###
# Serverless Webpack directories
.webpack/
# Optional stylelint cache
# SvelteKit build / generate output
.svelte-kit
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,jetbrains+all,macos,windows,linux
#Env files
**/*.env
!config/env/development.env
.idea
*.env
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no -- commitlint --edit ${1}
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm lint-staged
{
"apps/**/*.ts": ["npm run lint", "npm run format"]
}
......@@ -10,8 +10,13 @@
!*/
# ... in these ones
!src/*
!apps/**/src/*
# Explicitly ignore these locations
node_modules
dist
apps/**/dist
compose
documentation
# Ignore ssi-abstraction for now
apps/ssi-abstraction
File moved
# Base
FROM node:20 AS base
ARG APP_HOME=/home/node/app
ARG SERVICE
WORKDIR ${APP_HOME}
RUN corepack enable
# # libindy build
# FROM node:20-bullseye AS ssi-base
# RUN apt-get update \
# && apt-get install -y --no-install-recommends libsodium-dev libzmq3-dev
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain '1.58.0'
# RUN git clone https://github.com/hyperledger/indy-sdk
# RUN cd indy-sdk/libindy && ~/.cargo/bin/cargo build --release
# RUN cd indy-sdk/libindy && mv target/release/libindy.so /usr/lib/libindy.so
# Build
FROM base AS build
ARG APP_HOME=/home/node/app
WORKDIR ${APP_HOME}
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
COPY apps/${SERVICE}/package.json ./apps/${SERVICE}/
RUN pnpm install --frozen-lockfile
COPY apps/${SERVICE} ./apps/${SERVICE}
RUN pnpm --filter ${SERVICE} build:production
RUN pnpm --filter ${SERVICE} --prod deploy build
# This is a way of keeping the generated prisma client in the build folder
RUN if [ -d ./apps/${SERVICE}/node_modules/\@prisma/client ]; then \
GLOBAL_PRISMA_SETUP=`realpath ./apps/${SERVICE}/node_modules/\@prisma/client` \
GLOBAL_PRISMA_CLIENT=`readlink -f ${GLOBAL_PRISMA_SETUP}/../../.prisma` \
BUILD_PRISMA_SETUP=`realpath ./build/node_modules/\@prisma/client` \
BUILD_PRISMA_CLIENT=`readlink -f ${BUILD_PRISMA_SETUP}/../..` \
sh -c 'cp -r $GLOBAL_PRISMA_CLIENT $BUILD_PRISMA_CLIENT'; \
fi
# Final
FROM node:20 AS final
ARG APP_HOME=/home/node/app
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR ${APP_HOME}
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["node", "dist/main.js"]
COPY --chown=node:node ./docker-entrypoint.sh ./docker-entrypoint.sh
COPY --from=build --chown=node:node ${APP_HOME}/build/dist ./dist
COPY --from=build --chown=node:node ${APP_HOME}/build/node_modules ./node_modules
COPY --from=build --chown=node:node ${APP_HOME}/build/package.json .
# Cut unnecessary stuff from package.json. Only leave name, version and module type
RUN node -e "\
const { name, version, type } = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));\
fs.writeFileSync('./package.json', JSON.stringify({ name, version, type }, null, 2));\
"
USER node
Dockerfile
Jenkinsfile
coverage
docker-compose.yml
docs
node_modules
yarn-error.log
*.md
!README.md
.circle*
.codecov*
.coveralls*
.dockerignore
.drone*
.editorconfig
# .env
.git*
.huskyrc*
.lintstagedrc*
.npmignore
.prettierrc*
dist
\ No newline at end of file
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
},
env: {
node: true,
},
plugins: ['prettier', '@typescript-eslint/eslint-plugin', 'jest'],
extends: [
'prettier',
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
],
ignorePatterns: ['.eslintrc.js'],
overrides: [],
settings: {
jest: {
version: '29',
},
},
rules: {
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': [1, { argsIgnorePattern: '^_' }],
},
overrides: [
{
files: [
'*.spec.ts',
'*.e2e-spec.ts',
'__mocks__/*.ts',
'__mocks__/**/*.ts',
],
rules: {
'@typescript-eslint/no-explicit-any': 0,
'jest/no-mocks-import': 0,
},
},
],
};
# Ignore everything
*
# Except for these files
!*.ts
!*.d.ts
!jest.config.js
# .. also in subdirectories
!*/
# ... in these ones
!src/*
# Explicitly ignore these locations
node_modules
dist
FROM node:16-slim AS builder
RUN apt-get update
RUN apt-get install -y openssl
WORKDIR /app
RUN npm i -g pnpm
COPY . .
RUN pnpm install
RUN pnpm -F attestation-manager prisma:generate
RUN pnpm -F attestation-manager build
FROM node:16-slim
RUN apt-get update
RUN apt-get install -y openssl
ENV PATH /usr/src/app/node_modules/.bin:$PATH
WORKDIR /usr/src/app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/start.sh ./start.sh
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/src/prisma prisma
EXPOSE 3005
RUN chmod +x ./start.sh
CMD ["./start.sh"]
......@@ -3,6 +3,8 @@
"sourceRoot": "src",
"compilerOptions": {
"builder": "swc",
"typeCheck": true
"typeCheck": true,
"assets": ["**/*.prisma"]
}
}
......@@ -7,19 +7,17 @@
"license": "Apache-2.0",
"type": "module",
"scripts": {
"clean": "rm -r dist",
"prebuild": "rimraf dist",
"clean": "rimraf dist coverage *.tsbuildinfo",
"prebuild": "pnpm clean",
"build": "nest build",
"dbSchema": "npx prisma db push --schema=./src/prisma/schema.prisma",
"prebuild:production": "pnpm clean",
"build:production": "pnpm prisma:generate && nest build -p tsconfig.production.json",
"prisma:dbpush": "prisma db push --schema=./src/prisma/schema.prisma",
"prisma:generate": "prisma generate --schema=./src/prisma/schema.prisma",
"prisma:migrate": "npx prisma migrate deploy --schema=./src/prisma/schema.prisma",
"prismaStudio": "npx prisma studio",
"prisma:migrate": "prisma migrate deploy --schema=./src/prisma/schema.prisma",
"prisma:studio": "prisma studio",
"start": "nest start",
"start:docker": "yarn prisma:generate && yarn dbSchema && yarn start",
"lint": "eslint --fix",
"lint:all": "npm run lint -- .",
"format": "prettier --write",
"format:all": "npm run format -- .",
"start:dev": "nest start --watch --preserveWatchOutput",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
......@@ -40,6 +38,7 @@
"@prisma/client": "^5.6.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"express": "^4.17.3",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",
"jwks-rsa": "^3.1.0",
......@@ -65,17 +64,10 @@
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.9.0",
"@types/supertest": "^2.0.16",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"dotenv-cli": "^7.3.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"node-mocks-http": "^1.13.0",
"prettier": "^3.1.0",
"prisma": "^5.6.0",
"rimraf": "^5.0.5",
"source-map-support": "^0.5.21",
......
process.env.PORT = 3005;
process.env.NODE_ENV = 'development';
import {
MiddlewareConsumer,
Module,
NestModule,
RequestMethod,
type MiddlewareConsumer,
type NestModule,
} from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER } from '@nestjs/core';
import { TerminusModule } from '@nestjs/terminus';
import ExceptionHandler from './common/exception.handler.js';
import config from './config/config.js';
import validationSchema from './config/validation.js';
......@@ -39,7 +40,7 @@ import UserInfoModule from './userInfo/module.js';
],
})
export default class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
public configure(consumer: MiddlewareConsumer) {
// eslint-disable-line
consumer
.apply(AuthMiddleware)
......
import { Inject, Injectable } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { lastValueFrom } from 'rxjs';
import { Connection, NATSServices } from '../common/constants.js';
@Injectable()
export default class NatsClientService {
constructor(
public constructor(
@Inject(NATSServices.SERVICE_NAME) private natsClient: ClientProxy,
) {}
getConnectionById(connectionId: string) {
public getConnectionById(connectionId: string) {
const pattern = {
endpoint: `${Connection.NATS_ENDPOINT}/${Connection.GET_CONNECTION_BY_ID}`,
};
......@@ -17,7 +18,7 @@ export default class NatsClientService {
return lastValueFrom(this.natsClient.send(pattern, payload));
}
connectionTrusted(connectionId: string) {
public connectionTrusted(connectionId: string) {
const pattern = {
endpoint: `${Connection.NATS_ENDPOINT}/${Connection.MAKE_CONNECTION_TRUSTED}`,
};
......@@ -25,7 +26,7 @@ export default class NatsClientService {
return lastValueFrom(this.natsClient.send(pattern, payload));
}
getReceivedConnections() {
public getReceivedConnections() {
const pattern = {
endpoint: `${Connection.NATS_ENDPOINT}/${Connection.GET_RECEIVED_CONNECTIONS}`,
};
......
......@@ -4,15 +4,15 @@ import { lastValueFrom, map } from 'rxjs';
@Injectable()
export default class RestClientService {
constructor(private readonly httpService: HttpService) {}
public constructor(private readonly httpService: HttpService) {}
async delete(url: string) {
public async delete(url: string) {
return lastValueFrom(
this.httpService.delete(url).pipe(map((response) => response.data)),
);
}
async post(url: string, payload: object) {
public async post(url: string, payload: object) {
return lastValueFrom(
this.httpService
.post(url, payload)
......@@ -20,7 +20,7 @@ export default class RestClientService {
);
}
async get(url: string) {
public async get(url: string) {
return lastValueFrom(
this.httpService.get(url).pipe(map((response) => response.data)),
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment