initial commit
This commit is contained in:
commit
a7e3f110a0
|
@ -0,0 +1,2 @@
|
|||
NODE_ENV=development
|
||||
LOG_LEVEL=trace
|
|
@ -0,0 +1,3 @@
|
|||
node_modules
|
||||
dist
|
||||
.env
|
|
@ -0,0 +1,4 @@
|
|||
import { logger } from "#root/logger.js";
|
||||
|
||||
logger.info("Hello!");
|
||||
logger.debug("I am a teapot");
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#root/*": "./dist/src/*"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "npm run clean && tsc-watch --onSuccess \"tsx index.ts\"",
|
||||
"build": "npm run clean && tsc --noEmit false",
|
||||
"clean": "rimraf dist"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.10",
|
||||
"rimraf": "^5.0.5",
|
||||
"tsc-watch": "^6.0.4",
|
||||
"tsx": "^3.14.0",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.3.1",
|
||||
"envalid": "^7.3.1",
|
||||
"pino": "^8.16.1",
|
||||
"pino-pretty": "^10.2.3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import 'dotenv/config';
|
||||
import { cleanEnv, str } from 'envalid';
|
||||
|
||||
export const env = cleanEnv(process.env, {
|
||||
NODE_ENV: str({ choices: ["development", "production"] }),
|
||||
LOG_LEVEL: str({
|
||||
choices: ["trace", "debug", "info", "warn", "error", "fatal", "silent"],
|
||||
}),
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import { env } from "#root/env.js";
|
||||
import { LoggerOptions, pino } from "pino";
|
||||
import PinoPretty, { PrettyOptions } from "pino-pretty";
|
||||
|
||||
const options: LoggerOptions = {
|
||||
level: env.LOG_LEVEL
|
||||
};
|
||||
|
||||
const prettyOptions: PrettyOptions = {
|
||||
ignore: 'pid,hostname',
|
||||
colorize: env.isDev ? true : false,
|
||||
translateTime: 'SYS:dd.mm.yyyy, HH:MM:ss'
|
||||
};
|
||||
|
||||
export let logger = pino(options);
|
||||
|
||||
if (env.isDev) {
|
||||
// @ts-ignore
|
||||
logger = pino(options, PinoPretty(prettyOptions));
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"preserveWatchOutput": true,
|
||||
"noEmit": true,
|
||||
"module": "NodeNext",
|
||||
"target": "ES2021",
|
||||
"moduleResolution": "NodeNext",
|
||||
"sourceMap": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"paths": {
|
||||
"#root/*": [
|
||||
"./src/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"index.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue