Skip to content

Commit

Permalink
Merge pull request #2 from 2060-io/feat/credo-0.5
Browse files Browse the repository at this point in the history
feat: update to credo 0.5.0
  • Loading branch information
genaris authored Mar 20, 2024
2 parents 38eeb69 + bebbccb commit fb8af7c
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 584 deletions.
34 changes: 16 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
"postinstall": "patch-package"
},
"dependencies": {
"@credo-ts/action-menu": "^0.5.0-alpha.138",
"@credo-ts/anoncreds": "^0.5.0-alpha.138",
"@credo-ts/askar": "^0.5.0-alpha.138",
"@credo-ts/core": "^0.5.0-alpha.138",
"@credo-ts/node": "^0.5.0-alpha.138",
"@credo-ts/question-answer": "^0.5.0-alpha.138",
"@hyperledger/anoncreds-nodejs": "^0.2.0",
"@credo-ts/action-menu": "^0.5.0",
"@credo-ts/anoncreds": "^0.5.0",
"@credo-ts/askar": "^0.5.0",
"@credo-ts/core": "^0.5.0",
"@credo-ts/node": "^0.5.0",
"@credo-ts/question-answer": "^0.5.0",
"@hyperledger/anoncreds-nodejs": "^0.2.1",
"@hyperledger/aries-askar-nodejs": "^0.2.0",
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
Expand All @@ -84,7 +84,6 @@
"qrcode": "^1.5.3",
"reflect-metadata": "^0.1.13",
"swagger-ui-express": "^4.4.0",
"tslog": "^3.3.3",
"tsyringe": "4.8.0",
"uuid": "^9.0.0",
"yargs": "^17.3.1"
Expand All @@ -111,29 +110,28 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"ngrok": "^4.3.1",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"prettier": "^3.2.5",
"supertest": "^6.2.3",
"ts-jest": "^27.0.7",
"ts-node-dev": "^2.0.0",
"tsconfig-paths": "^4.1.0",
"typescript": "4.7.4"
"typescript": "^5.3.3"
},
"resolutions": {
"@types/node": "18.0.3",
"typescript": "4.7.4",
"@types/node": "20.11.19",
"typescript": "5.3.3",
"tsyringe": "4.8.0",
"@hyperledger/anoncreds-nodejs": "0.2.1",
"@hyperledger/aries-askar-nodejs": "0.2.0",
"@hyperledger/anoncreds-shared": "0.2.1",
"@hyperledger/aries-askar-shared": "0.2.0",
"@credo-ts/action-menu": "0.5.0-alpha.138",
"@credo-ts/core": "0.5.0-alpha.138",
"@credo-ts/question-answer": "0.5.0-alpha.138",
"@credo-ts/node": "0.5.0-alpha.138",
"@credo-ts/askar": "0.5.0-alpha.138",
"@credo-ts/anoncreds": "0.5.0-alpha.138"
"@credo-ts/action-menu": "0.5.0",
"@credo-ts/core": "0.5.0",
"@credo-ts/question-answer": "0.5.0",
"@credo-ts/node": "0.5.0",
"@credo-ts/askar": "0.5.0",
"@credo-ts/anoncreds": "0.5.0"
}
}
File renamed without changes.
13 changes: 0 additions & 13 deletions patches/web-did-resolver+2.0.23.patch

This file was deleted.

173 changes: 0 additions & 173 deletions src/controllers/examples.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const run = async () => {

const serverLogger = new TsLogger(
process.env.ADMIN_LOG_LEVEL ? Number(process.env.ADMIN_LOG_LEVEL) : LogLevel.debug,
'Server',
)

const conf: ServerConfig = {
Expand Down
38 changes: 6 additions & 32 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,27 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import type { ILogObject } from 'tslog'

import { LogLevel, BaseLogger } from '@credo-ts/core'
import { appendFileSync } from 'fs'
import { Logger } from 'tslog'
import { Logger } from '@nestjs/common'
import util from 'util'

function logToTransport(logObject: ILogObject) {
appendFileSync('logs.txt', JSON.stringify(logObject) + '\n')
}

export class TsLogger extends BaseLogger {
private logger: Logger

// Map our log levels to tslog levels
private tsLogLevelMap = {
[LogLevel.test]: 'silly',
[LogLevel.trace]: 'trace',
[LogLevel.test]: 'debug',
[LogLevel.trace]: 'debug',
[LogLevel.debug]: 'debug',
[LogLevel.info]: 'info',
[LogLevel.info]: 'log',
[LogLevel.warn]: 'warn',
[LogLevel.error]: 'error',
[LogLevel.fatal]: 'fatal',
} as const

public constructor(logLevel: LogLevel, name?: string) {
public constructor(logLevel: LogLevel, name: string) {
super(logLevel)

this.logger = new Logger({
name,
minLevel: this.logLevel == LogLevel.off ? undefined : this.tsLogLevelMap[this.logLevel],
ignoreStackLevels: 1,
attachedTransports: [
{
transportLogger: {
silly: logToTransport,
debug: logToTransport,
trace: logToTransport,
info: logToTransport,
warn: logToTransport,
error: logToTransport,
fatal: logToTransport,
},
// always log to file
minLevel: 'silly',
},
],
})
this.logger = new Logger(name)
}

private log(level: Exclude<LogLevel, LogLevel.off>, message: string, data?: Record<string, any>): void {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/setupAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const setupAgent = async ({
enableHttp?: boolean
useCors?: boolean
}) => {
const logger = new TsLogger(logLevel ?? LogLevel.warn)
const logger = new TsLogger(logLevel ?? LogLevel.warn, 'Agent')

if (!enableHttp && !enableWs) {
throw new Error('No transport has been enabled. Set at least one of HTTP and WS')
Expand Down
12 changes: 0 additions & 12 deletions tsoa.json

This file was deleted.

Loading

0 comments on commit fb8af7c

Please sign in to comment.