initial commit
This commit is contained in:
15
server/plugins/db.init.js
Normal file
15
server/plugins/db.init.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { getDb, closeDb } from '../utils/db.js'
|
||||
import { migrateFeedsToDevices } from '../utils/migrateFeedsToDevices.js'
|
||||
|
||||
/**
|
||||
* Initialize DB (and run bootstrap if no users) at server startup
|
||||
* so credentials are printed in the terminal before any request.
|
||||
* Close DB on server shutdown to avoid native sqlite3 crashes in worker teardown.
|
||||
*/
|
||||
// eslint-disable-next-line no-undef
|
||||
export default defineNitroPlugin((nitroApp) => {
|
||||
void getDb().then(() => migrateFeedsToDevices())
|
||||
nitroApp.hooks.hook('close', () => {
|
||||
closeDb()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user