feat: use fastify as server #2
31 changed files with 270 additions and 651 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -8,7 +8,6 @@
|
|||
"hookable",
|
||||
"mcfly",
|
||||
"mcflyjs",
|
||||
"nitropack",
|
||||
"ultrahtml",
|
||||
"unstorage"
|
||||
],
|
||||
|
|
|
|||
3
mcfly.config.mjs
Normal file
3
mcfly.config.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export default {
|
||||
from: 'root',
|
||||
}
|
||||
|
|
@ -9,8 +9,7 @@
|
|||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./define-mcfly-config": "./dist/define-mcfly-config.js",
|
||||
"./nitro-config": "./dist/nitro-config.js"
|
||||
"./define-config": "./dist/define-config.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --erasableSyntaxOnly",
|
||||
|
|
@ -32,8 +31,5 @@
|
|||
"dependencies": {
|
||||
"h3": "^1.15.1",
|
||||
"web-component-base": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nitropack": "~2.11.7"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import type { NitroConfig } from 'nitropack'
|
||||
|
||||
export type McFlyConfig = {
|
||||
components: 'js' | 'lit'
|
||||
nitro?: NitroConfig
|
||||
server: McFlyServer
|
||||
components?: 'js' | 'lit'
|
||||
plugins?: McFlyPlugin[]
|
||||
}
|
||||
|
||||
|
|
@ -11,7 +9,7 @@ export type McFlyConfig = {
|
|||
* @param {McFlyConfig} config
|
||||
* @returns {function(): McFlyConfig}e
|
||||
*/
|
||||
export function defineMcFlyConfig(config: McFlyConfig) {
|
||||
export function defineConfig(config: McFlyConfig) {
|
||||
return () => config
|
||||
}
|
||||
|
||||
|
|
@ -19,3 +17,5 @@ export function defineMcFlyConfig(config: McFlyConfig) {
|
|||
* TODO: finalize Plugin type
|
||||
*/
|
||||
export type McFlyPlugin = {}
|
||||
|
||||
export type McFlyServer = any
|
||||
|
|
@ -1 +1 @@
|
|||
export { type McFlyConfig, defineMcFlyConfig } from './define-mcfly-config.js'
|
||||
export { type McFlyConfig, defineConfig } from './define-config.js'
|
||||
|
|
|
|||
|
|
@ -3,17 +3,16 @@
|
|||
"version": "0.8.8",
|
||||
"description": "McFly core package",
|
||||
"type": "module",
|
||||
"main": "./dist/cli/index.js",
|
||||
"main": "./dist/index.js",
|
||||
"bin": {
|
||||
"mcfly": "./dist/cli/index.js"
|
||||
"mcfly": "./dist/index.js"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/cli/index.d.ts",
|
||||
"default": "./dist/cli/index.js"
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./runtime": "./dist/runtime/index.js",
|
||||
"./cli": "./dist/cli/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
|
|
@ -43,7 +42,6 @@
|
|||
"devalue": "^5.1.1",
|
||||
"esprima": "^4.0.1",
|
||||
"h3": "^1.15.1",
|
||||
"nitropack": "^2.11.7",
|
||||
"pathe": "^2.0.3",
|
||||
"ultrahtml": "^1.5.3"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { consola } from 'consola'
|
||||
import { colorize } from 'consola/utils'
|
||||
import { defineCommand, type ParsedArgs } from 'citty'
|
||||
import { createRequire } from 'node:module'
|
||||
import {
|
||||
type Nitro,
|
||||
build,
|
||||
createDevServer,
|
||||
createNitro,
|
||||
prepare,
|
||||
prerender,
|
||||
} from 'nitropack'
|
||||
import { resolve } from 'pathe'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname } from 'pathe'
|
||||
import { getMcFlyConfig, getNitroConfig } from '../../get-config.js'
|
||||
|
||||
const hmrKeyRe = /^runtimeConfig\.|routeRules\./
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
async function printInfo() {
|
||||
try {
|
||||
const _require = createRequire(import.meta.url)
|
||||
const mcflyPkg = await _require('@mcflyjs/core/package.json')
|
||||
const mcflyPkgVersion = `McFly ${colorize('bold', mcflyPkg.version)}`
|
||||
const nitroPkg = await _require('nitropack/package.json')
|
||||
const nitroPkgVersion = `Nitro ${nitroPkg.version}`
|
||||
consola.log(
|
||||
`${colorize('blue', mcflyPkgVersion)} ${colorize('dim', nitroPkgVersion)}`
|
||||
)
|
||||
} catch (e) {
|
||||
consola.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function serve(args: ParsedArgs) {
|
||||
try {
|
||||
// TODO: check for dir type (should be string)
|
||||
const dir = args.dir?.toString() || args._dir?.toString()
|
||||
const rootDir: string = resolve(dir || '.')
|
||||
|
||||
let nitro: Nitro
|
||||
const reload = async () => {
|
||||
// close existing nitro
|
||||
if (nitro) {
|
||||
consola.info('Restarting dev server...')
|
||||
if ('unwatch' in nitro.options._c12) {
|
||||
await nitro.options._c12.unwatch()
|
||||
}
|
||||
await nitro.close()
|
||||
}
|
||||
|
||||
const { mcflyConfig, configFile } = await getMcFlyConfig()
|
||||
const nitroConfig = await getNitroConfig(mcflyConfig)
|
||||
|
||||
// create new nitro
|
||||
nitro = await createNitro(
|
||||
{
|
||||
rootDir,
|
||||
dev: true,
|
||||
preset: 'nitro-dev',
|
||||
_cli: { command: 'dev' },
|
||||
...nitroConfig,
|
||||
},
|
||||
{
|
||||
watch: true,
|
||||
c12: {
|
||||
async onUpdate({ getDiff, newConfig }: any) {
|
||||
const diff = getDiff()
|
||||
|
||||
if (diff.length === 0) {
|
||||
return // No changes
|
||||
}
|
||||
|
||||
consola.info(
|
||||
'Nitro config updated:\n' +
|
||||
diff
|
||||
.map((entry: unknown) => ` ${entry?.toString()}`)
|
||||
.join('\n')
|
||||
)
|
||||
|
||||
// TODO: get types for c12 config & remove unknown
|
||||
// @ts-ignore
|
||||
await (diff.every((e: unknown) => hmrKeyRe.test(e.key))
|
||||
? nitro.updateConfig(newConfig.config || {}) // Hot reload
|
||||
: reload()) // Full reload
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
nitro.hooks.hookOnce('restart', reload)
|
||||
nitro.options.runtimeConfig.appConfigFile = configFile
|
||||
|
||||
nitro.options.handlers.push({
|
||||
middleware: true,
|
||||
handler: resolve(__dirname, '../../route-middleware.js'),
|
||||
})
|
||||
const server = createDevServer(nitro)
|
||||
|
||||
// const listenOptions = parseArgs(args)
|
||||
await server.listen(1234)
|
||||
await prepare(nitro)
|
||||
await prerender(nitro)
|
||||
await build(nitro)
|
||||
}
|
||||
await reload()
|
||||
} catch (e) {
|
||||
consola.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: 'serve',
|
||||
description: 'Runs the dev server.',
|
||||
},
|
||||
async run({ args }) {
|
||||
await printInfo()
|
||||
await serve(args)
|
||||
},
|
||||
})
|
||||
|
||||
export const exportedForTest = {
|
||||
serve,
|
||||
printInfo,
|
||||
}
|
||||
|
|
@ -3,15 +3,8 @@
|
|||
import { consola } from 'consola'
|
||||
import { defineCommand, type ParsedArgs } from 'citty'
|
||||
import { dirname, resolve } from 'pathe'
|
||||
import {
|
||||
build,
|
||||
copyPublicAssets,
|
||||
createNitro,
|
||||
prepare,
|
||||
prerender,
|
||||
} from 'nitropack'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { getMcFlyConfig, getNitroConfig } from '../../get-config.js'
|
||||
import { getMcFlyConfig } from '../get-config.js'
|
||||
|
||||
async function _build(args: ParsedArgs) {
|
||||
consola.start('Building project...')
|
||||
|
|
@ -21,33 +14,11 @@ async function _build(args: ParsedArgs) {
|
|||
const rootDir = resolve(dir)
|
||||
|
||||
const { mcflyConfig, configFile } = await getMcFlyConfig()
|
||||
const nitroConfig = await getNitroConfig(mcflyConfig)
|
||||
|
||||
const nitro = await createNitro({
|
||||
rootDir,
|
||||
dev: false,
|
||||
|
||||
...nitroConfig,
|
||||
|
||||
minify: args.minify ?? nitroConfig.minify,
|
||||
preset: args.preset ?? nitroConfig.preset,
|
||||
})
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
nitro.options.handlers.push({
|
||||
middleware: true,
|
||||
handler: resolve(__dirname, '../../route-middleware.js'),
|
||||
})
|
||||
|
||||
nitro.options.runtimeConfig.appConfigFile = configFile
|
||||
|
||||
await prepare(nitro)
|
||||
await copyPublicAssets(nitro)
|
||||
await prerender(nitro)
|
||||
await build(nitro)
|
||||
await nitro.close()
|
||||
consola.info('dir', __dirname)
|
||||
} catch (err) {
|
||||
consola.error(err)
|
||||
}
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
import { consola } from 'consola'
|
||||
import { defineCommand, type ParsedArgs } from 'citty'
|
||||
import { resolve } from 'pathe'
|
||||
import { createNitro, writeTypes } from 'nitropack'
|
||||
import { getMcFlyConfig, getNitroConfig } from '../../get-config.js'
|
||||
import { getMcFlyConfig } from '../get-config.js'
|
||||
|
||||
async function prepare(args: ParsedArgs) {
|
||||
consola.start('Preparing McFly workspace...')
|
||||
|
|
@ -16,10 +15,8 @@ async function prepare(args: ParsedArgs) {
|
|||
const dir: string = args.dir?.toString() || args._dir?.toString() || '.'
|
||||
const rootDir = resolve(dir)
|
||||
const { mcflyConfig } = await getMcFlyConfig()
|
||||
const nitroConfig = await getNitroConfig(mcflyConfig)
|
||||
const nitro = await createNitro({ rootDir, ...nitroConfig })
|
||||
|
||||
await writeTypes(nitro)
|
||||
consola.info({ mcflyConfig, rootDir })
|
||||
} catch (e) {
|
||||
consola.error(e)
|
||||
err = e
|
||||
57
packages/core/src/commands/serve.ts
Normal file
57
packages/core/src/commands/serve.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { consola } from 'consola'
|
||||
import { colorize } from 'consola/utils'
|
||||
import { defineCommand, type ParsedArgs } from 'citty'
|
||||
import { createRequire } from 'node:module'
|
||||
import { resolve } from 'pathe'
|
||||
// import { fileURLToPath } from 'node:url'
|
||||
// import { dirname } from 'pathe'
|
||||
import { getMcFlyConfig } from '../get-config.js'
|
||||
|
||||
// const __filename = fileURLToPath(import.meta.url)
|
||||
// const __dirname = dirname(__filename)
|
||||
|
||||
async function printInfo() {
|
||||
try {
|
||||
const _require = createRequire(import.meta.url)
|
||||
const mcflyPkg = await _require('@mcflyjs/core/package.json')
|
||||
const mcflyPkgVersion = `McFly ${colorize('bold', mcflyPkg.version)}`
|
||||
consola.log(`${colorize('blue', mcflyPkgVersion)}`)
|
||||
} catch (e) {
|
||||
consola.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function serve(args: ParsedArgs) {
|
||||
try {
|
||||
// TODO: check for dir type (should be string)
|
||||
const dir = args.dir?.toString() || args._dir?.toString()
|
||||
const rootDir: string = resolve(dir || '.')
|
||||
|
||||
const { mcflyConfig } = await getMcFlyConfig()
|
||||
|
||||
/**
|
||||
* TODO: config for srcDir
|
||||
*/
|
||||
mcflyConfig.server.serve({ rootDir: rootDir + '/src', apiDir: '/api' })
|
||||
} catch (e) {
|
||||
consola.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: 'serve',
|
||||
description: 'Runs the dev server.',
|
||||
},
|
||||
async run({ args }) {
|
||||
await printInfo()
|
||||
await serve(args)
|
||||
},
|
||||
})
|
||||
|
||||
export const exportedForTest = {
|
||||
serve,
|
||||
printInfo,
|
||||
}
|
||||
|
|
@ -1,27 +1,4 @@
|
|||
import { loadConfig } from 'c12'
|
||||
import { mcflyNitroConfig } from './mcfly-nitro-config.js'
|
||||
|
||||
/**
|
||||
* @typedef {import('nitropack').NitroConfig} NitroConfig
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a valid Nitro configuration given a McFly config object
|
||||
* @returns {Promise<NitroConfig>}
|
||||
*/
|
||||
export async function getNitroConfig(mcflyConfig = {}) {
|
||||
const { config: nitroConfig } = await loadConfig({ name: 'nitro' })
|
||||
return {
|
||||
// nitro config in mcfly config
|
||||
...mcflyConfig.nitro,
|
||||
|
||||
// nitro config from nitro config
|
||||
...(nitroConfig ?? {}),
|
||||
|
||||
// McFly standard nitro config
|
||||
...mcflyNitroConfig,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getMcFlyConfig() {
|
||||
const { config: mcflyConfig, configFile } = await loadConfig({
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
import { type NitroConfig } from 'nitropack'
|
||||
|
||||
/**
|
||||
* @typedef {import('nitropack').NitroConfig} NitroConfig
|
||||
* @type {NitroConfig}
|
||||
*/
|
||||
export const mcflyNitroConfig: NitroConfig = {
|
||||
framework: {
|
||||
name: 'McFly',
|
||||
},
|
||||
compatibilityDate: '2024-12-08',
|
||||
srcDir: 'src',
|
||||
apiDir: 'api',
|
||||
devServer: {
|
||||
watch: ['./pages', './components', './api'],
|
||||
},
|
||||
serverAssets: [
|
||||
{
|
||||
baseName: 'pages',
|
||||
dir: './pages',
|
||||
},
|
||||
{
|
||||
baseName: 'components',
|
||||
dir: './components',
|
||||
},
|
||||
],
|
||||
imports: {
|
||||
presets: [
|
||||
{
|
||||
from: 'web-component-base',
|
||||
imports: ['WebComponent', 'html', 'attachEffect'],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
import { eventHandler } from 'h3'
|
||||
import { useStorage } from 'nitropack/runtime'
|
||||
import { createHooks } from 'hookable'
|
||||
import { consola } from 'consola'
|
||||
import { colorize } from 'consola/utils'
|
||||
import { useRuntimeConfig } from 'nitropack/runtime'
|
||||
import { dirname, relative } from 'pathe'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import {
|
||||
hooks as mcflyHooks,
|
||||
defaultMcflyConfig,
|
||||
evaluateServerScripts,
|
||||
injectHtmlFragments,
|
||||
injectCustomElements,
|
||||
} from '@mcflyjs/core/runtime' // important to import from installed node_module because this script is passed to another context
|
||||
|
||||
/**
|
||||
* @typedef {import('../config').McFlyConfig} Config
|
||||
* @typedef {import('unstorage').Storage} Storage
|
||||
* @typedef {import('unstorage').StorageValue} StorageValue
|
||||
* @typedef {import('h3').EventHandler} EventHandler
|
||||
*/
|
||||
|
||||
/**
|
||||
* McFly middleware event handler
|
||||
*/
|
||||
export default eventHandler(async (event) => {
|
||||
const timeStart = performance.now()
|
||||
const hooks = createHooks()
|
||||
Object.keys(mcflyHooks).forEach((hookName) => hooks.addHooks(hookName))
|
||||
const { path } = event
|
||||
const storage = useStorage()
|
||||
|
||||
const { appConfigFile } = useRuntimeConfig()
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
let relativePath = relative(__dirname, appConfigFile)
|
||||
|
||||
let config
|
||||
// TODO: this still doesn't work on Netlify
|
||||
try {
|
||||
const { default: configFn } = await import(relativePath)
|
||||
config = configFn()
|
||||
} catch (err) {
|
||||
consola.error(err)
|
||||
}
|
||||
|
||||
// if not page, don't render
|
||||
if (event.path.startsWith('/api')) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!config || Object.keys(config).length === 0) {
|
||||
config = defaultMcflyConfig
|
||||
consola.warn(
|
||||
`[WARN]: McFly configuration not found, using defaults...`,
|
||||
defaultMcflyConfig
|
||||
)
|
||||
}
|
||||
|
||||
const plugins = config.plugins ?? []
|
||||
|
||||
plugins.forEach((plugin) => {
|
||||
const pluginHooks = Object.keys(plugin)
|
||||
pluginHooks.forEach((pluginHook) => {
|
||||
hooks.hook(pluginHook, plugin[pluginHook])
|
||||
})
|
||||
})
|
||||
|
||||
const { components: componentType } = config
|
||||
let html = await getHtml(path, storage)
|
||||
|
||||
if (html) {
|
||||
const transforms = [
|
||||
{
|
||||
fn: evaluateServerScripts,
|
||||
args: [event],
|
||||
hook: mcflyHooks.serverScriptsEvaluated,
|
||||
},
|
||||
{
|
||||
fn: injectHtmlFragments,
|
||||
args: [storage],
|
||||
hook: mcflyHooks.fragmentsInjected,
|
||||
},
|
||||
{
|
||||
fn: injectCustomElements,
|
||||
args: [componentType, storage],
|
||||
hook: mcflyHooks.customElementsInjected,
|
||||
},
|
||||
]
|
||||
|
||||
if (!!componentType && !!html) {
|
||||
for (const transform of transforms) {
|
||||
html = await transform.fn(html.toString(), ...transform.args)
|
||||
|
||||
// call hook
|
||||
if (transform.hook) {
|
||||
// not sure if we want to await, for now it makes the outcome predictable
|
||||
await hooks.callHook(transform.hook)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
consola.error('[ERR]: Failed to insert registry', {
|
||||
componentType: !componentType ? 'missing' : 'okay',
|
||||
html: !html ? 'missing' : 'okay',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (html) {
|
||||
await hooks.callHook(mcflyHooks.pageRendered)
|
||||
}
|
||||
|
||||
const timeEnd = performance.now()
|
||||
consola.info(
|
||||
colorize('green', event.path),
|
||||
'rendered in',
|
||||
Math.round(timeEnd - timeStart),
|
||||
'ms'
|
||||
)
|
||||
return (
|
||||
html ??
|
||||
new Response(
|
||||
'😱 ERROR 404: Not found. You can put a 404.html on the ./src/pages directory to customize this error page.',
|
||||
{ status: 404 }
|
||||
)
|
||||
)
|
||||
})
|
||||
/**
|
||||
* Gets the storage path for a file
|
||||
* @param {string} filename
|
||||
* @returns {string}
|
||||
*/
|
||||
function getPath(filename) {
|
||||
return `assets:pages${filename}`
|
||||
}
|
||||
|
||||
function getPurePath(path) {
|
||||
return path.split('?')[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the correct HTML depending on the path requested
|
||||
* @param {string} path
|
||||
* @param {Storage} storage
|
||||
* @returns {Promise<StorageValue>}
|
||||
*/
|
||||
async function getHtml(path, storage) {
|
||||
const purePath = getPurePath(path)
|
||||
const rawPath =
|
||||
purePath[purePath.length - 1] === '/' ? purePath.slice(0, -1) : purePath
|
||||
const filename = rawPath === '' ? '/index.html' : `${rawPath}.html`
|
||||
const fallback = getPath(rawPath + '/index.html')
|
||||
const filePath = getPath(filename)
|
||||
let html = await storage.getItem(filePath)
|
||||
if (!html) html = await storage.getItem(fallback)
|
||||
if (!html) html = await storage.getItem(getPath('/404.html'))
|
||||
|
||||
return html
|
||||
}
|
||||
|
|
@ -4,4 +4,3 @@ export { getFiles } from './get-files.js'
|
|||
export { hooks } from './hooks.mjs'
|
||||
export { injectCustomElements } from './inject-elements.js'
|
||||
export { injectHtmlFragments } from './inject-fragments.mjs'
|
||||
export { mcflyNitroConfig as nitroConfig } from '../mcfly-nitro-config.js'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { ParsedArgs } from 'citty'
|
||||
import consola from 'consola'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import { exportedForTest } from '../src/cli/commands/build.js'
|
||||
import { exportedForTest } from '../src/commands/build'
|
||||
|
||||
const build = exportedForTest.build
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { consola } from 'consola'
|
||||
import { it, expect, vi } from 'vitest'
|
||||
import { exportedForTest } from '../src/cli/commands/prepare.js'
|
||||
import { exportedForTest } from '../src/commands/prepare'
|
||||
const prepare = exportedForTest.prepare
|
||||
|
||||
const mocks = vi.hoisted(() => {
|
||||
|
|
@ -9,12 +9,6 @@ const mocks = vi.hoisted(() => {
|
|||
}
|
||||
})
|
||||
|
||||
vi.mock('nitropack', () => {
|
||||
return {
|
||||
createNitro: mocks.createNitro,
|
||||
}
|
||||
})
|
||||
|
||||
it('start prepare script', () => {
|
||||
const spy = vi.spyOn(consola, 'start')
|
||||
|
||||
|
|
@ -23,14 +17,6 @@ it('start prepare script', () => {
|
|||
expect(spy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.skip('execute nitropack prepare', () => {
|
||||
const successSpy = vi.spyOn(consola, 'success')
|
||||
|
||||
prepare({ dir: 'fakeDir', _: [] })
|
||||
|
||||
expect(successSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.skip('catch error', () => {
|
||||
const dir = 'fake-dir'
|
||||
const errSpy = vi.spyOn(consola, 'error')
|
||||
|
|
|
|||
7
packages/fastify/index.js
Normal file
7
packages/fastify/index.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import serve from './serve'
|
||||
|
||||
export default () => {
|
||||
return {
|
||||
serve,
|
||||
}
|
||||
}
|
||||
16
packages/fastify/package.json
Normal file
16
packages/fastify/package.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "@mcflyjs/fastify",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@fastify/autoload": "6.3.1",
|
||||
"fastify": "5.8.5"
|
||||
}
|
||||
}
|
||||
17
packages/fastify/serve.js
Normal file
17
packages/fastify/serve.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Fastify from 'fastify'
|
||||
import AutoLoad from '@fastify/autoload'
|
||||
import path from 'node:path'
|
||||
|
||||
export default ({ rootDir, apiDir }) => {
|
||||
const server = Fastify({ logger: true })
|
||||
|
||||
server.register(AutoLoad, {
|
||||
dir: path.join(rootDir, apiDir),
|
||||
options: {
|
||||
prefix: apiDir,
|
||||
},
|
||||
})
|
||||
|
||||
console.log('Watching for file changes in', rootDir)
|
||||
server.listen({ port: 3000 })
|
||||
}
|
||||
270
pnpm-lock.yaml
270
pnpm-lock.yaml
|
|
@ -37,7 +37,7 @@ importers:
|
|||
version: 9.1.7
|
||||
netlify-cli:
|
||||
specifier: ^25.6.0
|
||||
version: 25.6.2(@types/node@25.6.2)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)(picomatch@4.0.4)
|
||||
version: 25.6.2(@types/node@25.6.2)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)(picomatch@4.0.4)(rollup@4.60.3)
|
||||
prettier:
|
||||
specifier: ^3.8.3
|
||||
version: 3.8.3
|
||||
|
|
@ -59,10 +59,6 @@ importers:
|
|||
web-component-base:
|
||||
specifier: ^4.0.0
|
||||
version: 4.1.2
|
||||
devDependencies:
|
||||
nitropack:
|
||||
specifier: ~2.11.7
|
||||
version: 2.11.13(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.4)
|
||||
|
||||
packages/core:
|
||||
dependencies:
|
||||
|
|
@ -84,9 +80,6 @@ importers:
|
|||
h3:
|
||||
specifier: ^1.15.1
|
||||
version: 1.15.11
|
||||
nitropack:
|
||||
specifier: ^2.11.7
|
||||
version: 2.11.13(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.4)
|
||||
pathe:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
|
|
@ -148,6 +141,15 @@ importers:
|
|||
specifier: ^22.13.11
|
||||
version: 22.19.18
|
||||
|
||||
packages/fastify:
|
||||
dependencies:
|
||||
'@fastify/autoload':
|
||||
specifier: 6.3.1
|
||||
version: 6.3.1
|
||||
fastify:
|
||||
specifier: 5.8.5
|
||||
version: 5.8.5
|
||||
|
||||
site:
|
||||
dependencies:
|
||||
'@mcflyjs/config':
|
||||
|
|
@ -164,7 +166,19 @@ importers:
|
|||
version: 0.2.9
|
||||
'@mcflyjs/core':
|
||||
specifier: ^0.8.8
|
||||
version: 0.8.8(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.0)(magicast@0.3.5)
|
||||
version: 0.8.8(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.4)(magicast@0.3.5)
|
||||
|
||||
test-core:
|
||||
dependencies:
|
||||
'@mcflyjs/config':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/config
|
||||
'@mcflyjs/core':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/core
|
||||
'@mcflyjs/fastify':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/fastify
|
||||
|
||||
packages:
|
||||
|
||||
|
|
@ -966,6 +980,9 @@ packages:
|
|||
'@fastify/ajv-compiler@4.0.5':
|
||||
resolution: {integrity: sha512-KoWKW+MhvfTRWL4qrhUwAAZoaChluo0m0vbiJlGMt2GXvL4LVPQEjt8kSpHI3IBq5Rez8fg+XeH3cneztq+C7A==}
|
||||
|
||||
'@fastify/autoload@6.3.1':
|
||||
resolution: {integrity: sha512-0fsG+lO3m5yEZVjXKpltCe+2eHhM6rfAPQhvlGUgLUFTw/N2wA9WqPTObMtrF3oUCUrxbSDv60HlUIoh+aFM1A==}
|
||||
|
||||
'@fastify/busboy@3.2.0':
|
||||
resolution: {integrity: sha512-m9FVDXU3GT2ITSe0UaMA5rU3QkfC/UXtCU8y0gSN/GugTqtVldOBWIB5V6V3sbmenVZUIpU6f+mPEO2+m5iTaA==}
|
||||
|
||||
|
|
@ -6853,6 +6870,8 @@ snapshots:
|
|||
ajv-formats: 3.0.1(ajv@8.20.0)
|
||||
fast-uri: 3.1.2
|
||||
|
||||
'@fastify/autoload@6.3.1': {}
|
||||
|
||||
'@fastify/busboy@3.2.0': {}
|
||||
|
||||
'@fastify/error@4.2.0': {}
|
||||
|
|
@ -7080,7 +7099,7 @@ snapshots:
|
|||
h3: 1.15.11
|
||||
web-component-base: 4.1.2
|
||||
|
||||
'@mcflyjs/core@0.8.8(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.0)(magicast@0.3.5)':
|
||||
'@mcflyjs/core@0.8.8(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.4)(magicast@0.3.5)':
|
||||
dependencies:
|
||||
c12: 3.3.4(magicast@0.3.5)
|
||||
citty: 0.1.6
|
||||
|
|
@ -7088,7 +7107,7 @@ snapshots:
|
|||
devalue: 5.8.0
|
||||
esprima: 4.0.1
|
||||
h3: 1.15.11
|
||||
nitropack: 2.11.13(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.0)
|
||||
nitropack: 2.11.13(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.4)
|
||||
pathe: 2.0.3
|
||||
ultrahtml: 1.6.0
|
||||
transitivePeerDependencies:
|
||||
|
|
@ -7166,23 +7185,23 @@ snapshots:
|
|||
find-up: 7.0.0
|
||||
minimatch: 10.2.5
|
||||
read-pkg: 9.0.1
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
yaml: 2.8.4
|
||||
yargs: 17.7.2
|
||||
|
||||
'@netlify/build@35.13.4(@opentelemetry/api@1.8.0)(@types/node@25.6.2)(picomatch@4.0.4)':
|
||||
'@netlify/build@35.13.4(@opentelemetry/api@1.8.0)(@types/node@25.6.2)(picomatch@4.0.4)(rollup@4.60.3)':
|
||||
dependencies:
|
||||
'@bugsnag/js': 8.9.0
|
||||
'@netlify/blobs': 10.7.0(supports-color@10.2.2)
|
||||
'@netlify/cache-utils': 6.0.5
|
||||
'@netlify/config': 24.5.0
|
||||
'@netlify/edge-bundler': 14.10.1
|
||||
'@netlify/functions-utils': 6.2.30(supports-color@10.2.2)
|
||||
'@netlify/functions-utils': 6.2.30(rollup@4.60.3)(supports-color@10.2.2)
|
||||
'@netlify/git-utils': 6.0.4
|
||||
'@netlify/opentelemetry-utils': 2.0.2(@opentelemetry/api@1.8.0)
|
||||
'@netlify/plugins-list': 6.81.6
|
||||
'@netlify/run-utils': 6.0.3
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4(supports-color@10.2.2)
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
'@opentelemetry/api': 1.8.0
|
||||
'@sindresorhus/slugify': 2.2.1
|
||||
ansi-escapes: 7.3.0
|
||||
|
|
@ -7215,7 +7234,7 @@ snapshots:
|
|||
resolve: 2.0.0-next.6
|
||||
rfdc: 1.4.1
|
||||
safe-json-stringify: 1.2.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
string-width: 7.2.0
|
||||
supports-color: 10.2.2
|
||||
terminal-link: 4.0.0
|
||||
|
|
@ -7310,7 +7329,7 @@ snapshots:
|
|||
image-size: 2.0.2
|
||||
js-image-generator: 1.0.4
|
||||
parse-gitignore: 2.0.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
tmp-promise: 3.0.3
|
||||
uuid: 13.0.0
|
||||
write-file-atomic: 5.0.1
|
||||
|
|
@ -7328,12 +7347,12 @@ snapshots:
|
|||
image-size: 2.0.2
|
||||
js-image-generator: 1.0.4
|
||||
parse-gitignore: 2.0.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
tmp-promise: 3.0.3
|
||||
uuid: 13.0.0
|
||||
write-file-atomic: 5.0.1
|
||||
|
||||
'@netlify/dev@4.17.3(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)':
|
||||
'@netlify/dev@4.17.3(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)(rollup@4.60.3)':
|
||||
dependencies:
|
||||
'@netlify/ai': 0.4.1
|
||||
'@netlify/blobs': 10.7.4
|
||||
|
|
@ -7341,7 +7360,7 @@ snapshots:
|
|||
'@netlify/database-dev': 0.10.0
|
||||
'@netlify/dev-utils': 4.4.3
|
||||
'@netlify/edge-functions-dev': 1.0.16
|
||||
'@netlify/functions-dev': 1.2.6
|
||||
'@netlify/functions-dev': 1.2.6(rollup@4.60.3)
|
||||
'@netlify/headers': 2.1.8
|
||||
'@netlify/images': 1.3.7(@netlify/blobs@10.7.4)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)
|
||||
'@netlify/redirects': 3.1.10
|
||||
|
|
@ -7393,7 +7412,7 @@ snapshots:
|
|||
p-wait-for: 5.0.2
|
||||
parse-imports: 2.2.1
|
||||
path-key: 4.0.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
tar: 7.5.15
|
||||
tmp-promise: 3.0.3
|
||||
urlpattern-polyfill: 8.0.2
|
||||
|
|
@ -7416,12 +7435,12 @@ snapshots:
|
|||
dependencies:
|
||||
'@netlify/types': 2.6.0
|
||||
|
||||
'@netlify/functions-dev@1.2.6':
|
||||
'@netlify/functions-dev@1.2.6(rollup@4.60.3)':
|
||||
dependencies:
|
||||
'@netlify/blobs': 10.7.4
|
||||
'@netlify/dev-utils': 4.4.3
|
||||
'@netlify/functions': 5.2.0
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
cron-parser: 4.9.0
|
||||
decache: 4.6.2
|
||||
extract-zip: 2.0.1
|
||||
|
|
@ -7429,7 +7448,7 @@ snapshots:
|
|||
jwt-decode: 4.0.0
|
||||
lambda-local: 2.2.0
|
||||
read-package-up: 11.0.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
source-map-support: 0.5.21
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
|
|
@ -7439,9 +7458,9 @@ snapshots:
|
|||
- rollup
|
||||
- supports-color
|
||||
|
||||
'@netlify/functions-utils@6.2.30(supports-color@10.2.2)':
|
||||
'@netlify/functions-utils@6.2.30(rollup@4.60.3)(supports-color@10.2.2)':
|
||||
dependencies:
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4(supports-color@10.2.2)
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
cpy: 11.1.0
|
||||
path-exists: 5.0.0
|
||||
transitivePeerDependencies:
|
||||
|
|
@ -7669,7 +7688,7 @@ snapshots:
|
|||
'@babel/types': 7.28.0
|
||||
'@netlify/binary-info': 1.0.0
|
||||
'@netlify/serverless-functions-api': 2.15.1
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
archiver: 7.0.1
|
||||
common-path-prefix: 3.0.0
|
||||
copy-file: 11.1.0
|
||||
|
|
@ -7706,13 +7725,13 @@ snapshots:
|
|||
- rollup
|
||||
- supports-color
|
||||
|
||||
'@netlify/zip-it-and-ship-it@14.5.4':
|
||||
'@netlify/zip-it-and-ship-it@14.5.4(rollup@4.60.3)(supports-color@10.2.2)':
|
||||
dependencies:
|
||||
'@babel/parser': 7.29.3
|
||||
'@babel/types': 7.29.0
|
||||
'@netlify/binary-info': 1.0.0
|
||||
'@netlify/serverless-functions-api': 2.15.0
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
archiver: 7.0.1
|
||||
common-path-prefix: 3.0.0
|
||||
copy-file: 11.1.0
|
||||
|
|
@ -7733,49 +7752,7 @@ snapshots:
|
|||
precinct: 12.3.2(supports-color@10.2.2)
|
||||
require-package-name: 2.0.1
|
||||
resolve: 2.0.0-next.6
|
||||
semver: 7.7.2
|
||||
tmp-promise: 3.0.3
|
||||
toml: 3.0.0
|
||||
unixify: 1.0.0
|
||||
urlpattern-polyfill: 8.0.2
|
||||
yargs: 17.7.2
|
||||
zod: 3.25.76
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- encoding
|
||||
- react-native-b4a
|
||||
- rollup
|
||||
- supports-color
|
||||
|
||||
'@netlify/zip-it-and-ship-it@14.5.4(supports-color@10.2.2)':
|
||||
dependencies:
|
||||
'@babel/parser': 7.29.3
|
||||
'@babel/types': 7.29.0
|
||||
'@netlify/binary-info': 1.0.0
|
||||
'@netlify/serverless-functions-api': 2.15.0
|
||||
'@vercel/nft': 0.29.4(supports-color@10.2.2)
|
||||
archiver: 7.0.1
|
||||
common-path-prefix: 3.0.0
|
||||
copy-file: 11.1.0
|
||||
es-module-lexer: 1.7.0
|
||||
esbuild: 0.27.3
|
||||
execa: 8.0.1
|
||||
fast-glob: 3.3.3
|
||||
filter-obj: 6.1.0
|
||||
find-up: 7.0.0
|
||||
is-path-inside: 4.0.0
|
||||
junk: 4.0.1
|
||||
locate-path: 7.2.0
|
||||
merge-options: 3.0.4
|
||||
minimatch: 10.2.5
|
||||
normalize-path: 3.0.0
|
||||
p-map: 7.0.3
|
||||
path-exists: 5.0.0
|
||||
precinct: 12.3.2(supports-color@10.2.2)
|
||||
require-package-name: 2.0.1
|
||||
resolve: 2.0.0-next.6
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
tmp-promise: 3.0.3
|
||||
toml: 3.0.0
|
||||
unixify: 1.0.0
|
||||
|
|
@ -7928,7 +7905,7 @@ snapshots:
|
|||
'@opentelemetry/propagator-b3': 1.30.1(@opentelemetry/api@1.9.0)
|
||||
'@opentelemetry/propagator-jaeger': 1.30.1(@opentelemetry/api@1.9.0)
|
||||
'@opentelemetry/sdk-trace-base': 1.30.1(@opentelemetry/api@1.9.0)
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
|
||||
'@opentelemetry/semantic-conventions@1.28.0': {}
|
||||
|
||||
|
|
@ -8292,26 +8269,7 @@ snapshots:
|
|||
'@typescript-eslint/types': 8.59.2
|
||||
eslint-visitor-keys: 5.0.1
|
||||
|
||||
'@vercel/nft@0.29.4(rollup@4.60.3)':
|
||||
dependencies:
|
||||
'@mapbox/node-pre-gyp': 2.0.3(supports-color@10.2.2)
|
||||
'@rollup/pluginutils': 5.3.0(rollup@4.60.3)
|
||||
acorn: 8.16.0
|
||||
acorn-import-attributes: 1.9.5(acorn@8.16.0)
|
||||
async-sema: 3.1.1
|
||||
bindings: 1.5.0
|
||||
estree-walker: 2.0.2
|
||||
glob: 10.5.0
|
||||
graceful-fs: 4.2.11
|
||||
node-gyp-build: 4.8.4
|
||||
picomatch: 4.0.4
|
||||
resolve-from: 5.0.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- rollup
|
||||
- supports-color
|
||||
|
||||
'@vercel/nft@0.29.4(supports-color@10.2.2)':
|
||||
'@vercel/nft@0.29.4(rollup@4.60.3)(supports-color@10.2.2)':
|
||||
dependencies:
|
||||
'@mapbox/node-pre-gyp': 2.0.3(supports-color@10.2.2)
|
||||
'@rollup/pluginutils': 5.3.0(rollup@4.60.3)
|
||||
|
|
@ -9849,7 +9807,7 @@ snapshots:
|
|||
process-warning: 5.0.0
|
||||
rfdc: 1.4.1
|
||||
secure-json-parse: 4.1.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
toad-cache: 3.7.0
|
||||
|
||||
fastq@1.20.1:
|
||||
|
|
@ -10689,7 +10647,7 @@ snapshots:
|
|||
lodash.isstring: 4.0.1
|
||||
lodash.once: 4.1.1
|
||||
ms: 2.1.3
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
|
||||
junk@4.0.1: {}
|
||||
|
||||
|
|
@ -11017,16 +10975,16 @@ snapshots:
|
|||
|
||||
negotiator@1.0.0: {}
|
||||
|
||||
netlify-cli@25.6.2(@types/node@25.6.2)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)(picomatch@4.0.4):
|
||||
netlify-cli@25.6.2(@types/node@25.6.2)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)(picomatch@4.0.4)(rollup@4.60.3):
|
||||
dependencies:
|
||||
'@fastify/static': 9.0.0
|
||||
'@netlify/ai': 0.4.1
|
||||
'@netlify/api': 14.0.18
|
||||
'@netlify/blobs': 10.7.0(supports-color@10.2.2)
|
||||
'@netlify/build': 35.13.4(@opentelemetry/api@1.8.0)(@types/node@25.6.2)(picomatch@4.0.4)
|
||||
'@netlify/build': 35.13.4(@opentelemetry/api@1.8.0)(@types/node@25.6.2)(picomatch@4.0.4)(rollup@4.60.3)
|
||||
'@netlify/build-info': 10.5.1
|
||||
'@netlify/config': 24.5.0
|
||||
'@netlify/dev': 4.17.3(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)
|
||||
'@netlify/dev': 4.17.3(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)(rollup@4.60.3)
|
||||
'@netlify/dev-utils': 4.4.3
|
||||
'@netlify/edge-bundler': 14.10.1
|
||||
'@netlify/edge-functions': 3.0.6
|
||||
|
|
@ -11035,7 +10993,7 @@ snapshots:
|
|||
'@netlify/images': 1.3.7(@netlify/blobs@10.7.0)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)
|
||||
'@netlify/local-functions-proxy': 2.0.3
|
||||
'@netlify/redirect-parser': 15.0.4
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4
|
||||
'@netlify/zip-it-and-ship-it': 14.5.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
'@octokit/rest': 22.0.0
|
||||
'@opentelemetry/api': 1.8.0
|
||||
'@pnpm/tabtab': 0.5.4
|
||||
|
|
@ -11162,110 +11120,6 @@ snapshots:
|
|||
p-wait-for: 5.0.2
|
||||
qs: 6.15.1
|
||||
|
||||
nitropack@2.11.13(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.0):
|
||||
dependencies:
|
||||
'@cloudflare/kv-asset-handler': 0.4.2
|
||||
'@netlify/functions': 3.1.10(rollup@4.60.3)
|
||||
'@rollup/plugin-alias': 5.1.1(rollup@4.60.3)
|
||||
'@rollup/plugin-commonjs': 28.0.9(rollup@4.60.3)
|
||||
'@rollup/plugin-inject': 5.0.5(rollup@4.60.3)
|
||||
'@rollup/plugin-json': 6.1.0(rollup@4.60.3)
|
||||
'@rollup/plugin-node-resolve': 16.0.3(rollup@4.60.3)
|
||||
'@rollup/plugin-replace': 6.0.3(rollup@4.60.3)
|
||||
'@rollup/plugin-terser': 0.4.4(rollup@4.60.3)
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)
|
||||
archiver: 7.0.1
|
||||
c12: 3.3.4(magicast@0.3.5)
|
||||
chokidar: 4.0.3
|
||||
citty: 0.1.6
|
||||
compatx: 0.2.0
|
||||
confbox: 0.2.4
|
||||
consola: 3.4.2
|
||||
cookie-es: 2.0.1
|
||||
croner: 9.1.0
|
||||
crossws: 0.3.5
|
||||
db0: 0.3.4(@electric-sql/pglite@0.3.16)
|
||||
defu: 6.1.7
|
||||
destr: 2.0.5
|
||||
dot-prop: 9.0.0
|
||||
esbuild: 0.25.12
|
||||
escape-string-regexp: 5.0.0
|
||||
etag: 1.8.1
|
||||
exsolve: 1.0.8
|
||||
globby: 14.1.0
|
||||
gzip-size: 7.0.0
|
||||
h3: 1.15.11
|
||||
hookable: 5.5.3
|
||||
httpxy: 0.1.7
|
||||
ioredis: 5.10.1
|
||||
jiti: 2.7.0
|
||||
klona: 2.0.6
|
||||
knitwork: 1.3.0
|
||||
listhen: 1.10.0
|
||||
magic-string: 0.30.21
|
||||
magicast: 0.3.5
|
||||
mime: 4.1.0
|
||||
mlly: 1.8.2
|
||||
node-fetch-native: 1.6.7
|
||||
node-mock-http: 1.0.4
|
||||
ofetch: 1.5.1
|
||||
ohash: 2.0.11
|
||||
pathe: 2.0.3
|
||||
perfect-debounce: 1.0.0
|
||||
pkg-types: 2.3.1
|
||||
pretty-bytes: 6.1.1
|
||||
radix3: 1.1.2
|
||||
rollup: 4.60.3
|
||||
rollup-plugin-visualizer: 6.0.11(rollup@4.60.3)
|
||||
scule: 1.3.0
|
||||
semver: 7.8.0
|
||||
serve-placeholder: 2.0.2
|
||||
serve-static: 2.2.1
|
||||
source-map: 0.7.6
|
||||
std-env: 3.10.0
|
||||
ufo: 1.6.4
|
||||
ultrahtml: 1.6.0
|
||||
uncrypto: 0.1.3
|
||||
unctx: 2.5.0
|
||||
unenv: 2.0.0-rc.24
|
||||
unimport: 5.7.0
|
||||
unplugin-utils: 0.2.5
|
||||
unstorage: 1.17.5(@netlify/blobs@10.7.0)(db0@0.3.4(@electric-sql/pglite@0.3.16))(ioredis@5.10.1)
|
||||
untyped: 2.0.0
|
||||
unwasm: 0.3.11
|
||||
youch: 4.1.0-beta.8
|
||||
youch-core: 0.3.3
|
||||
transitivePeerDependencies:
|
||||
- '@azure/app-configuration'
|
||||
- '@azure/cosmos'
|
||||
- '@azure/data-tables'
|
||||
- '@azure/identity'
|
||||
- '@azure/keyvault-secrets'
|
||||
- '@azure/storage-blob'
|
||||
- '@capacitor/preferences'
|
||||
- '@deno/kv'
|
||||
- '@electric-sql/pglite'
|
||||
- '@libsql/client'
|
||||
- '@netlify/blobs'
|
||||
- '@planetscale/database'
|
||||
- '@upstash/redis'
|
||||
- '@vercel/blob'
|
||||
- '@vercel/functions'
|
||||
- '@vercel/kv'
|
||||
- aws4fetch
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- better-sqlite3
|
||||
- drizzle-orm
|
||||
- encoding
|
||||
- idb-keyval
|
||||
- mysql2
|
||||
- react-native-b4a
|
||||
- rolldown
|
||||
- sqlite3
|
||||
- supports-color
|
||||
- uploadthing
|
||||
|
||||
nitropack@2.11.13(@electric-sql/pglite@0.3.16)(@netlify/blobs@10.7.4):
|
||||
dependencies:
|
||||
'@cloudflare/kv-asset-handler': 0.4.2
|
||||
|
|
@ -11277,7 +11131,7 @@ snapshots:
|
|||
'@rollup/plugin-node-resolve': 16.0.3(rollup@4.60.3)
|
||||
'@rollup/plugin-replace': 6.0.3(rollup@4.60.3)
|
||||
'@rollup/plugin-terser': 0.4.4(rollup@4.60.3)
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)
|
||||
'@vercel/nft': 0.29.4(rollup@4.60.3)(supports-color@10.2.2)
|
||||
archiver: 7.0.1
|
||||
c12: 3.3.4(magicast@0.3.5)
|
||||
chokidar: 4.0.3
|
||||
|
|
@ -11425,13 +11279,13 @@ snapshots:
|
|||
normalize-package-data@7.0.1:
|
||||
dependencies:
|
||||
hosted-git-info: 8.1.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
validate-npm-package-license: 3.0.4
|
||||
|
||||
normalize-package-data@8.0.0:
|
||||
dependencies:
|
||||
hosted-git-info: 9.0.3
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
validate-npm-package-license: 3.0.4
|
||||
|
||||
normalize-path@2.1.1:
|
||||
|
|
@ -11622,7 +11476,7 @@ snapshots:
|
|||
ky: 1.14.3
|
||||
registry-auth-token: 5.1.1
|
||||
registry-url: 6.0.1
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
|
||||
parallel-transform@1.2.0:
|
||||
dependencies:
|
||||
|
|
@ -12916,7 +12770,7 @@ snapshots:
|
|||
is-npm: 6.1.0
|
||||
latest-version: 9.0.0
|
||||
pupa: 3.3.0
|
||||
semver: 7.7.2
|
||||
semver: 7.8.0
|
||||
xdg-basedir: 5.1.0
|
||||
|
||||
uqr@0.1.3: {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
packages:
|
||||
- "packages/**"
|
||||
- "templates/**"
|
||||
- "site/**"
|
||||
- 'packages/**'
|
||||
- 'templates/**'
|
||||
- 'site'
|
||||
- 'test-fastify'
|
||||
- 'test-core'
|
||||
allowBuilds:
|
||||
'@parcel/watcher': false
|
||||
esbuild: true
|
||||
|
|
|
|||
|
|
@ -1,27 +1,28 @@
|
|||
// @ts-check
|
||||
import { defineMcFlyConfig } from '@mcflyjs/config'
|
||||
import { defineConfig } from '@mcflyjs/config'
|
||||
// import testPlugin from './test-plugin.mjs'
|
||||
|
||||
export default defineMcFlyConfig({
|
||||
export default defineConfig({
|
||||
server: {},
|
||||
components: 'js',
|
||||
// plugins: [testPlugin()],
|
||||
nitro: {
|
||||
preset: 'netlify',
|
||||
devServer: {
|
||||
watch: ['../packages'],
|
||||
},
|
||||
routeRules: {
|
||||
'/chat': {
|
||||
redirect: {
|
||||
to: 'https://matrix.to/#/#mcfly:matrix.org',
|
||||
statusCode: 302,
|
||||
},
|
||||
},
|
||||
},
|
||||
compressPublicAssets: {
|
||||
gzip: true,
|
||||
brotli: true,
|
||||
},
|
||||
compatibilityDate: '2024-12-08',
|
||||
},
|
||||
// nitro: {
|
||||
// preset: 'netlify',
|
||||
// devServer: {
|
||||
// watch: ['../packages'],
|
||||
// },
|
||||
// routeRules: {
|
||||
// '/chat': {
|
||||
// redirect: {
|
||||
// to: 'https://matrix.to/#/#mcfly:matrix.org',
|
||||
// statusCode: 302,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// compressPublicAssets: {
|
||||
// gzip: true,
|
||||
// brotli: true,
|
||||
// },
|
||||
// compatibilityDate: '2024-12-08',
|
||||
// },
|
||||
})
|
||||
|
|
|
|||
6
test-core/mcfly.config.mjs
Normal file
6
test-core/mcfly.config.mjs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { defineConfig } from '@mcflyjs/config'
|
||||
import fastify from '@mcflyjs/fastify'
|
||||
|
||||
export default defineConfig({
|
||||
server: fastify(),
|
||||
})
|
||||
17
test-core/package.json
Normal file
17
test-core/package.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "test-core",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "mcfly serve"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@mcflyjs/core": "workspace:*",
|
||||
"@mcflyjs/config": "workspace:*",
|
||||
"@mcflyjs/fastify": "workspace:*"
|
||||
}
|
||||
}
|
||||
29
test-core/src/api/README.md
Normal file
29
test-core/src/api/README.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Routes Folder
|
||||
|
||||
Routes define the pathways within your application.
|
||||
Fastify's structure supports the modular monolith approach, where your
|
||||
application is organized into distinct, self-contained modules.
|
||||
This facilitates easier scaling and future transition to a microservice architecture.
|
||||
In the future you might want to independently deploy some of those.
|
||||
|
||||
In this folder you should define all the routes that define the endpoints
|
||||
of your web application.
|
||||
Each service is a [Fastify
|
||||
plugin](https://fastify.dev/docs/latest/Reference/Plugins/), it is
|
||||
encapsulated (it can have its own independent plugins) and it is
|
||||
typically stored in a file; be careful to group your routes logically,
|
||||
e.g. all `/users` routes in a `users.js` file. We have added
|
||||
a `root.js` file for you with a '/' root added.
|
||||
|
||||
If a single file becomes too large, create a folder and add a `index.js` file there:
|
||||
this file must be a Fastify plugin, and it will be loaded automatically
|
||||
by the application. You can now add as many files as you want inside that folder.
|
||||
In this way you can create complex routes within a single monolith,
|
||||
and eventually extract them.
|
||||
|
||||
If you need to share functionality between routes, place that
|
||||
functionality into the `plugins` folder, and share it via
|
||||
[decorators](https://fastify.dev/docs/latest/Reference/Decorators/).
|
||||
|
||||
If you're a bit confused about using `async/await` to write routes, you would
|
||||
better take a look at [Promise resolution](https://fastify.dev/docs/latest/Reference/Routes/#promise-resolution) for more details.
|
||||
6
test-core/src/api/example/index.js
Normal file
6
test-core/src/api/example/index.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export default async (fastify) => {
|
||||
fastify.get('/', async function (request, reply) {
|
||||
console.log({ request, reply })
|
||||
return 'This is an example'
|
||||
})
|
||||
}
|
||||
6
test-core/src/api/root.js
Normal file
6
test-core/src/api/root.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export default async function (fastify, opts) {
|
||||
fastify.get('/', async function (request, reply) {
|
||||
console.log({ opts, request, reply })
|
||||
return { root: true }
|
||||
})
|
||||
}
|
||||
0
test-core/src/pages/index.html
Normal file
0
test-core/src/pages/index.html
Normal file
Loading…
Reference in a new issue