mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
chore: fix runtime typescript errors
This commit is contained in:
parent
9e9b20ef90
commit
fa5d0e04f9
@ -1,6 +1,6 @@
|
|||||||
import destr from 'destr'
|
import destr from 'destr'
|
||||||
|
|
||||||
const runtimeConfig = process.env.RUNTIME_CONFIG
|
const runtimeConfig = process.env.RUNTIME_CONFIG as any
|
||||||
|
|
||||||
for (const type of ['private', 'public']) {
|
for (const type of ['private', 'public']) {
|
||||||
for (const key in runtimeConfig[type]) {
|
for (const key in runtimeConfig[type]) {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import { createRenderer } from 'vue-bundle-renderer'
|
import { createRenderer } from 'vue-bundle-renderer'
|
||||||
import devalue from '@nuxt/devalue'
|
import devalue from '@nuxt/devalue'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
|
// @ts-ignore
|
||||||
import { renderToString } from '~renderer'
|
import { renderToString } from '~renderer'
|
||||||
|
// @ts-ignore
|
||||||
import server from '~build/dist/server/server'
|
import server from '~build/dist/server/server'
|
||||||
|
// @ts-ignore
|
||||||
import clientManifest from '~build/dist/server/client.manifest.json'
|
import clientManifest from '~build/dist/server/client.manifest.json'
|
||||||
|
// @ts-ignore
|
||||||
import htmlTemplate from '~build/views/document.template.js'
|
import htmlTemplate from '~build/views/document.template.js'
|
||||||
|
|
||||||
const renderer = createRenderer(server, {
|
const renderer = createRenderer(server, {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-ignore
|
||||||
import { createRenderer } from '~vueServerRenderer'
|
import { createRenderer } from '~vueServerRenderer'
|
||||||
|
|
||||||
const _renderer = createRenderer({})
|
const _renderer = createRenderer({})
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// @ts-ignore
|
||||||
export { renderToString } from '@vue/server-renderer'
|
export { renderToString } from '@vue/server-renderer'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import '~polyfill'
|
import '~polyfill'
|
||||||
import { localCall } from '../server/call'
|
import { localCall } from '../server'
|
||||||
|
|
||||||
async function cli () {
|
async function cli () {
|
||||||
const url = process.argv[2] || '/'
|
const url = process.argv[2] || '/'
|
||||||
@ -9,6 +9,7 @@ async function cli () {
|
|||||||
debug('URL', url)
|
debug('URL', url)
|
||||||
debug('StatusCode', r.status)
|
debug('StatusCode', r.status)
|
||||||
debug('StatusMessage', r.statusText)
|
debug('StatusMessage', r.statusText)
|
||||||
|
// @ts-ignore
|
||||||
for (const header of r.headers.entries()) {
|
for (const header of r.headers.entries()) {
|
||||||
debug(header[0], header[1])
|
debug(header[0], header[1])
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { localCall } from '../server'
|
|||||||
|
|
||||||
const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/
|
const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/
|
||||||
|
|
||||||
addEventListener('fetch', (event) => {
|
addEventListener('fetch', (event: any) => {
|
||||||
event.respondWith(handleEvent(event))
|
event.respondWith(handleEvent(event))
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ async function handleEvent (event) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return new Response(r.body, {
|
return new Response(r.body, {
|
||||||
|
// @ts-ignore
|
||||||
headers: r.headers,
|
headers: r.headers,
|
||||||
status: r.status,
|
status: r.status,
|
||||||
statusText: r.statusText
|
statusText: r.statusText
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
import '~polyfill'
|
import '~polyfill'
|
||||||
import { Server } from 'http'
|
import { Server } from 'http'
|
||||||
|
import destr from 'destr'
|
||||||
import { handle } from '../server'
|
import { handle } from '../server'
|
||||||
|
|
||||||
const server = new Server(handle)
|
const server = new Server(handle)
|
||||||
|
|
||||||
const port = process.env.NUXT_PORT || process.env.PORT || 3000
|
const port = (destr(process.env.NUXT_PORT || process.env.PORT) || 3000) as number
|
||||||
const host = process.env.NUXT_HOST || process.env.HOST || 'localhost'
|
const hostname = process.env.NUXT_HOST || process.env.HOST || 'localhost'
|
||||||
|
|
||||||
server.listen(port, host, (err) => {
|
// @ts-ignore
|
||||||
|
server.listen(port, hostname, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
console.log(`Listening on http://${host}:${port}`)
|
console.log(`Listening on http://${hostname}:${port}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default {}
|
export default {}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-nocheck
|
||||||
import '~polyfill'
|
import '~polyfill'
|
||||||
import { localCall } from '../server'
|
import { localCall } from '../server'
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import destr from 'destr'
|
|||||||
import { createCall, createFetch as createLocalFetch } from '@nuxt/un/runtime/fetch'
|
import { createCall, createFetch as createLocalFetch } from '@nuxt/un/runtime/fetch'
|
||||||
import { timingMiddleware } from './timing'
|
import { timingMiddleware } from './timing'
|
||||||
import { handleError } from './error'
|
import { handleError } from './error'
|
||||||
|
// @ts-ignore
|
||||||
import serverMiddleware from '~serverMiddleware'
|
import serverMiddleware from '~serverMiddleware'
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { sendError } from 'h3'
|
import { createError } from 'h3'
|
||||||
|
// @ts-ignore
|
||||||
import { getAsset, readAsset } from '~static'
|
import { getAsset, readAsset } from '~static'
|
||||||
|
|
||||||
const METHODS = ['HEAD', 'GET']
|
const METHODS = ['HEAD', 'GET']
|
||||||
@ -23,7 +24,10 @@ export default async function serveStatic(req, res) {
|
|||||||
|
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
if (id.startsWith(PUBLIC_PATH)) {
|
if (id.startsWith(PUBLIC_PATH)) {
|
||||||
sendError(res, 'Asset not found: ' + id, false, 404)
|
throw createError({
|
||||||
|
message: 'Asset not found: ' + id,
|
||||||
|
statusCode: 404
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user