-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
46 lines (38 loc) · 1.11 KB
/
server.js
File metadata and controls
46 lines (38 loc) · 1.11 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
45
46
const express = require('express');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const mysql = require('mysql2');
const app = express();
const connection = mysql.createConnection({
host: 'localhost',
user: 'swiftdocs',
password: 'gvQtFW6Hc9Zn(vBO',
database: 'swiftdocs'
});
connection.connect((err) => {
if (err) {
console.error('Error connecting to MySQL:', err);
return;
}
console.log('Connected to MySQL database');
});
app.use(express.json());
// User Registration
app.post('/register', async (req, res) => {
// Implement user registration logic using MySQL queries
});
// User Login
app.post('/login', async (req, res) => {
// Implement user login logic using MySQL queries
});
// Staff Documentation Access
app.get('/staff-docs', authenticateToken, (req, res) => {
// This endpoint will only be accessible to authenticated users (staff)
res.sendFile(__dirname + '/frontend/staff_docs.html');
});
function authenticateToken(req, res, next) {
// Implement JWT token verification logic
}
app.listen(3000, () => {
console.log('Server running on port 3000');
});