🧹 Moved Sb1 API to separate workspace and created common workspace
- Created common workspace - Create Sparebank1Api workspace - Moved logger to common - Moved SB1 types to types.ts - Logger will avoid duplicating first line when capturing console.logs - Updated imports and added type keyword - Added nonUniqueId type
This commit is contained in:
3
packages/common/date.ts
Normal file
3
packages/common/date.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { type Dayjs } from "dayjs"
|
||||
|
||||
export const toISODateString = (day: Dayjs): string => day.format("YYYY-MM-DD")
|
21
packages/common/logger.ts
Normal file
21
packages/common/logger.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import pino from "pino"
|
||||
import { LOG_LEVEL } from "@/../config.ts"
|
||||
|
||||
/**
|
||||
* / Returns a logging instance with the default log-level "info"
|
||||
*/
|
||||
const logger = pino(
|
||||
pino.destination({
|
||||
level: LOG_LEVEL,
|
||||
}),
|
||||
)
|
||||
|
||||
console.log = function (...args): void {
|
||||
if (args.length > 1) {
|
||||
logger.info(args?.slice(1), args?.[0])
|
||||
} else {
|
||||
logger.info(args?.[0])
|
||||
}
|
||||
}
|
||||
|
||||
export default logger
|
12
packages/common/package.json
Normal file
12
packages/common/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "common",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"pino": "^9.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"pino-pretty": "^13.0.0"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user