Upgraded dependencies, bumped to Node 24.
This commit is contained in:
@@ -1,50 +1,50 @@
|
||||
import config from 'config';
|
||||
import path from 'path';
|
||||
import express from 'express';
|
||||
import boolParser from 'express-query-boolean';
|
||||
import Router from 'express-promise-router';
|
||||
import session from 'express-session';
|
||||
import RedisStore from 'connect-redis';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import compression from 'compression';
|
||||
import cookie from 'cookie';
|
||||
|
||||
import redis from '../redis.js';
|
||||
|
||||
import errorHandler from './error.js';
|
||||
import consentHandler from './consent.js';
|
||||
import initRestrictionHandler from './restrictions.js';
|
||||
|
||||
import { scenesRouter } from './scenes.js';
|
||||
import { actorsRouter } from './actors.js';
|
||||
import { syncRouter } from './sync.js';
|
||||
|
||||
import { fetchMoviesApi } from './movies.js';
|
||||
import { fetchEntitiesApi } from './entities.js';
|
||||
import { fetchTagsApi } from './tags.js';
|
||||
import config from 'config';
|
||||
import { RedisStore } from 'connect-redis';
|
||||
import { parseCookie } from 'cookie';
|
||||
import express, { Router } from 'express';
|
||||
import session from 'express-session';
|
||||
|
||||
import { verifyKey } from '../auth.js';
|
||||
import initLogger from '../logger.js';
|
||||
|
||||
import redis from '../redis.js';
|
||||
import queryBoolean from '../utils/query-boolean.js';
|
||||
import { actorsRouter } from './actors.js';
|
||||
|
||||
import { router as alertsRouter } from './alerts.js';
|
||||
import {
|
||||
createKeyApi,
|
||||
fetchUserKeysApi,
|
||||
flushUserKeysApi,
|
||||
loginApi,
|
||||
logoutApi,
|
||||
removeUserKeyApi,
|
||||
setUserApi,
|
||||
signupApi,
|
||||
} from './auth.js';
|
||||
import consentHandler from './consent.js';
|
||||
|
||||
import { fetchEntitiesApi } from './entities.js';
|
||||
import errorHandler from './error.js';
|
||||
import { graphqlApi } from './graphql.js';
|
||||
|
||||
import mainHandler from './main.js';
|
||||
import { fetchMoviesApi } from './movies.js';
|
||||
|
||||
import {
|
||||
setUserApi,
|
||||
loginApi,
|
||||
logoutApi,
|
||||
signupApi,
|
||||
fetchUserKeysApi,
|
||||
createKeyApi,
|
||||
removeUserKeyApi,
|
||||
flushUserKeysApi,
|
||||
} from './auth.js';
|
||||
import initRestrictionHandler from './restrictions.js';
|
||||
|
||||
import { scenesRouter } from './scenes.js';
|
||||
|
||||
import { router as userRouter } from './users.js';
|
||||
import { router as stashesRouter } from './stashes.js';
|
||||
import { router as alertsRouter } from './alerts.js';
|
||||
|
||||
import { syncRouter } from './sync.js';
|
||||
import { initCachesApi } from './system.js';
|
||||
|
||||
import initLogger from '../logger.js';
|
||||
import { fetchTagsApi } from './tags.js';
|
||||
|
||||
import { router as userRouter } from './users.js';
|
||||
|
||||
const logger = initLogger();
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
@@ -57,8 +57,11 @@ export default async function initServer() {
|
||||
app.use(compression());
|
||||
app.disable('x-powered-by');
|
||||
app.set('view engine', 'ejs');
|
||||
// Express 5 defaults to the 'simple' query parser (Node's querystring) instead of 'extended'
|
||||
// (qs), which drops support for the bracket/nested query syntax the app relies on.
|
||||
app.set('query parser', 'extended');
|
||||
|
||||
router.use(boolParser());
|
||||
router.use(queryBoolean());
|
||||
|
||||
router.use('/', express.static('public'));
|
||||
router.use('/', express.static('static'));
|
||||
@@ -66,12 +69,10 @@ export default async function initServer() {
|
||||
|
||||
router.use((req, _res, next) => {
|
||||
if (req.headers.cookie) {
|
||||
const cookies = cookie.parse(req.headers.cookie);
|
||||
const cookies = parseCookie(req.headers.cookie);
|
||||
|
||||
/* eslint-disable no-param-reassign */
|
||||
req.cookies = cookies;
|
||||
req.tagFilter = cookies.tags ? JSON.parse(cookies.tags) : [];
|
||||
/* eslint-enable no-param-reassign */
|
||||
}
|
||||
|
||||
next();
|
||||
@@ -99,7 +100,8 @@ export default async function initServer() {
|
||||
// (In dev, Vite's middleware serves our static assets.)
|
||||
const sirv = (await import('sirv')).default;
|
||||
router.use(sirv('dist/client'));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// We instantiate Vite's development server and integrate its middleware to our server.
|
||||
// ⚠️ We instantiate it only in development. (It isn't needed in production and it
|
||||
// would unnecessarily bloat our production server.)
|
||||
@@ -121,7 +123,7 @@ export default async function initServer() {
|
||||
res.sendFile(path.join(import.meta.dirname, '../../assets/consent.html'));
|
||||
});
|
||||
|
||||
router.use('/api/*', async (req, _res, next) => {
|
||||
router.use('/api/{*splat}', async (req, _res, next) => {
|
||||
if (req.headers['api-user']) {
|
||||
req.user = await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
|
||||
}
|
||||
@@ -167,16 +169,14 @@ export default async function initServer() {
|
||||
router.use(consentHandler);
|
||||
|
||||
router.use((_req, res, next) => {
|
||||
/* eslint-disable no-param-reassign */
|
||||
res.set('Accept-CH', 'Sec-CH-Prefers-Color-Scheme');
|
||||
res.set('Vary', 'Sec-CH-Prefers-Color-Scheme');
|
||||
res.set('Critical-CH', 'Sec-CH-Prefers-Color-Scheme');
|
||||
/* eslint-enable no-param-reassign */
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
router.get('*', mainHandler);
|
||||
router.get('/{*splat}', mainHandler);
|
||||
|
||||
router.use(errorHandler);
|
||||
app.use(router);
|
||||
|
||||
Reference in New Issue
Block a user