-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added global config files to setup the core project structure
- Loading branch information
Showing
17 changed files
with
4,605 additions
and
3,684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lib | ||
node_modules | ||
.next | ||
.firebase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"projects": { | ||
"default": "next-firebase-mui-starter", | ||
"prod": "next-firebase-mui-starter", | ||
"test": "next-firebase-mui-starter-test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"firestore": { | ||
"rules": "firebase/firestore.rules", | ||
"indexes": "firebase/firestore.indexes.json" | ||
}, | ||
"hosting": { | ||
"public": ".next", | ||
"ignore": [ | ||
"firebase.json", | ||
"**/.*", | ||
"**/node_modules/**" | ||
], | ||
"rewrites": [ | ||
{ | ||
"source": "**", | ||
"destination": "/index.html" | ||
} | ||
] | ||
}, | ||
"storage": { | ||
"rules": "firebase/storage.rules" | ||
}, | ||
"functions": { | ||
"predeploy": [ | ||
"yarn --cwd \"$RESOURCE_DIR\" lint", | ||
"yarn --cwd \"$RESOURCE_DIR\" build" | ||
], | ||
"source": "functions", | ||
"ignore": [ | ||
"node_modules", | ||
"test", | ||
"generators", | ||
".git", | ||
".react-email", | ||
"firebase-debug.log", | ||
"firebase-debug.*.log" | ||
] | ||
}, | ||
"emulators": { | ||
"auth": { | ||
"port": 9099 | ||
}, | ||
"functions": { | ||
"port": 5001 | ||
}, | ||
"firestore": { | ||
"port": 8080 | ||
}, | ||
"hosting": { | ||
"port": 5000 | ||
}, | ||
"storage": { | ||
"port": 9199 | ||
}, | ||
"ui": { | ||
"enabled": true | ||
}, | ||
"pubsub": { | ||
"port": 8087 | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "models", | ||
"description": "shared models for the whole project", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"declarationMap": true, | ||
"composite": true, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": ["lib/**/*"], | ||
"scripts": { | ||
"lint": "eslint --ext .js,.ts ", | ||
"build": "tsc", | ||
"prepublishOnly": "tsc" | ||
}, | ||
"exports": { | ||
".": "./lib/", | ||
"./users": "./lib/users.js" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5", | ||
"@typescript-eslint/parser": "^6", | ||
"eslint": "^8", | ||
"eslint-plugin-import": "^2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"module": "CommonJS", | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"outDir": "lib", | ||
"sourceMap": true, | ||
"allowJs": false, | ||
"declaration": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
}, | ||
"compileOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface UserInfo { | ||
id: string; | ||
imageUrl?: string; | ||
displayName?: string; | ||
} | ||
|
||
export interface UserPreferences { | ||
unsubscribeWeeklyProgress?: boolean; | ||
unsubscribeAnnouncements?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import {NextRequest, NextResponse} from 'next/server'; | ||
import {authentication} from "next-firebase-auth-edge/lib/next/middleware"; | ||
|
||
|
||
const commonOptions = { | ||
loginPath: '/api/login', | ||
logoutPath: '/api/logout', | ||
apiKey: process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY!, | ||
cookieName: 'ProfoundAcademyAuth', | ||
cookieSignatureKeys: [process.env.COOKIE_SECRET_CURRENT!, process.env.COOKIE_SECRET_PREVIOUS!], | ||
cookieSerializeOptions: { | ||
path: '/', | ||
httpOnly: true, | ||
secure: process.env.NEXT_PUBLIC_COOKIE_SECURE === 'true', // Set this to true on HTTPS environments | ||
sameSite: 'lax' as const, // https://github.com/vercel/next.js/discussions/41745#discussioncomment-5408993 | ||
maxAge: 12 * 60 * 60 * 24, // twelve days | ||
}, | ||
serviceAccount: { | ||
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID!, | ||
clientEmail: process.env.PRIVATE_FIREBASE_CLIENT_EMAIL!, | ||
// Using JSON to handle newline problems when storing the key as a secret in Vercel | ||
// https://github.com/vercel/vercel/issues/749#issuecomment-707515089 | ||
privateKey: JSON.parse(process.env.PRIVATE_FIREBASE_PRIVATE_KEY!), | ||
}, | ||
}; | ||
|
||
|
||
export async function middleware(request: NextRequest) { | ||
const pathname = request.nextUrl.pathname; | ||
|
||
// `/_next/` and `public/demo/*` are ignored by the watcher, but we need to ignore other files in `public` manually | ||
if ([ | ||
'/manifest.json', | ||
'/robots.txt', | ||
'/sitemap.xml', | ||
'/logo192.png', | ||
'/logo512.png', | ||
'/logo.svg', | ||
].includes(pathname)) | ||
return; | ||
console.log('pathname:', pathname); | ||
|
||
// Handle authentication | ||
if ([commonOptions.loginPath, commonOptions.logoutPath].includes(pathname)) { | ||
console.log('handling auth:', pathname); | ||
return authentication(request, { | ||
...commonOptions, | ||
handleValidToken: async ({ token, decodedToken }) => { | ||
console.log('Successfully authenticated', { token, decodedToken }); | ||
return NextResponse.next(); | ||
}, | ||
handleInvalidToken: async () => { | ||
console.log('Not authenticated or token expired'); | ||
return NextResponse.next(); | ||
}, | ||
handleError: async (error) => { | ||
console.error('Oops, this should not have happened.', { error }); | ||
return NextResponse.next(); | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export const config = { | ||
matcher: [ | ||
// Skip all internal paths (_next, _vercel, assets, etc.) | ||
'/((?!_next/static|_next/image|_vercel/insights|monitoring|demo|assets|favicon.ico).*)', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,46 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
const {withSentryConfig} = require('@sentry/nextjs'); | ||
|
||
module.exports = nextConfig | ||
module.exports = withSentryConfig({ | ||
reactStrictMode: true, | ||
experimental: { | ||
serverActions: true, | ||
}, | ||
webpack(config) { | ||
config.module.rules.push({ | ||
test: /\.svg$/, | ||
use: ["@svgr/webpack"] | ||
}); | ||
|
||
return config; | ||
}, | ||
}, | ||
|
||
// Injected content via Sentry wizard below | ||
{ | ||
// For all available options, see: | ||
// https://github.com/getsentry/sentry-webpack-plugin#options | ||
|
||
// Suppresses source map uploading logs during build | ||
silent: true, | ||
org: process.env.NEXT_PUBLIC_SENTRY_ORG, | ||
project: process.env.NEXT_PUBLIC_SENTRY_PROJECT, | ||
}, | ||
{ | ||
// For all available options, see: | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ | ||
|
||
// Upload a larger set of source maps for prettier stack traces (increases build time) | ||
widenClientFileUpload: true, | ||
|
||
// Transpiles SDK to be compatible with IE11 (increases bundle size) | ||
transpileClientSDK: true, | ||
|
||
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) | ||
tunnelRoute: '/monitoring', | ||
|
||
// Hides source maps from generated client bundles | ||
hideSourceMaps: true, | ||
|
||
// Automatically tree-shake Sentry logger statements to reduce bundle size | ||
disableLogger: true, | ||
}); |
Oops, something went wrong.