Skip to content

Commit 17cbc84

Browse files
committed
feat: added all tools required
0 parents  commit 17cbc84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6269
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DATABASE_URL=
2+
NEXTAUTH_SECRET=
3+
NEXTAUTH_URL=

.eslintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": ["next", "next/core-web-vitals", "eslint:recommended"],
3+
"rules": {
4+
"no-unused-vars": [1, { "args": "after-used", "argsIgnorePattern": "^_" }]
5+
}
6+
}

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
.env
31+
32+
# vercel
33+
.vercel
34+
35+
# typescript
36+
*.tsbuildinfo
37+
next-env.d.ts

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit "$1"

.husky/pre-commit

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "Running pre-commit hook...🍺"
5+
6+
npx lint-staged
7+
echo "ESLint & Prettier check completed successfully. ✅ "
8+
9+
yarn test || (
10+
echo "Test failed. ❌ "
11+
exit 1
12+
)
13+
echo "Test completed successfully. ✅ "
14+
15+
yarn build || (
16+
echo "Build failed. ❌ "
17+
exit 1
18+
)
19+
echo "Build completed successfully. ✅ "

.husky/pre-push

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn build

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.next
2+
node_modules
3+
dist
4+
.yarn

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"tabWidth": 2,
4+
"printWidth": 100,
5+
"singleQuote": false,
6+
"trailingComma": "all"
7+
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true,
4+
"editor.defaultFormatter": "esbenp.prettier-vscode",
5+
"editor.formatOnSave": true,
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll": true,
8+
"source.organizeImports": true
9+
}
10+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# MLSA, KIIT Chapter

commitlint.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
2+
// ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
3+
// docs: Documentation only changes
4+
// feat: A new feature
5+
// fix: A bug fix
6+
// perf: A code change that improves performance
7+
// refactor: A code change that neither fixes a bug nor adds a feature
8+
// style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
9+
// test: Adding missing tests or correcting existing tests
10+
11+
module.exports = {
12+
extends: ["@commitlint/config-conventional"],
13+
rules: {
14+
"body-leading-blank": [1, "always"],
15+
"body-max-line-length": [2, "always", 100],
16+
"footer-leading-blank": [1, "always"],
17+
"footer-max-line-length": [2, "always", 100],
18+
"header-max-length": [2, "always", 100],
19+
"scope-case": [2, "always", "lower-case"],
20+
"subject-case": [2, "never", ["sentence-case", "start-case", "pascal-case", "upper-case"]],
21+
"subject-empty": [2, "never"],
22+
"subject-full-stop": [2, "never", "."],
23+
"type-case": [2, "always", "lower-case"],
24+
"type-empty": [2, "never"],
25+
"type-enum": [
26+
2,
27+
"always",
28+
[
29+
"build",
30+
"chore",
31+
"ci",
32+
"docs",
33+
"feat",
34+
"fix",
35+
"perf",
36+
"refactor",
37+
"revert",
38+
"style",
39+
"test",
40+
"translation",
41+
"security",
42+
"changeset",
43+
],
44+
],
45+
},
46+
};

next.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// @ts-check
2+
/**
3+
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
4+
* This is especially useful for Docker builds.
5+
*/
6+
!process.env.SKIP_ENV_VALIDATION && (await import("./src/env/server.mjs"));
7+
8+
/** @type {import("next").NextConfig} */
9+
const config = {
10+
experimental: {
11+
appDir: true,
12+
},
13+
reactStrictMode: true,
14+
swcMinify: true,
15+
images: {
16+
domains: ["avatars.githubusercontent.com"],
17+
},
18+
};
19+
20+
export default config;

package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "mlsa-kiit",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint",
10+
"lint:fix": "next lint --fix",
11+
"format": "prettier --write .",
12+
"prepare": "husky install",
13+
"test": "echo test",
14+
"postinstall": "prisma generate",
15+
"db:seed": "prisma db seed",
16+
"db:studio": "prisma studio",
17+
"db:generate": "prisma generate",
18+
"db:push": "prisma db push",
19+
"db:docs": "prisma:generate && cd prisma/docs && serve -l 8421",
20+
"db:migrate": "prisma migrate deploy",
21+
"db:migrate-dev": "prisma migrate dev"
22+
},
23+
"dependencies": {
24+
"@next-auth/prisma-adapter": "^1.0.5",
25+
"@prisma/client": "^4.12.0",
26+
"@tanstack/react-query": "^4.29.1",
27+
"lodash": "^4.17.21",
28+
"next": "13.2.4",
29+
"next-auth": "^4.22.0",
30+
"react": "18.2.0",
31+
"react-dom": "18.2.0",
32+
"zod": "^3.21.4"
33+
},
34+
"devDependencies": {
35+
"@commitlint/cli": "^17.5.1",
36+
"@commitlint/config-conventional": "^17.4.4",
37+
"@types/lodash": "^4.14.192",
38+
"@types/node": "^18.15.11",
39+
"@types/react": "^18.0.34",
40+
"@types/react-dom": "^18.0.11",
41+
"autoprefixer": "^10.4.14",
42+
"eslint": "^8.38.0",
43+
"eslint-config-next": "^13.3.0",
44+
"husky": "^8.0.3",
45+
"lint-staged": "^13.2.1",
46+
"postcss": "^8.4.21",
47+
"prettier": "^2.8.7",
48+
"prisma": "^4.12.0",
49+
"prisma-dbml-generator": "^0.10.0",
50+
"prisma-docs-generator": "^0.7.0",
51+
"serve": "^14.2.0",
52+
"tailwindcss": "^3.3.1",
53+
"ts-node": "^10.9.1",
54+
"typescript": "^5.0.4"
55+
},
56+
"prisma": {
57+
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed/index.ts"
58+
},
59+
"lint-staged": {
60+
"**/*.{ts,js}": "next lint --fix",
61+
"**/*.{ts,js,md,json}": "prettier --write ."
62+
}
63+
}

