-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support request notice log & string log format
- Loading branch information
Showing
23 changed files
with
559 additions
and
59 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 |
---|---|---|
|
@@ -104,4 +104,6 @@ dist | |
.tern-port | ||
|
||
# mac | ||
.DS_Store | ||
.DS_Store | ||
|
||
log/ |
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,2 +1,4 @@ | ||
# hoth | ||
A Node.js framework based on fastify | ||
|
||
under development |
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,3 @@ | ||
export default { | ||
'@hoth/app-autoload': {}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
example/hoth-quickstart/src/controller/app/app.controller.ts
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,16 @@ | ||
import {Controller, getFastifyInstanceByAppName, GET} from '@hoth/decorators'; | ||
import {FastifyReply, FastifyRequest} from 'fastify'; | ||
|
||
@Controller('/app') | ||
export default class AppController { | ||
|
||
private readonly service = getFastifyInstanceByAppName('quickstart'); | ||
|
||
@GET() | ||
getApp(req: FastifyRequest, reply: FastifyReply) { | ||
reply.log.info(`config test value ${req.$appConfig.get('test')}`); | ||
reply.log.error({err: new Error('hello1')}); | ||
reply.log.warn('test error'); | ||
reply.send('ok'); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
example/hoth-quickstart/src/controller/post/post.controller.ts
This file was deleted.
Oops, something went wrong.
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,7 +1,8 @@ | ||
{ | ||
"watch": ["packages/*/src", "example/*/src"], | ||
"ignore": ["*.test.ts"], | ||
"watch": ["*.ts"], | ||
"ignore": ["*.test.ts", "node_modules/*", "*.d.ts"], | ||
"ext": "ts,js", | ||
"exec": "yarn run build && yarn run hoth start --app-dir='example/hoth-quickstart/dist'", | ||
"legacyWatch": true | ||
"exec": "yarn run build && NODE_ENV=development yarn run hoth start --app-dir='example/hoth-quickstart/dist' --app-name='quickstart'", | ||
"legacyWatch": true, | ||
"require": ["source-map-support/register"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {FastifyReply, FastifyRequest} from 'fastify'; | ||
|
||
declare module 'fastify' { | ||
interface FastifyLoggerInstance { | ||
notice: (...args: any[]) => void; | ||
} | ||
} | ||
|
||
export default function (req: FastifyRequest, reply: FastifyReply, done) { | ||
const responseTime = reply.getResponseTime(); | ||
reply.log.notice({ | ||
res: reply, | ||
responseTime: responseTime.toFixed(1), | ||
}, 'request completed'); | ||
done(); | ||
} |
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,8 @@ | ||
import {FastifyReply, FastifyRequest} from 'fastify'; | ||
|
||
export default function (app: string) { | ||
return function (req: FastifyRequest, reply: FastifyReply, done) { | ||
req.log = reply.log = reply.log.child({req, app}); | ||
done(); | ||
}; | ||
} |
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
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
Oops, something went wrong.