Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions templates/eject-esm/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import Fastify from 'fastify'
import closeWithGrace from 'close-with-grace'

// Import your application
import appService from './app.js'
import { app as serviceApp, options as serviceOptions} from './app.js'

// Read and load environment variables from .env files (ignore if not present)
try {
process.loadEnvFile()
} catch {}

// Instantiate Fastify with some config
const app = Fastify({
const app = Fastify(serviceOptions || {
logger: true
})

// Register your application as a normal plugin
app.register(appService)
app.register(serviceApp)

// delay is the number of milliseconds for the graceful close to finish
closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) {
Expand Down
7 changes: 5 additions & 2 deletions templates/eject-ts/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import Fastify from 'fastify'
// Require library to exit fastify process, gracefully (if possible)
import closeWithGrace from 'close-with-grace'

// Import your application
import { app as serviceApp, options as serviceOptions} from './app.ts'

// Read and load environment variables from .env files (ignore if not present)
try {
process.loadEnvFile()
} catch {}

// Instantiate Fastify with some config
const app = Fastify({
const app = Fastify(serviceOptions || {
logger: true,
})

// Register your application as a normal plugin
app.register(import('./app'))
app.register(serviceApp)

// delay is the number of milliseconds for the graceful close to finish
closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }, async function ({ signal, err, manual }) {
Expand Down
9 changes: 5 additions & 4 deletions templates/eject/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ const Fastify = require('fastify')
// Require library to exit fastify process, gracefully (if possible)
const closeWithGrace = require('close-with-grace')

// Register your application as a normal plugin.
const appService = require('./app.js')

// Instantiate Fastify with some config
const app = Fastify({
const app = Fastify(appService.options || {
logger: true
})

// Register your application as a normal plugin
const appService = require('./app.js')
app.register(appService)
app.register(appService.app)

// delay is the number of milliseconds for the graceful close to finish
closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) {
Expand Down