Comments (5)
Thank you! I found the determining thing for me that got it to work was passing in legacyMode: true into createClient.
from lireddit.
Thanks! I went through stack overflow and asked a lot of questions to chat gpt. But this is the only one that worked. :)
from lireddit.
I still get this error:
let RedisStore = require("connect-redis")(session);
^
TypeError: require(...) is not a function
at Object.<anonymous> (C:\Users\moham\Documents\Projects\lilReddit\dist\index.js:26:42)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47
[nodemon] app crashed - waiting for file changes before starting...
in yarn dev console.
Here's my code:
import "dotenv/config";
import { MikroORM } from "@mikro-orm/core";
import { __prod__ } from "./constants";
import microConfig from "./mikro-orm.config";
import express from "express";
import { ApolloServer } from "apollo-server-express";
import { buildSchema } from "type-graphql";
import "reflect-metadata";
import { UserResolver } from "./resolvers/user";
import { PostResolver } from "./resolvers/post";
import { MyContext } from "types";
const session = require("express-session");
let RedisStore = require("connect-redis")(session);
const main = async () => {
const orm = await MikroORM.init(microConfig);
await orm.getMigrator().up();
const { createClient } = require("redis");
let redisClient = createClient({ legacyMode: true });
redisClient.on("connect", () => console.log("Connected to Redis!"));
redisClient.on("error", (err: Error) =>
console.log("Redis Client Error", err)
);
redisClient.connect();
const app = express();
app.use(
session({
name: "qid",
store: new RedisStore({
client: redisClient,
disableTouch: true,
}),
cookie: {
maxAge: 1000 * 60 * 60 * 24 * 365 * 1, // 1 year
httpOnly: true,
sameSite: "lax",
secure: __prod__, // cookie only works in https
},
saveUninitialized: false,
secret: "bruhhhh",
resave: false,
})
);
My tsconfig:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": "./src",
"paths": {
"*": ["*", "src/*"]
},
"types": ["node", "express", "express-session"]
},
"exclude": ["node_modules"],
"include": ["./src/**/*.tsx", "./src/**/*.ts"]
}
I appreciate any help
from lireddit.
Found the fix :
https://www.npmjs.com/package/connect-redis
from lireddit.
@mhd-hi, how did the link help? what did you do differently. i have similar issue. Thanks
from lireddit.
Related Issues (20)
- I'm getting this error HOT 1
- Mikro-orm branches
- `cache.resolveFieldByKey` is deprected HOT 6
- dbName ="lireddit" Invalid shorthand property intliazer HOT 2
- Cookie does not clear from browser in production HOT 2
- TypeError: is not a function or its return value is not iterable HOT 2
- CORS error when loading schema from GraphQL Code Generator HOT 1
- Samesite Lax cookie not being set HOT 15
- Redis ClientClosedError after cookie is set HOT 4
- ERR_INVALID_ARG_TYPE when setting req.session.userId HOT 2
- Dokku app container failed to start: exec docker-entrypoint.sh failed: Exec format error HOT 3
- useMeQuery() doesn't run after redirection from login/register page HOT 4
- Error: Cannot use GraphQLObjectType "FieldError" from another module or realm (problem and solution)
- Problem + Solution: More than one row returned by a subquery used as an expression
- TypeError: Cannot set property 'userId' of undefined HOT 3
- createConnection typeorm deprecation
- The Me query HOT 2
- findByIds Deprecated HOT 1
- Module parse failed: Unexpected token (4:39)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lireddit.