ts: lib/homepage/index.ts

Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
Raccoon 2021-06-12 04:50:12 +08:00
parent 45def871a6
commit 92c0575977
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38
4 changed files with 31 additions and 19 deletions

View File

@ -1,12 +1,13 @@
'use strict'
import * as fs from 'fs'
import * as path from 'path'
import * as config from '../config'
// @ts-ignore
import {User} from '../models'
import * as logger from '../logger'
import {Request, Response} from "express";
const fs = require('fs')
const path = require('path')
const config = require('../config')
const { User } = require('../models')
const logger = require('../logger')
exports.showIndex = async (req, res) => {
export async function showIndex(req: Request, res: Response) {
const isLogin = req.isAuthenticated()
const deleteToken = ''
@ -25,7 +26,7 @@ exports.showIndex = async (req, res) => {
const user = await User.findOne({
where: {
id: req.user.id
id: (req.user as any).id
}
})
if (user) {
@ -33,6 +34,6 @@ exports.showIndex = async (req, res) => {
return res.render('index.ejs', data)
}
logger.error(`error: user not found with id ${req.user.id}`)
logger.error(`error: user not found with id ${(req.user as any).id}`)
return res.render('index.ejs', data)
}

24
package-lock.json generated
View File

@ -1277,15 +1277,25 @@
}
},
"@types/express": {
"version": "4.17.2",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.2.tgz",
"integrity": "sha512-5mHFNyavtLoJmnusB8OKJ5bshSzw+qkMIBAobLrIM48HJvunFva9mOa6aBwh64lBFyNwBbs0xiEFuj4eU/NjCA==",
"version": "4.17.9",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.9.tgz",
"integrity": "sha512-SDzEIZInC4sivGIFY4Sz1GG6J9UObPwCInYJjko2jzOf/Imx/dlpume6Xxwj1ORL82tBbmN4cPDIDkLbWHk9hw==",
"requires": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "*",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"@types/express-flash": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/@types/express-flash/-/express-flash-0.0.2.tgz",
"integrity": "sha512-1l0s3YiZpMkWZ/65S4iSOLOnI7bYNDgnxx54nw5eA2pWOZ7Vvc7PpDv6iJq0bB7EBusoVWkzd+RV4r/nLY4/HA==",
"dev": true,
"requires": {
"@types/express": "*"
}
},
"@types/express-serve-static-core": {
"version": "4.17.2",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.2.tgz",
@ -1353,9 +1363,9 @@
"integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw=="
},
"@types/node": {
"version": "10.17.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.14.tgz",
"integrity": "sha512-G0UmX5uKEmW+ZAhmZ6PLTQ5eu/VPaT+d/tdLd5IFsKRPcbe6lPxocBtcYBFSaLaCW8O60AX90e91Nsp8lVHCNw=="
"version": "12.20.15",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.15.tgz",
"integrity": "sha512-F6S4Chv4JicJmyrwlDkxUdGNSplsQdGwp1A0AJloEVDirWdZOAiRHhovDlsFkKUrquUXhz1imJhXHsf59auyAg=="
},
"@types/passport": {
"version": "1.0.2",
@ -9653,7 +9663,6 @@
"integrity": "sha512-ipVpHX1UL9K5klPYTlQzrBbGejrFjavrld4PVbSShz5nnaK8oYo6v/85Ys/S7jylCkgpQn5QLGGWEhYYjcFbWA==",
"requires": {
"@types/ldapjs": "^1.0.0",
"@types/node": "^10.12.12",
"bcryptjs": "^2.4.0",
"ldapjs": "^1.0.2",
"lru-cache": "^5.1.1"
@ -11950,7 +11959,6 @@
"resolved": "https://registry.npmjs.org/passport-ldapauth/-/passport-ldapauth-2.1.3.tgz",
"integrity": "sha512-23n425UTasN6XhcXG0qQ0h0YrS/zfo8kNIEhSLfPsNpglhYhhQFfB1pmDc5RrH+Kiz5fKLkki5BpvkKHCwkixg==",
"requires": {
"@types/node": "^10.12.26",
"@types/passport": "^1.0.0",
"ldapauth-fork": "^4.2.0",
"passport-strategy": "^1.0.0"

View File

@ -110,7 +110,9 @@
"@hackmd/idle-js": "~1.0.1",
"@hackmd/js-sequence-diagrams": "~0.0.1-alpha.3",
"@susisu/mte-kernel": "^2.1.0",
"@types/node": "^10.17.14",
"@types/express": "4.17.9",
"@types/express-flash": "~0.0.2",
"@types/node": "~12.20.15",
"acorn": "~6.1.1",
"babel-core": "~6.26.3",
"babel-loader": "~7.1.4",

View File

@ -7,5 +7,6 @@
},
"include": [
"./lib/**/*"
]
],
"exclude": ["node_modules"]
}