working ish website

This commit is contained in:
Siwat Sirichai 2024-05-05 18:13:58 +07:00
parent 5540ac6d81
commit b194d2031d
8 changed files with 271 additions and 6 deletions

View file

@ -20,6 +20,14 @@ app.use(passport.session());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get('/selfservice/api/whoami', function (req, res) {
if (!req.isAuthenticated()) {
return res.status(401).send('Unauthorized');
}
// Send user type and upn in json format
res.send({ userType: req.user.userType, upn: req.user.username });
});
let authRoutes = require('./routes/auth.js');
app.use('/', authRoutes);
let psRelationStudentRoutes = require('./routes/ps_relation_student.js');
@ -27,6 +35,9 @@ app.use('/selfservice/api', psRelationStudentRoutes);
let psRelationParentRoutes = require('./routes/ps_relation_parent.js');
app.use('/selfservice/api', psRelationParentRoutes);
// Serve Static Files
app.use("/",express.static('statics'));
let server = https.createServer(http_config.options, app);
server.listen(3000, function () {
console.log('Listening on port 3000');