Compare commits
1 Commits
feat/serve
...
feature/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e20904e896 |
@@ -46,6 +46,7 @@
|
|||||||
"graphql-query-complexity": "^0.12.0",
|
"graphql-query-complexity": "^0.12.0",
|
||||||
"graphql-redis-subscriptions": "^2.6.0",
|
"graphql-redis-subscriptions": "^2.6.0",
|
||||||
"graphql-subscriptions": "^2.0.0",
|
"graphql-subscriptions": "^2.0.0",
|
||||||
|
"graphql-ws": "^5.14.2",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"io-ts": "^2.2.16",
|
"io-ts": "^2.2.16",
|
||||||
"luxon": "^3.2.1",
|
"luxon": "^3.2.1",
|
||||||
@@ -66,7 +67,6 @@
|
|||||||
"@nestjs/schematics": "^10.0.2",
|
"@nestjs/schematics": "^10.0.2",
|
||||||
"@nestjs/testing": "^10.2.6",
|
"@nestjs/testing": "^10.2.6",
|
||||||
"@relmify/jest-fp-ts": "^2.0.2",
|
"@relmify/jest-fp-ts": "^2.0.2",
|
||||||
"@types/argon2": "^0.15.0",
|
|
||||||
"@types/bcrypt": "^5.0.0",
|
"@types/bcrypt": "^5.0.0",
|
||||||
"@types/cookie": "^0.5.1",
|
"@types/cookie": "^0.5.1",
|
||||||
"@types/cookie-parser": "^1.4.3",
|
"@types/cookie-parser": "^1.4.3",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ForbiddenException, HttpException, Module } from '@nestjs/common';
|
import { HttpException, Module } from '@nestjs/common';
|
||||||
import { GraphQLModule } from '@nestjs/graphql';
|
import { GraphQLModule } from '@nestjs/graphql';
|
||||||
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||||
import { UserModule } from './user/user.module';
|
import { UserModule } from './user/user.module';
|
||||||
@@ -20,28 +20,35 @@ import { ShortcodeModule } from './shortcode/shortcode.module';
|
|||||||
import { COOKIES_NOT_FOUND } from './errors';
|
import { COOKIES_NOT_FOUND } from './errors';
|
||||||
import { ThrottlerModule } from '@nestjs/throttler';
|
import { ThrottlerModule } from '@nestjs/throttler';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
|
import { Context } from 'graphql-ws';
|
||||||
|
import {
|
||||||
|
ApolloServerPluginLandingPageLocalDefault,
|
||||||
|
ApolloServerPluginLandingPageProductionDefault,
|
||||||
|
} from '@apollo/server/plugin/landingPage/default';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
GraphQLModule.forRoot<ApolloDriverConfig>({
|
GraphQLModule.forRoot<ApolloDriverConfig>({
|
||||||
|
driver: ApolloDriver,
|
||||||
buildSchemaOptions: {
|
buildSchemaOptions: {
|
||||||
numberScalarMode: 'integer',
|
numberScalarMode: 'integer',
|
||||||
},
|
},
|
||||||
playground: process.env.PRODUCTION !== 'true',
|
playground: false,
|
||||||
|
plugins: [
|
||||||
|
process.env.PRODUCTION !== 'true'
|
||||||
|
? ApolloServerPluginLandingPageLocalDefault()
|
||||||
|
: ApolloServerPluginLandingPageProductionDefault(),
|
||||||
|
],
|
||||||
autoSchemaFile: true,
|
autoSchemaFile: true,
|
||||||
installSubscriptionHandlers: true,
|
|
||||||
subscriptions: {
|
subscriptions: {
|
||||||
'subscriptions-transport-ws': {
|
'graphql-ws': {
|
||||||
path: '/graphql',
|
path: '/graphql',
|
||||||
onConnect: (_, websocket) => {
|
onConnect: (context: Context<any, any>) => {
|
||||||
try {
|
try {
|
||||||
const cookies = subscriptionContextCookieParser(
|
const cookies = subscriptionContextCookieParser(
|
||||||
websocket.upgradeReq.headers.cookie,
|
context.extra.request.headers.cookie,
|
||||||
);
|
);
|
||||||
|
context['cookies'] = cookies;
|
||||||
return {
|
|
||||||
headers: { ...websocket?.upgradeReq?.headers, cookies },
|
|
||||||
};
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(COOKIES_NOT_FOUND, 400, {
|
throw new HttpException(COOKIES_NOT_FOUND, 400, {
|
||||||
cause: new Error(COOKIES_NOT_FOUND),
|
cause: new Error(COOKIES_NOT_FOUND),
|
||||||
@@ -55,7 +62,6 @@ import { AppController } from './app.controller';
|
|||||||
res,
|
res,
|
||||||
connection,
|
connection,
|
||||||
}),
|
}),
|
||||||
driver: ApolloDriver,
|
|
||||||
}),
|
}),
|
||||||
ThrottlerModule.forRoot([
|
ThrottlerModule.forRoot([
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,13 +60,13 @@ export const authCookieHandler = (
|
|||||||
res.cookie(AuthTokenType.ACCESS_TOKEN, authTokens.access_token, {
|
res.cookie(AuthTokenType.ACCESS_TOKEN, authTokens.access_token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: true,
|
secure: true,
|
||||||
sameSite: 'lax',
|
sameSite: process.env.PRODUCTION !== 'true' ? 'none' : 'lax',
|
||||||
maxAge: accessTokenValidity,
|
maxAge: accessTokenValidity,
|
||||||
});
|
});
|
||||||
res.cookie(AuthTokenType.REFRESH_TOKEN, authTokens.refresh_token, {
|
res.cookie(AuthTokenType.REFRESH_TOKEN, authTokens.refresh_token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: true,
|
secure: true,
|
||||||
sameSite: 'lax',
|
sameSite: process.env.PRODUCTION !== 'true' ? 'none' : 'lax',
|
||||||
maxAge: refreshTokenValidity,
|
maxAge: refreshTokenValidity,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
7323
pnpm-lock.yaml
generated
7323
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user