generated from nimblehq/git-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2c3efa1
commit 4d014fd
Showing
38 changed files
with
13,925 additions
and
2,451 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 @@ | ||
DATABASE_URL="postgresql://postgres:@localhost:5432/next-newsletter_dev?schema=public" |
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,3 @@ | ||
COOKIE_SECRET= | ||
OAUTH_GOOGLE_CLIENT_ID= | ||
OAUTH_GOOGLE_CLIENT_SECRET= |
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,3 +1,12 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"@nimblehq/eslint-config-nimble", | ||
"@nimblehq/eslint-config-nimble-react" | ||
], | ||
|
||
"rules": { | ||
// suppress errors for missing 'import React' in files since Next.JS import React | ||
"react/react-in-jsx-scope": "off" | ||
} | ||
} |
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,7 @@ | ||
.PHONY: start, start_database | ||
|
||
start: start_database | ||
npm run dev | ||
|
||
start_database: | ||
docker-compose -f docker-compose.dev.yml up -d |
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,19 +1,34 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
NextNewsletter 🚀 is bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
### Prerequisites | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
- Ensure you have ![node-version-image](https://img.shields.io/badge/node-16.17.0-brightgreen.svg) version installed. | ||
- Define the local environment variables by copying `.env.sample`: | ||
|
||
``` | ||
cp .env.sample .env.local | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
💡Secrets can be generated via node CLI with `crypto.randomBytes(128).toString('base64')` . | ||
|
||
### Development | ||
|
||
1. Install all dependencies: | ||
|
||
```bash | ||
npm install | ||
# or | ||
yarn install | ||
``` | ||
|
||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. | ||
2. Run the development server: | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. | ||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
3. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
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,11 @@ | ||
version: "3.8" | ||
|
||
services: | ||
db: | ||
image: postgres:14.5 | ||
container_name: next-newsletter_db | ||
environment: | ||
- POSTGRES_HOST_AUTH_METHOD=trust | ||
- POSTGRES_DB=next-newsletter_dev | ||
ports: | ||
- "5432:5432" |
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 @@ | ||
// eslint-disable-next-line | ||
const nextJest = require('next/jest'); | ||
|
||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: './', | ||
}) | ||
|
||
// Add any custom config to be passed to Jest | ||
const customJestConfig = { | ||
// Add more setup options before each test is run | ||
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work | ||
moduleDirectories: ['node_modules', '<rootDir>/'], | ||
testEnvironment: 'jest-environment-jsdom', | ||
setupFilesAfterEnv: ['<rootDir>/test/database.ts'], | ||
collectCoverageFrom: [ | ||
'src/**/*.{js,jsx,ts,tsx}', | ||
'!src/config/*.{js,ts}', | ||
'!src/**/*.d.ts', | ||
'!src/tests/**/*' | ||
] | ||
}; | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
module.exports = createJestConfig(customJestConfig); |
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,15 @@ | ||
import { getIronSession } from 'iron-session/edge'; | ||
import type { NextRequest } from 'next/server'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { sessionOptions } from './src/config/session'; | ||
|
||
export const middleware = async (req: NextRequest) => { | ||
const res = NextResponse.next(); | ||
const session = await getIronSession(req, res, sessionOptions); | ||
const { user } = session; | ||
|
||
console.log('nextjs middleware', user); | ||
|
||
return res; | ||
}; |
Oops, something went wrong.