T
TanStack7mo ago
genetic-orange

Where is the Server Side Entry Point?

I'd like to know where the server side is started so I can implement Bugsnag and database setup. This is for a nodeJS/Docker project.
17 Replies
foreign-sapphire
foreign-sapphire7mo ago
there is no defined serverside entry point. it's a thing we are currently evaluating how to do best. so your input would be valuable. when you say "serverside entry point", what exactly does this mean for you? SSR? server functions? both ?
flat-fuchsia
flat-fuchsia7mo ago
That's a pretty interesting question. I also run NodeJS apps in docker containers. It might be easier to think of it in terms of goals. For me, thats mostly initialization of globals.. the place to setup a postgresql 'connection pool' . or a nats connection to pick up and react to events. or a place to initialize and maintain a set of authenticated users for websockets. (eek does TanStack Start support websockets?)
foreign-sapphire
foreign-sapphire7mo ago
nitro does support websockets
flat-fuchsia
flat-fuchsia7mo ago
zodding in and parsing in the environmental variables is also a good initial thing.. these are probably things you'd solve differently in a cloudflare workers style environment.. but where to setup long running infrastructure code/data I guess is the question. i wonder if nitro has a bootstrap to harness @Manuel Schiller this appears to be a limitation of nitro itself. As it appears to have no startup methods to latch onto (possibly by design)
foreign-sapphire
foreign-sapphire7mo ago
should be possible via nitro plugin? https://nitro.build/guide/plugins
Plugins - Nitro
Use plugins to extend Nitro's runtime behavior.
flat-fuchsia
flat-fuchsia7mo ago
actually, i just spotted that..
genetic-orange
genetic-orangeOP7mo ago
@Manuel Schiller Can you import or use defineNitroPlugin in Tanstack/start?
flat-fuchsia
flat-fuchsia7mo ago
interesting. tho I wonder if its possible to wrap CreateStartHandler in the SSR handler.. or if SSR handler is the wrong place for code like this appears to be wrong, doesnt run on startup
quickest-silver
quickest-silver7mo ago
I'm also trying to figure this out. For this config:
export default defineConfig({
server: {
preset: 'node-server',
plugins: ['./plugins/env-check.ts'],
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
],
},
})
export default defineConfig({
server: {
preset: 'node-server',
plugins: ['./plugins/env-check.ts'],
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
],
},
})
I am getting this error: Package import specifier "#nitro-internal-virtual/error-handler" is not defined in package. And the env-check.ts:
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
console.log('Nitro plugin', nitroApp)
})
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
console.log('Nitro plugin', nitroApp)
})
What do you think about this, @Manuel Schiller?
foreign-sapphire
foreign-sapphire7mo ago
no idea, never tried this might be caused by the setup through vinxi maybe? since we are currently removing vinxi, we wont investigate this now as it will be gone soon
flat-fuchsia
flat-fuchsia7mo ago
vinxi is a vike competitor?
foreign-sapphire
foreign-sapphire7mo ago
not sure if that is comparable
flat-fuchsia
flat-fuchsia7mo ago
not very famliar with either. checking it out
national-gold
national-gold7mo ago
where do we add Cors. Is there a way to do createRouter( ({method:use})=>(cors() ) or do we add it as a global middleware if you're actively removing vinxi 1.0 most be close
conscious-sapphire
conscious-sapphire7mo ago
Last time I checked (January) source code of Vinxi did not register nitro stuff like tasks or hooks
foreign-sapphire
foreign-sapphire7mo ago
we might be able to expose this in future

Did you find this page helpful?