postcss.config.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

prisma/schema.prisma

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
}
4+
5+
generator docs {
6+
provider = "node node_modules/prisma-docs-generator"
7+
}
8+
9+
generator dbml {
10+
provider = "prisma-dbml-generator"
11+
}
12+
13+
datasource db {
14+
provider = "postgres"
15+
url = env("DATABASE_URL")
16+
}
17+
18+
model User {
19+
id String @id @default(cuid())
20+
name String @unique
21+
}
22+
23+
// model EventRegistration {
24+
// id String @id @default(auto()) @map("_id") @db.ObjectId
25+
// eventId String
26+
// name String
27+
// roll Int @unique
28+
// currentYear Int
29+
// Branch String
30+
// kiitEmail String @unique
31+
// personalEmail String @unique
32+
// phoneNumber String @unique
33+
// linkedin String @unique
34+
// Github String @unique
35+
// expectationsFromEvent String
36+
// }

prisma/seed/index.ts

Whitespace-only changes.

public/mlsa-logo.png

14.4 KB
Loading

src/app/api/auth/[...nextauth].ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import NextAuth, { type NextAuthOptions } from "next-auth";
2+
import { PrismaAdapter } from "@next-auth/prisma-adapter";
3+
import { prisma } from "../../../server/db";
4+
import CredentialsProvider from "next-auth/providers/credentials";
5+
6+
export const authOptions: NextAuthOptions = {
7+
session: {
8+
strategy: "jwt",
9+
},
10+
adapter: PrismaAdapter(prisma),
11+
providers: [
12+
CredentialsProvider({
13+
type: "credentials",
14+
name: "Code Login",
15+
credentials: {
16+
code: { label: "Code", type: "text", placeholder: "Code" },
17+
},
18+
authorize: async (credentials) => {
19+
if (!credentials?.code) {
20+
return null;
21+
}
22+
23+
const user = null;
24+
// const user = await prisma.user.findUnique({
25+
// where: {
26+
// code: credentials.code,
27+
// },
28+
// });
29+
30+
if (!user) {
31+
return null;
32+
}
33+
34+
return user;
35+
},
36+
}),
37+
],
38+
pages: {
39+
signIn: "/",
40+
},
41+
};
42+
43+
export default NextAuth(authOptions);

src/app/api/hello/route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// import { prisma } from "@/server/db";
2+
3+
export const GET = async (_req: Request) => {
4+
// await prisma.$connect();
5+
// await prisma.$disconnect();
6+
return new Response("Hello world!");
7+
};

src/app/api/save-answers.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Example of a restricted endpoint that only authenticated users can access from https://next-auth.js.org/getting-started/example
2+
3+
import { NextApiRequest, NextApiResponse } from "next";
4+
import { getServerAuthSession } from "../../server/auth";
5+
6+
const saveAnswers = async (req: NextApiRequest, res: NextApiResponse) => {
7+
const session = await getServerAuthSession({ req, res });
8+
9+
if (session) {
10+
res.send({
11+
content: "This is protected content. You can access this content because you are signed in.",
12+
});
13+
} else {
14+
res.send({
15+
error: "You must be signed in to view the protected content on this page.",
16+
});
17+
}
18+
};
19+
20+
export default saveAnswers;

src/app/error.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use client";
2+
3+
import { useEffect } from "react";
4+
5+
export default function Error({ error, reset }: { error: Error; reset: () => void }) {
6+
// TODO: Have to test it. No idea if it is working or not.
7+
useEffect(() => {
8+
console.error(error);
9+
}, [error]);
10+
11+
return (
12+
<div>
13+
<h2>Something went wrong!</h2>
14+
<button onClick={reset}>Try again</button>
15+
</div>
16+
);
17+
}

src/app/events/[eventID]/layout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ILayoutProps } from "@/types";
2+
import EventRegistrationNavbar from "@/components/EventRegistrationNavbar";
3+
4+
export default function EventLayout({ children }: ILayoutProps) {
5+
return (
6+
<div className="">
7+
<EventRegistrationNavbar />
8+
{children}
9+
</div>
10+
);
11+
}

0 commit comments

Comments
 (0)