Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into chore/enable-seed-editing
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/server.ts
  • Loading branch information
coolchock committed Nov 26, 2024
2 parents b5aa0e7 + 81d3ce4 commit 3b3adc3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
13 changes: 5 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# APOLLO_API_KEY=
# POSTGRES_USER=myuser
# POSTGRES_PASSWORD=mypassword
# POSTGRES_DB=instant_mock_db
# POSTGRES_HOST=postgres_db
# POSTGRES_PORT=5432
# BACKEND_PORT=3008
# FRONTEND_DEV_SERVER_PORT=3009
# GITHUB_CLIENT_ID=
# GITHUB_CLIENT_SECRET=
# AZURE_CLIENT_ID=
# AZURE_CLIENT_SECRET=

4 changes: 2 additions & 2 deletions backend/package-lock.json

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

26 changes: 13 additions & 13 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
import './loadEnv';
import 'reflect-metadata';
import {
EntityManager,
EntityRepository,
MikroORM,
RequestContext,
} from '@mikro-orm/core';
import {EntityManager, EntityRepository, MikroORM, RequestContext,} from '@mikro-orm/core';
import cors from 'cors';
import express from 'express';
import figlet from 'figlet';
import fs from 'fs';
import path from 'path';
import supertokens from 'supertokens-node';
import swaggerJsdoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import * as Undici from 'undici';
import {SuperTokensConfig} from './config/supertokens';
import figlet from 'figlet';
import {getWebsiteDomain, SuperTokensConfig} from './config/supertokens';
import Client from './graphql/client';
import {authMiddleware} from './middleware/auth';
import {ApolloApiKey} from './models/apolloApiKey';
import {Seed} from './models/seed';
import {SeedGroup} from './models/seedGroup';
import apolloApiKeysRoutes from './routes/apolloApiKey';
import authRoutes from './routes/auth';
import avatarRoutes from './routes/avatar';
import authRoutes from './routes/auth';
import graphqlRoutes from './routes/graphql';
import graphsRoutes from './routes/graphs';
import proposalsRoutes from './routes/proposals';
import seedGroupsRoutes from './routes/seedGroups';
import seedsRoutes from './routes/seeds';
import {logger} from './utilities/logger';
import fs from 'fs';

const isTypescript = __filename.endsWith('.ts');
const ProxyAgent = Undici.ProxyAgent;
Expand Down Expand Up @@ -85,7 +80,7 @@ const initializeApp = async () => {
const mikroOrmConfig = {
...(await import(
`./mikro-orm.${process.env.MIKRO_ORM_DRIVER || 'sqlite'}${isTypescript ? '.ts' : '.js'}`
).then((module) => module.default)),
).then((module) => module.default)),
};

DI.orm = await MikroORM.init(mikroOrmConfig);
Expand Down Expand Up @@ -120,13 +115,18 @@ const initializeApp = async () => {
app.use(express.urlencoded({limit: '50mb', extended: true}));
app.use(
cors({
// origin: [getWebsiteDomain()],
origin: (origin, callback) => {
const allowedOrigins = [getWebsiteDomain()];
const regex = /^(https:\/\/[a-zA-Z0-9-]+\.narrative\.tech|https?:\/\/localhost(:\d+)?)$/;
if (!origin || allowedOrigins.includes(origin) || regex.test(origin)) callback(null, true);
else callback(new Error('Not allowed by CORS'));
},
allowedHeaders: [
'content-type',
...supertokens.getAllCORSHeaders(),
'seed-group',
],
methods: ['GET', 'PUT', 'POST', 'DELETE', 'PATCH'],
methods: ['GET', 'PUT', 'POST', 'DELETE'],
credentials: true,
})
);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

0 comments on commit 3b3adc3

Please sign in to comment.