This commit is contained in:
lesion 2022-08-22 17:18:00 +02:00
parent fa55f75c7e
commit 87765ba2c0
3 changed files with 10 additions and 5 deletions

View file

@ -6,10 +6,10 @@ import serveStatic from 'serve-static'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
ssr: true,
nitro: {
plugins: ['~/server/startup.js'],
},
buildModules: ['@nuxtjs/tailwindcss', 'unplugin-icons/nuxt', '@nuxtjs/svg'],
serverMiddleware: [
{ path: '/imgs', handler: serveStatic(__dirname + '/imgs') }
],
vite: {
plugins: [
UnpluginComponentsVite({

View file

@ -4,10 +4,10 @@ import { v4 } from 'uuid'
const db = new Database('./cosette.db')
function load() {
export function load() {
db.pragma('journal_mode = WAL')
db.exec('CREATE TABLE IF NOT EXISTS cosette (uuid TEXT PRIMARY KEY, name TEXT NOT NULL, description TEXT, tags TEXT, images TEXT, updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP)')
db.exec('CREATE INDEX cosette_updated_at_index ON cosette (updatedAt)')
db.exec('CREATE INDEX IF NOT EXISTS cosette_updated_at_index ON cosette (updatedAt)')
db.exec('CREATE TABLE IF NOT EXISTS chan (uuid TEXT PRIMARY KEY, cosetta_uuid REFERENCES cosette(uuid), message TEXT, updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP)')
}
// TODO: da gestire in qualche modo all'avvio

5
server/startup.js Normal file
View file

@ -0,0 +1,5 @@
import { load } from '../server/controller'
export default () => {
load()
}