Files
SAFEKISO/safekiso-server/modules/safekiso/routes/main.js
2026-04-07 14:50:23 +09:00

87 lines
1.9 KiB
JavaScript

var express = require('express');
var router = express.Router();
var util = require('util');
var mysql = require('mysql');
var utils = require('../../../src/utils');
var crossCtl = require('../../../src/crossCtl');
const localHandler = require('../');
localHandler.setRouterMain(router);
var path = require('path');
var passport = require('passport');
// import { handle } from '../client/twf/.output/server/index.mjs';
// operation
/*
router.use(function (req, res, next) {
next()
})
*/
function commonGate(req, res) {
if (req.isAuthenticated() === false) {
req.workTag
.res()
.redirect('/signin?loc=' + encodeURIComponent(req.infos.rawLoc));
} else {
res.render('main/pages/index', { infos: req.infos });
}
}
router.get('/profile', function (req, res) {
var profileType = 'me';
if (req.query.pid !== undefined) {
profileType = 'other';
}
req.infos.profileType = profileType;
res.render('main/pages/index', { infos: req.infos });
});
router.get('/profile/edit', function (req, res) {
var profileType = 'me';
if (req.query.pid !== undefined) {
profileType = 'other';
}
req.infos.profileType = profileType;
commonGate(req, res);
});
/*
const fs = require('fs');
router.use(function (req, res, next) {
let clientPath = path.join(
__dirname,
'..',
'client',
crossCtl.sConfig.type,
'.output',
'public',
'index.html'
);
fs.access(clientPath, fs.F_OK, (err) => {
if (err) {
res.render('main/pages/index', { infos: req.infos });
} else {
req.workTag
.res()
.status(200)
.type('text/html')
.sendFile(clientPath);
}
});
// req.workTag.res().status(200).type('text/html').sendFile(path.join(__dirname, '..', 'wwwroot', 'text.html'))
});
*/
module.exports = router;