Skip to content

Commit fc0ef7f

Browse files
committed
feat(app): rewrite app logic with tRPC
1 parent ada2d07 commit fc0ef7f

37 files changed

+7001
-465
lines changed

grocery-list-mern/.commitlintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"]
3+
}

grocery-list-mern/.editorconfig

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

grocery-list-mern/.eslintrc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"plugins": ["prettier"],
3+
"extends": ["next", "next/core-web-vitals", "prettier"],
4+
"rules": {
5+
"prettier/prettier": "error",
6+
"camelcase": "off",
7+
"import/prefer-default-export": "off",
8+
"react/jsx-filename-extension": "off",
9+
"react/jsx-props-no-spreading": "off",
10+
"react/no-unused-prop-types": "off",
11+
"react/require-default-props": "off",
12+
"import/extensions": [
13+
"error",
14+
"ignorePackages",
15+
{
16+
"ts": "never",
17+
"tsx": "never",
18+
"js": "never",
19+
"jsx": "never"
20+
}
21+
],
22+
"quotes": "off",
23+
"jsx-a11y/anchor-is-valid": [
24+
"error",
25+
{
26+
"components": ["Link"],
27+
"specialLink": ["hrefLeft", "hrefRight"],
28+
"aspects": ["invalidHref", "preferButton"]
29+
}
30+
]
31+
},
32+
"overrides": [
33+
{
34+
"files": "**/*.+(ts|tsx)",
35+
"parser": "@typescript-eslint/parser",
36+
"plugins": ["@typescript-eslint/eslint-plugin"],
37+
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
38+
"rules": {
39+
"@typescript-eslint/explicit-function-return-type": "off",
40+
"@typescript-eslint/explicit-module-boundary-types": "off",
41+
"no-use-before-define": [0],
42+
"@typescript-eslint/no-use-before-define": [1],
43+
"@typescript-eslint/no-explicit-any": "off",
44+
"@typescript-eslint/no-var-requires": "off",
45+
"@typescript-eslint/quotes": [
46+
2,
47+
"backtick",
48+
{
49+
"avoidEscape": true
50+
}
51+
]
52+
}
53+
}
54+
]
55+
}

grocery-list-mern/.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

grocery-list-mern/.gitignore

100755100644
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
/.pnp
66
.pnp.js
77

8+
# JetBrains IDE files
9+
.idea/
10+
811
# testing
912
/coverage
1013

@@ -18,18 +21,19 @@
1821
# misc
1922
.DS_Store
2023
*.pem
24+
tsconfig.tsbuildinfo
2125

2226
# debug
2327
npm-debug.log*
2428
yarn-debug.log*
2529
yarn-error.log*
26-
.pnpm-debug.log*
2730

2831
# local env files
29-
.env*.local
32+
.env
33+
.env.local
34+
.env.development.local
35+
.env.test.local
36+
.env.production.local
3037

3138
# vercel
3239
.vercel
33-
34-
# typescript
35-
*.tsbuildinfo

grocery-list-mern/.husky/commit-msg

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

grocery-list-mern/.husky/common.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
command_exists () {
2+
command -v "$1" >/dev/null 2>&1
3+
}
4+
5+
# Workaround for Windows 10, Git Bash and Yarn
6+
if command_exists winpty && test -t 1; then
7+
exec < /dev/tty
8+
fi

grocery-list-mern/.husky/pre-commit

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

grocery-list-mern/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact = true

grocery-list-mern/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12.22

grocery-list-mern/.prettierrc

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

grocery-list-mern/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 João Pedro Schmitz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

grocery-list-mern/README.md

100755100644
Lines changed: 109 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,126 @@
1-
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).
1+
<p align="center">
2+
<img src="https://user-images.githubusercontent.com/26466516/141659551-d7ba5630-7200-46fe-863b-87818dae970a.png" alt="Next.js TypeScript Starter">
3+
</p>
24

3-
## Getting Started
5+
<br />
46

5-
First, run the development server:
7+
<div align="center"><strong>Non-opinionated TypeScript starter for Next.js</strong></div>
8+
<div align="center">Highly scalable foundation with the best DX. All the tools you need to build your next project.</div>
69

