showing info in dashboard
This commit is contained in:
@@ -3,6 +3,7 @@ import cors from 'cors';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import http from 'http';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import chalk from 'chalk';
|
||||
import moment from 'moment';
|
||||
import path from 'path';
|
||||
@@ -21,6 +22,7 @@ class Server {
|
||||
auth;
|
||||
UIPath = path.join(__dirname, '../ui')
|
||||
DBPath = path.join(__dirname, '../db')
|
||||
ComalPath = path.join(os.homedir(), 'Sites/comalyr.com')
|
||||
|
||||
registerRoutes(router) {
|
||||
/* Stripe */
|
||||
@@ -35,10 +37,33 @@ class Server {
|
||||
/* Site */
|
||||
router.post('/signup', this.verifySignupToken, this.newUserSubmission)
|
||||
router.get('/db/images/*', this.getUserImage)
|
||||
router.get('/app/comaldata', this.getComalData)
|
||||
router.get('/*', this.get)
|
||||
return router
|
||||
}
|
||||
|
||||
getComalData = async (req, res, next) => {
|
||||
try {
|
||||
const pathOne = path.join(this.ComalPath, "db", "join.json");
|
||||
const pathTwo = path.join(this.ComalPath, "db", "contact.json");
|
||||
|
||||
const [joinRaw, contactRaw] = await Promise.all([
|
||||
fs.promises.readFile(pathOne, "utf8"),
|
||||
fs.promises.readFile(pathTwo, "utf8")
|
||||
]);
|
||||
|
||||
const join = joinRaw.trim() ? JSON.parse(joinRaw) : [];
|
||||
const contact = contactRaw.trim() ? JSON.parse(contactRaw) : [];
|
||||
|
||||
res.json({
|
||||
join,
|
||||
contact
|
||||
});
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
||||
verifySignupToken = (req, res, next) => {
|
||||
const { token } = req.query;
|
||||
if (!token) {
|
||||
|
||||
Reference in New Issue
Block a user