refactor(fastify): use ServerConfig type from core
This commit is contained in:
parent
97c04c21b9
commit
c4f8a2c779
4 changed files with 2389 additions and 6635 deletions
|
|
@ -1,6 +1,18 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { defineCommand, runMain, type ArgsDef, type CommandDef } from 'citty'
|
import { defineCommand, runMain, type ArgsDef, type CommandDef } from 'citty'
|
||||||
|
|
||||||
|
export type Logger = {
|
||||||
|
log: Function
|
||||||
|
error: Function
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ServerConfig = {
|
||||||
|
rootDir: string
|
||||||
|
apiDir: string
|
||||||
|
port: number
|
||||||
|
logger: Logger
|
||||||
|
}
|
||||||
|
|
||||||
const main: CommandDef<ArgsDef> = defineCommand({
|
const main: CommandDef<ArgsDef> = defineCommand({
|
||||||
meta: {
|
meta: {
|
||||||
name: 'mcfly',
|
name: 'mcfly',
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/autoload": "6.3.1",
|
"@fastify/autoload": "6.3.1",
|
||||||
"fastify": "5.8.5"
|
"fastify": "5.8.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@mcflyjs/core": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@ import Fastify from 'fastify'
|
||||||
import AutoLoad from '@fastify/autoload'
|
import AutoLoad from '@fastify/autoload'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('@mcflyjs/core').ServerConfig} ServerConfig
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ServerConfig} param
|
||||||
|
*/
|
||||||
export default ({ rootDir, apiDir, logger, port }) => {
|
export default ({ rootDir, apiDir, logger, port }) => {
|
||||||
const server = Fastify()
|
const server = Fastify()
|
||||||
const portNumber = port ?? 3000
|
const portNumber = port ?? 3000
|
||||||
|
|
|
||||||
9002
pnpm-lock.yaml
9002
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue