Files
simplenote-web/src/index.js
Hiro c4921c8e73 feat: add frontend UI for SimpleNote Web
- Vanilla JS frontend with dark theme
- Dashboard with sidebar (libraries tree, tags), document grid, search
- Document viewer with markdown rendering and metadata panel
- Document editor with split write/preview and formatting toolbar
- Login screen with token authentication
- All styled according to UI/UX specs (dark theme, accent #00d4aa)
- API client for all endpoints
- Responsive design
2026-03-28 11:44:42 +00:00

51 lines
1.5 KiB
JavaScript

/**
* SimpleNote Web - Entry Point
* Document management API with nested libraries and markdown support
*/
import express from 'express';
import cors from 'cors';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import config from './config/index.js';
import { createApiRouter } from './routes/index.js';
import { errorHandler } from './middleware/errorHandler.js';
import { initTagIndexer } from './indexers/tagIndexer.js';
import { ensureDir } from './utils/fsHelper.js';
const app = express();
// Serve static files from public/
app.use(express.static(join(dirname(fileURLToPath(import.meta.url)), '..', 'public')));
// Middleware
app.use(cors({ origin: config.corsOrigin }));
app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ extended: true }));
// Health check (unprotected)
app.get('/health', (req, res) => {
res.json({ status: 'ok', timestamp: new Date().toISOString(), version: '1.0.0' });
});
// Ensure data directory exists
ensureDir(config.dataRoot);
// Initialize tag indexer
console.log(`[SimpleNote] Data root: ${config.dataRoot}`);
initTagIndexer(config.dataRoot);
// Mount API routes
app.use(config.apiPrefix, createApiRouter(config.apiPrefix));
// Error handler
app.use(errorHandler);
// Start server
app.listen(config.port, config.host, () => {
console.log(`[SimpleNote] Web API running on http://${config.host}:${config.port}`);
console.log(`[SimpleNote] API prefix: ${config.apiPrefix}`);
});
export default app;