Skip to content

Commit 6eda183

Browse files
Added contributing guide, new environment variable and env example file
1 parent 09b1465 commit 6eda183

File tree

5 files changed

+122
-8
lines changed

5 files changed

+122
-8
lines changed

.env.example

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
AUTH_SECRET="" # A random string
2+
AUTH_URL="" # Should be http://localhost:3000 for local development
3+
AUTH_GITHUB_ID=""
4+
AUTH_GITHUB_SECRET=""
5+
XATA_API_KEY=""
6+
XATA_BRANCH="" # Default should be "main"
7+
8+
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="" # Optional
9+
NEXT_PUBLIC_ANALYTICS_WEBSITE_ID="" # Optional

CONTRIBUTING.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Contributing to Hacktoberfest Projects Finder
2+
3+
Thank you for your interest in contributing to the Hacktoberfest Projects Finder! We welcome contributions from everyone. This document will guide you through the process of setting up the project locally and creating a GitHub OAuth application.
4+
5+
## Setting Up the Project
6+
7+
1. Fork the repository on GitHub.
8+
2. Clone your forked repository:
9+
```sh
10+
git clone https://github.com/your-username/hacktoberfest-projects.git
11+
```
12+
3. Navigate to the project directory:
13+
```sh
14+
cd hacktoberfest-projects
15+
```
16+
4. Install dependencies (we recommend using `pnpm`):
17+
```sh
18+
pnpm install
19+
```
20+
5. Copy the `.env.example` file to `.env.local` and fill in the required environment variables.
21+
22+
## Creating a GitHub OAuth Application
23+
24+
To use GitHub authentication in the project, you need to create a GitHub OAuth application. Follow these steps:
25+
26+
1. Go to your GitHub account settings.
27+
2. Navigate to "Developer settings" > "OAuth Apps".
28+
3. Click on "New OAuth App".
29+
4. Fill in the application details:
30+
- Application name: "Hacktoberfest Projects Finder" (or your preferred name)
31+
- Homepage URL: `http://localhost:3000` (for local development)
32+
- Authorization callback URL: `http://localhost:3000/api/auth/callback/github`
33+
5. Click "Register application".
34+
6. On the next page, you'll see your Client ID. Click "Generate a new client secret" to create your Client Secret.
35+
7. Copy the Client ID and Client Secret to your `.env.local` file.
36+
37+
## Setting Up Xata
38+
39+
Xata is used as the database for this project. Follow these steps to set it up:
40+
41+
1. Sign up for a Xata account at https://xata.io/
42+
2. Install the Xata CLI globally:
43+
```sh
44+
npm install -g "@xata.io/cli@latest"
45+
```
46+
3. Authenticate with Xata:
47+
```sh
48+
xata auth login
49+
```
50+
4. Update the database settings in `xata.ts` and `.xatarc` files (do not commit these changes).
51+
5. Run the migration:
52+
```sh
53+
xata push main
54+
```
55+
56+
## Environment Variables
57+
58+
Create a `.env.local` file in the root of the project and add the following variables:
59+
```sh
60+
AUTH_SECRET="" # A random string
61+
AUTH_URL="" # Should be http://localhost:3000 for local development
62+
AUTH_GITHUB_ID=""
63+
AUTH_GITHUB_SECRET=""
64+
XATA_API_KEY=""
65+
XATA_BRANCH="" # Default should be "main"
66+
67+
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="" # Optional
68+
NEXT_PUBLIC_ANALYTICS_WEBSITE_ID="" # Optional
69+
```
70+
71+
Make sure to fill in the required values for each variable. The `AUTH_SECRET` should be a random string, and `AUTH_URL` should be set to `http://localhost:3000` for local development. The `XATA_BRANCH` should typically be set to "main" unless you're using a different branch. Remember that the `NEXT_PUBLIC_` variables are optional.
72+
73+
## Running the Project
74+
75+
After setting up the environment variables, you can start the development server:
76+
```sh
77+
pnpm dev
78+
```
79+
80+
The application should now be running at `http://localhost:3000`.
81+
82+
## Making Contributions
83+
84+
1. Create a new branch for your feature or bug fix:
85+
```sh
86+
git checkout -b feature/your-feature-name
87+
```
88+
2. Make your changes and commit them with a descriptive commit message.
89+
3. Push your changes to your fork:
90+
```sh
91+
git push origin feature/your-feature-name
92+
```
93+
4. Create a pull request from your fork to the main repository.
94+
95+
Please ensure your code follows the project's coding standards and includes appropriate tests if applicable.
96+
97+
## Questions or Issues
98+
99+
If you have any questions or run into issues, please open an issue in the GitHub repository. We're here to help!
100+
101+
Thank you for contributing to the Hacktoberfest Projects Finder!

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use it here - https://finder.usmans.me
1515