7-
```bash
8-
npm run dev
10+
<br />
11+
12+
<div align="center">
13+
<img src="https://img.shields.io/static/v1?label=PRs&message=welcome&style=flat-square&color=5e17eb&labelColor=000000" alt="PRs welcome!" />
14+
15+
<img alt="License" src="https://img.shields.io/github/license/jpedroschmitz/typescript-nextjs-starter?style=flat-square&color=5e17eb&labelColor=000000">
16+
17+
<a href="https://twitter.com/intent/follow?screen_name=jpedroschmitz">
18+
<img src="https://img.shields.io/twitter/follow/jpedroschmitz?style=flat-square&color=5e17eb&labelColor=000000" alt="Follow @jpedroschmitz" />
19+
</a>
20+
</div>
21+
22+
<div align="center">
23+
<sub>Created by <a href="https://twitter.com/jpedroschmitz">João Pedro</a> with the help of many <a href="https://github.com/jpedroschmitz/typescript-nextjs-starter/graphs/contributors">wonderful contributors</a>.</sub>
24+
</div>
25+
26+
<br />
27+
28+
## Features
29+
30+
- ⚡️ Next.js 12
31+
- ⚛️ React 18
32+
- ⛑ TypeScript
33+
- 📏 ESLint — To find and fix problems in your code
34+
- 💖 Prettier — Code Formatter for consistent style
35+
- 🐶 Husky — For running scripts before committing
36+
- 📄 Commitizen — To define a standard way of committing rules
37+
- 🚓 Commitlint — To make sure your commit messages follow the convention
38+
- 🖌 Renovate — To keep your dependencies up to date
39+
- 🚫 lint-staged — Run ESLint and Prettier against staged Git files
40+
- 👷 PR Workflow — Run Type Check & Linters on Pull Requests
41+
- ⚙️ EditorConfig - Consistent coding styles across editors and IDEs
42+
- 🗂 Path Mapping — Import components or images using the `@` prefix
43+
44+
## Quick Start
45+
46+
The best way to start with this template is using [Create Next App](https://nextjs.org/docs/api-reference/create-next-app).
47+
48+
```
49+
yarn create next-app -e https://github.com/jpedroschmitz/typescript-nextjs-starter
950
# or
51+
npx create-next-app -e https://github.com/jpedroschmitz/typescript-nextjs-starter
52+
```
53+
54+
### Development
55+
56+
To start the project locally, run:
57+
58+
```bash
1059
yarn dev
1160
```
1261

13-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
62+
Open `http://localhost:3000` with your browser to see the result.
63+
64+
## Testimonials
65+
66+
> [**“This starter is by far the best TypeScript starter for Next.js. Feature packed but un-opinionated at the same time!”**](https://github.com/jpedroschmitz/typescript-nextjs-starter/issues/87#issue-789642190)<br>
67+
> — Arafat Zahan
68+
69+
> [**“I can really recommend the Next.js Typescript Starter repo as a solid foundation for your future Next.js projects.”**](https://corfitz.medium.com/create-a-custom-create-next-project-command-2a6b35a1c8e6)<br>
70+
> — Corfitz
71+
72+
> [**“Brilliant work!”**](https://github.com/jpedroschmitz/typescript-nextjs-starter/issues/87#issuecomment-769314539)<br>
73+
> — Soham Dasgupta
74+
75+
## Showcase
76+
77+
List of websites that started off with Next.js TypeScript Starter:
1478

15-
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
79+
- [dowhile.io](https://dowhile.io)
80+
- [graphcms.com](https://graphcms.com)
81+
- [mobg.com.br](https://mobg.com.br)
82+
- [nextlevelweek.com](https://nextlevelweek.com)
83+
- [rocketseat.com.br](https://www.rocketseat.com.br)
1684

17-
[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`.
85+
## Documentation
1886

19-
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.
87+
### Requirements
2088

21-
## Learn More
89+
- Node.js >= 12.22.0
90+
- Yarn 1 (Classic)
2291

23-
To learn more about Next.js, take a look at the following resources:
92+
### Directory Structure
2493

25-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
94+
- [`.github`](.github) — GitHub configuration including the CI workflow.<br>
95+
- [`.husky`](.husky) — Husky configuration and hooks.<br>
96+
- [`public`](./public) — Static assets such as robots.txt, images, and favicon.<br>
97+
- [`src`](./src) — Application source code, including pages, components, styles.
98+
99+
### Scripts
100+
101+
- `yarn dev` — Starts the application in development mode at `http://localhost:3000`.
102+
- `yarn build` — Creates an optimized production build of your application.
103+
- `yarn start` — Starts the application in production mode.
104+
- `yarn type-check` — Validate code using TypeScript compiler.
105+
- `yarn lint` — Runs ESLint for all files in the `src` directory.
106+
- `yarn format` — Runs Prettier for all files in the `src` directory.
107+
- `yarn commit` — Run commitizen. Alternative to `git commit`.
108+
109+
### Path Mapping
110+
111+
TypeScript are pre-configured with custom path mappings. To import components or files, use the `@` prefix.
112+
113+
```tsx
114+
import { Button } from '@/components/Button';
115+
116+
// To import images or other files from the public folder
117+
import avatar from '@/public/avatar.png';
118+
```
27119

28-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
120+
### Switch to npm
29121

30-
## Deploy on Vercel
122+
This starter uses Yarn 1 (Classic) by default, but this choice is yours. If you'd like to switch to npm, delete the `yarn.lock` file, install the dependencies with `npm i`, change the CI workflow, and Husky Git hooks to use npm commands.
31123

32-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
124+
## License
33125

34-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
126+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for more information.

grocery-list-mern/next.config.js

100755100644
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/** @type {import('next').NextConfig} */
2-
const nextConfig = {
1+
module.exports = {
32
reactStrictMode: true,
4-
}
5-
6-
module.exports = nextConfig
3+
};

grocery-list-mern/package.json

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,70 @@
11
{
2-
"name": "grocery-list-mern",
3-
"version": "0.1.0",
2+
"name": "typescript-nextjs-starter",
3+
"description": "A TypeScript starter for Next.js that includes all you need to build amazing projects",
4+
"version": "1.0.0",
45
"private": true,
6+
"author": "João Pedro Schmitz <hey@joaopedro.dev> (@jpedroschmitz)",
7+
"license": "MIT",
8+
"keywords": [
9+
"nextjs",
10+
"starter",
11+
"typescript"
12+
],
513
"scripts": {
6-
"dev": "next dev",
14+
"dev": "next",
715
"build": "next build",
816
"start": "next start",
9-
"lint": "next lint"
17+
"type-check": "tsc",
18+
"lint": "eslint --ignore-path .gitignore \"src/**/*.+(ts|js|tsx)\"",
19+
"format": "prettier --ignore-path .gitignore \"src/**/*.+(ts|js|tsx)\" --write",
20+
"commit": "cz"
21+
},
22+
"lint-staged": {
23+
"./src/**/*.{ts,js,jsx,tsx}": [
24+
"eslint --ignore-path .gitignore --fix",
25+
"prettier --ignore-path .gitignore --write"
26+
]
1027
},
1128
"dependencies": {
12-
"next": "12.2.0",
29+
"@fontsource/poppins": "4.5.8",
30+
"@prisma/client": "4.0.0",
31+
"@trpc/client": "9.25.3",
32+
"@trpc/next": "9.25.3",
33+
"@trpc/react": "9.25.3",
34+
"@trpc/server": "9.25.3",
35+
"next": "12.1.6",
36+
"prisma": "4.0.0",
1337
"react": "18.2.0",
14-
"react-dom": "18.2.0"
38+
"react-dom": "18.2.0",
39+
"react-query": "3.39.1",
40+
"zod": "3.17.3"
1541
},
1642
"devDependencies": {
17-
"@types/node": "18.0.0",
43+
"@commitlint/cli": "17.0.3",
44+
"@commitlint/config-conventional": "17.0.3",
45+
"@types/node": "16.11.41",
1846
"@types/react": "18.0.14",
1947
"@types/react-dom": "18.0.5",
48+
"@typescript-eslint/eslint-plugin": "5.30.0",
49+
"@typescript-eslint/parser": "5.30.0",
50+
"autoprefixer": "10.4.7",
51+
"commitizen": "4.2.4",
52+
"cz-conventional-changelog": "3.3.0",
2053
"eslint": "8.18.0",
21-
"eslint-config-next": "12.2.0",
54+
"eslint-config-next": "12.1.6",
55+
"eslint-config-prettier": "8.5.0",
56+
"eslint-import-resolver-typescript": "2.7.1",
57+
"eslint-plugin-prettier": "4.0.0",
58+
"husky": "8.0.1",
59+
"lint-staged": "13.0.3",
60+
"postcss": "8.4.14",
61+
"prettier": "2.7.1",
62+
"tailwindcss": "3.1.4",
2263
"typescript": "4.7.4"
64+
},
65+
"config": {
66+
"commitizen": {
67+
"path": "cz-conventional-changelog"
68+
}
2369
}
2470
}

0 commit comments

Comments
 (0)