Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: Provide a First Class Way to Eject Fastify Config #7617

Open
1 task
MichaelrMentele opened this issue Feb 11, 2023 · 2 comments
Open
1 task

[RFC]: Provide a First Class Way to Eject Fastify Config #7617

MichaelrMentele opened this issue Feb 11, 2023 · 2 comments

Comments

@MichaelrMentele
Copy link
Contributor

Summary

It's hard for app owners to do things with their deployment when we cannot control the server config. This feels like a glaring gap that hamstrings folks controlling their own devops.

Motivation

Give app owners control of their own deployment

Detailed proposal

Not sure yet the best way to do this. But in order to actually add full tracing we ended up reaching into the RW internals which is not break (could break if files get moved for example) and pulling out the setup.

Instead there should be a first class way to tweak the fastify instance creation like:

import './tracer'

import createFastifyInstance from '@redwoodjs/api-server/dist/fastify'
import withFunctions from '@redwoodjs/api-server/dist/plugins/withFunctions'
import { startServer as startFastifyServer } from '@redwoodjs/api-server/dist/server'

import { logger } from 'src/lib/logger'

async function main() {
  const tsApiServer = Date.now()

  let fastify = createFastifyInstance()

  const options = { apiRootPath: '/', port: 8911 }

  // Import Server Functions.
  fastify = await withFunctions(fastify, options)

  const http = startFastifyServer({
    port: options.port,
    socket: undefined,
    fastify,
  }).ready(() => {
    logger.info('Took ' + (Date.now() - tsApiServer) + ' ms')
  })
  process.on('exit', () => {
    void http?.close()
  })
}

void main()

Are you interested in working on this?

  • I'm interested in working on this
@MichaelrMentele
Copy link
Contributor Author

Detailed plan needs development. Unclear to me best way to proceed without more XP in RW internals.

@Josh-Walker-GM
Copy link
Collaborator

We've started in this direction with #8119 which enabled an experimental server.ts|js file which should provide the level of control described here. Unless I'm mistaken then @jtoar will correct me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants