Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchoz49 committed Oct 14, 2024
1 parent cce4873 commit d6ade10
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ A robust and modern starter template for building high-performance web applicati
## Fastify Plugins

- **[@fastify/auth](https://github.com/fastify/fastify-auth)**: Authentication plugin for Fastify
- **[@fastify/cors](https://github.com/fastify/fastify-cors)**: Enable CORS
- **[@fastify/helmet](https://github.com/fastify/fastify-helmet)**: Secure the application by setting various HTTP headers
- **[@fastify/swagger](https://github.com/fastify/fastify-swagger)**: Document the API using Swagger
- **[@scalar/fastify-api-reference](https://github.com/scalar/scalar/tree/main/packages/fastify-api-reference)**: OpenAPI/Swagger interactive API documentation
- **[@fastify/type-provider-typebox](https://github.com/fastify/fastify-type-provider-typebox)**: Type-safe schema definition language
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
"dependencies": {
"@fastify/auth": "^5.0.1",
"@fastify/autoload": "^6.0.1",
"@fastify/cors": "^10.0.0",
"@fastify/helmet": "^12.0.0",
"@fastify/jwt": "^9.0.1",
"@fastify/swagger": "^9.0.0",
"@fastify/type-provider-typebox": "^5.0.0",
Expand Down
10 changes: 0 additions & 10 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ export const createApp = (options: AppOptions = {}) => {

// fastify plugins
app.register(import('fastify-better-error'), { errors })
app.register(import('@fastify/cors'))
app.register(import('@fastify/helmet'))

// user plugins
app.register(autoload, {
Expand All @@ -76,14 +74,6 @@ export const createApp = (options: AppOptions = {}) => {
})

app.addHook('onReady', async () => {
if (env.DATABASE.RUN_MIGRATE) {
await app.drizzle.migrate()
}

if (env.DATABASE.RUN_SEED) {
await app.drizzle.seed()
}

const hrend = process.hrtime(hrstart)
app.log.info('Execution time (hr): %ds %dms', hrend[0], hrend[1] / 1000000)
})
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/drizzle.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ async function drizzlePlugin(app: App) {
}
})

app.addHook('onReady', async () => {
if (env.RUN_MIGRATE) {
await app.drizzle.migrate()
}

if (env.RUN_SEED) {
await app.drizzle.seed()
}
})

app.decorate('drizzle', {
db,
entities: schema,
Expand Down

0 comments on commit d6ade10

Please sign in to comment.