UP checkAuthenticated.js -> ts
This commit is contained in:
parent
9452dcf90e
commit
c5b2e2d82b
@ -1,7 +1,8 @@
|
||||
import { type Express, type NextFunction, type Request, type Response } from "express";
|
||||
import UserModel from '../models/userModel';
|
||||
|
||||
var UserModel = require('../models/userModel');
|
||||
|
||||
async function checkAuthenticated(req, res, next) {
|
||||
async function checkAuthenticated(req: Request, res: Response, next: NextFunction) {
|
||||
try {
|
||||
const password = req.body.pass;
|
||||
const userFound = await UserModel.findOne({ pass: password });
|
||||
@ -16,4 +17,4 @@ async function checkAuthenticated(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = checkAuthenticated;
|
||||
export default checkAuthenticated;
|
13
miscellaneous/custom.d.ts
vendored
Normal file
13
miscellaneous/custom.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
declare namespace Express {
|
||||
export interface Request {
|
||||
user?: Document<unknown, {}, {
|
||||
pass?: string | undefined;
|
||||
omdb_key?: string | undefined;
|
||||
twitch_client_id?: string | undefined;
|
||||
twitch_client_secret?: string | undefined;
|
||||
mac_address?: string | undefined;
|
||||
}>
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
const checkAuthenticated = require('../../middleware/checkAuthenticated.js');
|
||||
const checkAuthenticated = require('../../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
var mediaRouter = require('./mediaRouter');
|
||||
var gameRouter = require('./gameRouter');
|
||||
|
@ -1,7 +1,7 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var gameController = require('../../controllers/gameController.js');
|
||||
var checkAuthenticated = require('../../middleware/checkAuthenticated.js');
|
||||
var checkAuthenticated = require('../../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
router.get('/', gameController.list);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var mediaController = require('../../controllers/mediaController.js');
|
||||
var checkAuthenticated = require('../../middleware/checkAuthenticated.js');
|
||||
var checkAuthenticated = require('../../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
router.get('/', mediaController.list);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var userController = require('../controllers/userController.js');
|
||||
const checkAuthenticated = require('../middleware/checkAuthenticated.js');
|
||||
const checkAuthenticated = require('../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', function (req, res, next) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user