-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from OXeu/feat_logger
feat: add utils/logger 🧀
- Loading branch information
Showing
6 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,3 +178,4 @@ dist | |
|
||
# Finder (MacOS) folder config | ||
.DS_Store | ||
bunfig.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import cors from '@elysiajs/cors'; | ||
import { Elysia } from 'elysia'; | ||
import { Logestic } from 'logestic'; | ||
import { PostService } from './action/post'; | ||
import { UserService } from './action/user'; | ||
import { migration } from './db/migrate'; | ||
import {logPlugin, logger} from './utils/logger' | ||
|
||
migration() | ||
|
||
const log = Logestic.preset('fancy') | ||
export const app = new Elysia() | ||
.use(cors()) | ||
.use(log) | ||
.use(logPlugin) | ||
.use(UserService) | ||
.use(PostService) | ||
.get('/', ({uid}) => `Hi ${uid}`) | ||
.get('/', ({ uid }) => `Hi ${uid}`) | ||
.onError(({ code }) => { | ||
if (code === 'NOT_FOUND') | ||
return ':(' | ||
}) | ||
.listen(process.env.PORT ?? 3001) | ||
.listen(process.env.PORT ?? 3001, () => { | ||
logger.info(`[Rim] Server is running: http://localhost:${process.env.PORT ?? 3001}`) | ||
}) | ||
|
||
export type App = typeof app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* @Author: Bin | ||
* @Date: 2024-05-22 | ||
* @FilePath: /oXeu_rin/src/utils/index.ts | ||
*/ | ||
|
||
export * from './logger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* @Author: Bin | ||
* @Date: 2024-05-22 | ||
* @FilePath: /oXeu_rin/src/utils/logger.ts | ||
*/ | ||
import { Logestic } from 'logestic'; | ||
|
||
const logPlugin = Logestic.preset('fancy') | ||
const {logestic: logger} = logPlugin.decorator; | ||
|
||
export {logPlugin, logger} |