nm3clol-express-app/app/server.mts

42 lines
1.6 KiB
TypeScript

console.log(`Starting up nm3clol-express-app...`);
import express from 'express';
import axios from 'axios';
import pageRouter from './page/router.mjs';
import searchRouter from './search/router.mjs';
import { config } from './config.mjs';
const app = express();
console.log(`Running app configuration:`, config);
// Set EJS as the view engine
app.set('view engine', 'ejs');
// Specify the views directory
app.set('views', config.viewsPath);
// Middleware to parse JSON request body
app.use(express.json());
// Middleware to rewrite requests
//app.use(rewriter);
// Search endpoints
console.log(`Assigning /search route to search router.`);
app.use('/search', searchRouter());
// app.use('/advanced-search', advancedSearch.router);
// Page endpoints
console.log(`Assigning / route to page router.`);
app.use('/', pageRouter());
// Start server
app.listen(config.appHttpPort, () => {
console.log(`nm3clol-express-app HTTP server listening on port ${config.appHttpPort}.`)
console.log(`To access your app, you can use the localhost URL, http://localhost:${config.appHttpPort}.`);
console.log(`To access your app, you can use the 127.0.0.1 host, http://127.0.0.1:${config.appHttpPort}.`);
console.log(`To access your app, you can use the ::1 host, http://[::1]:${config.appHttpPort}.`);
console.log(`To access your app, you might can use the app host name, ${config.appHttpUrl}.`);
console.log(`This app is configured to use the web site URL for URL generation, as needed, ${config.siteUrl}. Certain site features won't work correctly unless this is on a publicly accessible URL.`);
});