Typescript: How to use with custom server framework?

Created on 14 Nov 2019  路  4Comments  路  Source: nuxt/typescript

Can you please provide example of usage with custom server framework?

question programmatic usage

Most helpful comment

Here you go!

const HTTPS = require('https')
const path = require('path')
const express = require('express')
const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')

const app = express()
const { registerTSNode, getRootdirFromArgv } = require('@nuxt/typescript-runtime/lib')

const rootDir = getRootdirFromArgv()
const tsConfigPath = path.resolve(rootDir, 'tsconfig.json')

registerTSNode(tsConfigPath)

// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')

It took about an hour to solve it. It's taken from @nuxt/typescript-runtime internals and it works fine :)

But let someone from core-team approves this solution

All 4 comments

Here you go!

const HTTPS = require('https')
const path = require('path')
const express = require('express')
const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')

const app = express()
const { registerTSNode, getRootdirFromArgv } = require('@nuxt/typescript-runtime/lib')

const rootDir = getRootdirFromArgv()
const tsConfigPath = path.resolve(rootDir, 'tsconfig.json')

registerTSNode(tsConfigPath)

// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')

It took about an hour to solve it. It's taken from @nuxt/typescript-runtime internals and it works fine :)

But let someone from core-team approves this solution

@krystian50 Thanks 馃檹

Here you go!

const HTTPS = require('https')
const path = require('path')
const express = require('express')
const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')

const app = express()
const { registerTSNode, getRootdirFromArgv } = require('@nuxt/typescript-runtime/lib')

const rootDir = getRootdirFromArgv()
const tsConfigPath = path.resolve(rootDir, 'tsconfig.json')

registerTSNode(tsConfigPath)

// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')

It took about an hour to solve it. It's taken from @nuxt/typescript-runtime internals and it works fine :)

But let someone from core-team approves this solution

Thank you for sharing. @kevinmarrec, can we provide some kind of official way of doing it, since nuxt (js) api supports it? Many people would be happy to use custom framework instead of connect, including me 馃槉

@krystian50 https://github.com/nuxt/typescript/issues/193#issuecomment-554298475 it seems to be using an old version of @nuxt/typescript-runtime.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fy0 picture fy0  路  6Comments

nandenjin picture nandenjin  路  4Comments

xavism picture xavism  路  3Comments

negezor picture negezor  路  6Comments

Pacheco95 picture Pacheco95  路  4Comments