1616
## Contributing
1717

18-
Contributions are always welcome!
18+
We welcome contributions from everyone! If you're interested in helping improve the Hacktoberfest Projects Finder, please take a look at our [CONTRIBUTING.md](CONTRIBUTING.md) file. It contains detailed information on how to set up the project locally, create a GitHub OAuth application, set up the Xata database, and submit your contributions.
1919

2020
> Pull Requests about adding languages will not be merged, if you want to suggest adding a new language, please [create an issue](https://github.com/max-programming/hacktoberfest-projects/issues/new) for that 🙂
2121

src/app/layout.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Toaster } from 'react-hot-toast';
66
import { SessionProvider } from 'next-auth/react';
77
import { Footer } from '@/components/footer';
88
import { ReportModal } from '@/components/report-modal';
9+
import { env } from '@/env.mjs';
910

1011
const spaceGrotesk = Space_Grotesk({
1112
subsets: ['latin'],
@@ -24,10 +25,10 @@ export default function RootLayout({ children }: React.PropsWithChildren) {
2425
<ReportModal />
2526
</SessionProvider>
2627
<Toaster position="bottom-right" />
27-
{process.env.NEXT_PUBLIC_ANALYTICS_WEBSITE_ID && (
28+
{env.NEXT_PUBLIC_ANALYTICS_WEBSITE_ID && (
2829
<Script
2930
src="https://cloud.umami.is/script.js"
30-
data-website-id={process.env.NEXT_PUBLIC_ANALYTICS_WEBSITE_ID}
31+
data-website-id={env.NEXT_PUBLIC_ANALYTICS_WEBSITE_ID}
3132
strategy="lazyOnload"
3233
/>
3334
)}

src/env.mjs

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ export const env = createEnv({
66
AUTH_GITHUB_SECRET: z.string().min(1, 'AUTH_GITHUB_SECRET is required'),
77
AUTH_GITHUB_ID: z.string().min(1, 'AUTH_GITHUB_ID is required'),
88
AUTH_SECRET: z.string().min(1, 'AUTH_SECRET is required'),
9-
AUTH_GITHUB_TOKEN: z.string().optional(),
10-
XATA_BRANCH: z.string().optional(),
11-
XATA_API_KEY: z.string().optional()
9+
XATA_BRANCH: z.string().min(1, 'XATA_BRANCH is required'),
10+
XATA_API_KEY: z.string().min(1, 'XATA_API_KEY is required'),
11+
AUTH_GITHUB_TOKEN: z.string().optional()
1212
},
1313
client: {
14-
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME: z.string().optional()
14+
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME: z.string().optional(),
15+
NEXT_PUBLIC_ANALYTICS_WEBSITE_ID: z.string().uuid().optional()
1516
},
1617
experimental__runtimeEnv: {
1718
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME:
18-
process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
19+
process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME,
20+
NEXT_PUBLIC_ANALYTICS_WEBSITE_ID:
21+
process.env.NEXT_PUBLIC_ANALYTICS_WEBSITE_ID
1922
}
2023
});

0 commit comments

Comments
 (0)