| // | |
| // SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org> | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // | |
| import express from 'express'; | |
| import { fileURLToPath } from 'url'; | |
| import path from 'path'; | |
| import config from './config.js'; | |
| import imageRoutes from | |
| './src/routes/imageRoutes.js'; | |
| import { initCleanup } from | |
| './src/services/storageManager.js'; | |
| import { setupViewEngine } from | |
| './src/middleware/viewEngine.js'; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| const app = express(); | |
| setupViewEngine(app, __dirname); | |
| app.use(express.urlencoded({ | |
| extended: true, | |
| limit: config.limits.bodySize | |
| })); | |
| app.use( | |
| "/__public__/assets", | |
| express.static(path.resolve("assets")) | |
| ); | |
| app.use(express.static( | |
| path.join(__dirname, 'public') | |
| )); | |
| app.use('/', imageRoutes); | |
| initCleanup(); | |
| app.listen( | |
| config.server.port, | |
| config.server.host | |
| ); |