-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (35 loc) · 1.29 KB
/
Copy pathserver.js
File metadata and controls
44 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* MindRoots - Arabic Morphology Visualization Tool
* Copyright (c) 2024 MindRoots Project
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
require('dotenv').config(); // Load environment variables
const express = require('express');
const neo4j = require('neo4j-driver');
const cors = require('cors');
const path = require('path');
const apiRoutes = require('./routes/api');
const app = express();
const port = 5001;
app.use(cors());
app.use(express.json({ limit: '15mb' })); // 15mb accommodates base64-encoded image uploads (~10MB decoded)
// Static file serving for multi-tenant workspaces
app.use('/workspaces', express.static(path.join(__dirname, 'workspaces')));
// Neo4j driver setup using environment variables
const driver = neo4j.driver(
process.env.NEO4J_URI,
neo4j.auth.basic(process.env.NEO4J_USERNAME, process.env.NEO4J_PASSWORD)
);
// Middleware to make the Neo4j driver available to all routes
app.use((req, res, next) => {
req.driver = driver;
next();
});
// Use the api routes
app.use('/api', apiRoutes);
// Start the server
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});