Skip to content

Commit

Permalink
fix: remove dependency on express-session
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Aug 22, 2024
1 parent 8fd19cf commit 7d93d1e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 84 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ HOST=127.0.0.1
PORT=3000
# Redis configuration
REDIS_URL=redis://localhost:6379
# Session Secret (generate a random string with `openssl rand -hex 32`)
SESSION_SECRET=
# Solana Cluster endpoints.
# NOTE: Currently we only test with Helius on devnet/mainnet. Patches to fix this are welcome.
#SOLANA_CUSTOM_ENDPOINT=http://localhost:8899
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ env:
REDIS_URL: redis://localhost:6379
JWT_SECRET: 1dfe5003518560c6362eab48f8220edf8708bbc67efbd4ed8cdf621965e938ee
PORT: 3000
SESSION_SECRET: 1dfe5003518560c6362eab48f8220edf8708bbc67efbd4ed8cdf621965e938ee
# TODO: Fix the setup so works on a local validator
SOLANA_MAINNET_ENDPOINT: 'https://api.mainnet-beta.solana.com'

Expand Down
9 changes: 0 additions & 9 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Logger } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { ApiCoreService, EVENT_APP_STARTED } from '@pubkey-link/api-core-data-access'
import cookieParser from 'cookie-parser'
import session from 'express-session'
import { exec } from 'node:child_process'
import { AppModule } from './app/app.module'

Expand All @@ -11,14 +10,6 @@ async function bootstrap() {
const core = app.get(ApiCoreService)
app.setGlobalPrefix(core.config.prefix)
app.use(cookieParser())
app.use(
session({
secret: core.config.sessionSecret,
resave: false,
saveUninitialized: false,
cookie: { secure: !core.config.isDevelopment },
}),
)

const host = `http://${core.config.host}:${core.config.port}`
await app.listen(core.config.port, core.config.host)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ export class ApiCoreConfigService {
return this.service.get('redisUrl')
}

get sessionSecret() {
return this.service.get<string>('sessionSecret') as string
}

get solanaCustomEndpoint() {
return this.service.get<string>('solanaCustomEndpoint') as string
}
Expand Down
3 changes: 0 additions & 3 deletions libs/api/core/data-access/src/lib/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export interface ApiCoreConfig {
port: number
// Redis
redisUrl: string
// Session
sessionSecret: string
// Solana Endpoints
solanaCustomEndpoint: string
solanaDevnetEndpoint: string
Expand Down Expand Up @@ -120,7 +118,6 @@ export function configuration(): ApiCoreConfig {
jwtSecret: process.env['JWT_SECRET'] as string,
port: parseInt(process.env['PORT'] as string, 10) || 3000,
redisUrl: process.env['REDIS_URL'] as string,
sessionSecret: process.env['SESSION_SECRET'] as string,
solanaCustomEndpoint: process.env['SOLANA_CUSTOM_ENDPOINT'] as string,
solanaDevnetEndpoint: process.env['SOLANA_DEVNET_ENDPOINT'] as string,
solanaMainnetEndpoint: process.env['SOLANA_MAINNET_ENDPOINT'] as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const validationSchema = Joi.object({
NODE_ENV: Joi.string().valid('development', 'production', 'test', 'provision').default('development'),
PORT: Joi.number().default(3000),
REDIS_URL: Joi.string().required().error(new Error(`REDIS_URL is required.`)),
SESSION_SECRET: Joi.string().required(),
// Solana endpoints
SOLANA_CUSTOM_ENDPOINT: Joi.string(),
SOLANA_DEVNET_ENDPOINT: Joi.string(),
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
"dotenv": "^16.3.1",
"express": "^4.18.2",
"express-serve-static-core": "^0.1.1",
"express-session": "^1.17.3",
"fast-equals": "^5.0.1",
"graphql": "^16.8.1",
"graphql-codegen-typescript-validation-schema": "^0.12.1",
Expand Down
87 changes: 24 additions & 63 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7d93d1e

Please sign in to comment.