Skip to content

Commit

Permalink
feat: Terms
Browse files Browse the repository at this point in the history
  • Loading branch information
mathhulk committed Jun 24, 2024
1 parent 7e730ef commit e9686ba
Show file tree
Hide file tree
Showing 20 changed files with 6,405 additions and 4,179 deletions.
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.14.2-slim AS builder
FROM node:slim AS builder
RUN mkdir /backend
WORKDIR /backend
COPY package.json .
Expand Down
9,200 changes: 5,566 additions & 3,634 deletions backend/package-lock.json

Large diffs are not rendered by default.

85 changes: 38 additions & 47 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"name": "ts-graphql-starter",
"version": "1.0.0",
"description": "A GraphQL API starter using NodeJS, TypeScript and Apollo Server",
"main": "index.js",
"name": "backend",
"main": "src/main.ts",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only ./src/index.ts",
"build": "rimraf ./build && tsc",
"start": "npm run build && node ./build/index.js",
"start": "tsx src/main.ts",
"dev": "tsx watch src/main.ts",
"build": "tsc --noEmit",
"test": "jest --watch",
"coverage": "jest --coverage",
"generate": "graphql-codegen --config codegen.ts",
Expand All @@ -25,53 +23,46 @@
},
"homepage": "https://github.com/Rieranthony/ts-graphql-starter#readme",
"devDependencies": {
"@babel/eslint-parser": "^7.22.15",
"@graphql-codegen/cli": "2.13.7",
"@graphql-codegen/graphql-modules-preset": "^2.5.3",
"@graphql-codegen/introspection": "2.2.1",
"@graphql-codegen/typescript": "^2.7.4",
"@graphql-codegen/typescript-resolvers": "^2.7.4",
"@types/cors": "^2.8.12",
"@types/express-session": "^1.17.6",
"@types/helmet": "0.0.46",
"@types/jest": "^25.2.1",
"@types/lodash": "^4.14.186",
"@types/node": "^13.13.5",
"@types/passport-google-oauth20": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"eslint": "^8.26.0",
"eslint-plugin-unused-imports": "^2.0.0",
"jest": "^29.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.1",
"ts-node-dev": "^1.1.8",
"typescript": "^5.2.2"
"@babel/eslint-parser": "^7.24.7",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/graphql-modules-preset": "^4.0.7",
"@graphql-codegen/introspection": "4.0.3",
"@graphql-codegen/typescript": "^4.0.7",
"@graphql-codegen/typescript-resolvers": "^4.1.0",
"@types/cors": "^2.8.17",
"@types/express-session": "^1.18.0",
"@types/helmet": "0.0.48",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.5",
"@types/node": "^20.14.8",
"@types/passport-google-oauth20": "^2.0.16",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.5",
"typescript": "^5.5.2"
},
"dependencies": {
"@apollo/server": "^4.1.0",
"@apollo/server": "^4.10.4",
"@apollo/server-plugin-response-cache": "^4.1.3",
"@graphql-tools/schema": "^10.0.0",
"@graphql-tools/utils": "^10.0.7",
"axios": "^1.5.1",
"@graphql-tools/schema": "^10.0.4",
"@graphql-tools/utils": "^10.2.2",
"connect-redis": "^7.1.1",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.18.2",
"express-session": "^1.17.3",
"graphql": "^16.6.0",
"graphql-modules": "^2.1.0",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-session": "^1.18.0",
"graphql": "^16.9.0",
"graphql-modules": "^2.3.0",
"graphql-type-json": "^0.3.2",
"helmet": "^3.22.0",
"helmet": "^7.1.0",
"lodash": "^4.17.21",
"mongodb": "^6.2.0",
"mongoose": "^7.6.3",
"passport": "^0.6.0",
"mongodb": "^6.7.0",
"mongoose": "^8.4.3",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0",
"redis": "^4.6.13",
"reflect-metadata": "^0.1.13"
},
"overrides": {
"oauth": "^0.10.0"
"redis": "^4.6.14",
"tsx": "^4.15.7"
}
}
13 changes: 9 additions & 4 deletions backend/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import http from "http";

export default async (config: Config) => {
const app = express();
app.set('trust proxy', 1);
app.set("trust proxy", 1);

await loaders(app);

const httpServer = http.createServer(app);

await httpServer.listen(config.port)
httpServer.listen(config.port);

console.log(`🚀\tServer ready (in Docker network) at:\thttp://localhost:${config.port}${config.backendPath}`);
console.log(`\tServer ready (in Host network) at:\thttp://localhost:8080${config.backendPath}`)
console.log(
`🚀\tServer ready (in Docker network) at:\thttp://localhost:${config.port}${config.backendPath}`
);

console.log(
`\tServer ready (in Host network) at:\thttp://localhost:8080${config.backendPath}`
);
};
27 changes: 25 additions & 2 deletions backend/src/bootstrap/loaders/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { RedisClientType } from "redis";
import passportLoader from "./passport";
import { config } from "../../config";

export default async (app: Application, server: ApolloServer, redis: RedisClientType) => {
export default async (
app: Application,
server: ApolloServer,
redis: RedisClientType
) => {
// Body parser only needed during POST on the graphQL path
app.use(json());

Expand All @@ -22,7 +26,26 @@ export default async (app: Application, server: ApolloServer, redis: RedisClient
);

// Sets various HTTP headers to help protect our app
app.use(helmet());
app.use(
helmet({
crossOriginEmbedderPolicy: false,
contentSecurityPolicy: {
directives: {
imgSrc: [
`'self'`,
"data:",
"apollo-server-landing-page.cdn.apollographql.com",
],
scriptSrc: [`'self'`, `https: 'unsafe-inline'`],
manifestSrc: [
`'self'`,
"apollo-server-landing-page.cdn.apollographql.com",
],
frameSrc: [`'self'`, "sandbox.embed.apollographql.com"],
},
},
})
);

// load authentication
passportLoader(app, redis);
Expand Down
Loading

0 comments on commit e9686ba

Please sign in to comment.