to do: troubleshoot missing token in request headers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Express } from 'express';
|
||||
import express, { Express } from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import morgan from 'morgan';
|
||||
@@ -19,8 +19,8 @@ declare module 'express-session' {
|
||||
|
||||
export const expressLoader = async (app: Express) => {
|
||||
app.use(cors({ origin: origin }));
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.use(cookieParser());
|
||||
app.use(morgan('tiny'));
|
||||
app.use(requireSessionSecret);
|
||||
|
||||
@@ -56,6 +56,8 @@ export const authRoute = (app: Express) => {
|
||||
|
||||
const safeUserData = {
|
||||
id: user.id,
|
||||
firstname: user.firstname,
|
||||
lastname: user.lastname,
|
||||
handle: user.handle,
|
||||
email: user.email,
|
||||
datecreated: user.datecreated,
|
||||
|
||||
@@ -8,6 +8,12 @@ const router = Router();
|
||||
export const collectionRoute = (app: Express) => {
|
||||
app.use('/app/collection', router);
|
||||
|
||||
router.use((req, res, next) => {
|
||||
console.log('what gives');
|
||||
console.log(req.body);
|
||||
next();
|
||||
})
|
||||
|
||||
router.get('/:id', async (req, res, next) => {
|
||||
const { id } = req.params;
|
||||
try {
|
||||
@@ -30,7 +36,7 @@ export const collectionRoute = (app: Express) => {
|
||||
|
||||
router.post('/', async (req, res, next) => {
|
||||
const data = req.body;
|
||||
console.log(data);
|
||||
console.log(req.body ?? "sanity check");
|
||||
|
||||
try {
|
||||
const result = await CollectionInstance.post(data);
|
||||
|
||||
@@ -25,7 +25,7 @@ export const routes = async (app: Express) => {
|
||||
console.log(token);
|
||||
|
||||
if (!token) {
|
||||
res.status(403).send("Unauthorized");
|
||||
res.status(403).send("Unauthorized, did not receive token");
|
||||
} else {
|
||||
jwt.verify(token, process.env.SESSIONSECRET as string, (err, data) => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user