• Stars
    star
    1
  • Language
    TypeScript
  • Created about 2 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Blitz.js

This is a Blitz.js app.

name

Getting Started

Run your app in the development mode.

blitz dev

Open http://localhost:3000 with your browser to see the result.

Environment Variables

Ensure the .env.local file has required environment variables:

DATABASE_URL=postgresql://<YOUR_DB_USERNAME>@localhost:5432/prisma-thingy

Ensure the .env.test.local file has required environment variables:

DATABASE_URL=postgresql://<YOUR_DB_USERNAME>@localhost:5432/prisma-thingy_test

Tests

Runs your tests using Jest.

yarn test

Blitz comes with a test setup using Jest and react-testing-library.

Commands

Blitz comes with a powerful CLI that is designed to make development easy and fast. You can install it with npm i -g blitz

  blitz [COMMAND]

  dev       Start a development server
  build     Create a production build
  start     Start a production server
  export    Export your Blitz app as a static application
  prisma    Run prisma commands
  generate  Generate new files for your Blitz project
  console   Run the Blitz console REPL
  install   Install a recipe
  help      Display help for blitz
  test      Run project tests

You can read more about it on the CLI Overview documentation.

What's included?

Here is the starting structure of your app.

prisma-thingy
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ auth/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LoginForm.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ SignupForm.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ mutations/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ changePassword.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ forgotPassword.test.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ forgotPassword.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ login.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ logout.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ resetPassword.test.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ resetPassword.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ signup.ts
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ forgot-password.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ login.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ reset-password.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ signup.tsx
โ”‚   โ”‚   โ””โ”€โ”€ validations.ts
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Form.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ LabeledTextField.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ useCurrentUser.ts
โ”‚   โ”‚   โ””โ”€โ”€ layouts/
โ”‚   โ”‚       โ””โ”€โ”€ Layout.tsx
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ _app.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ _document.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ 404.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ index.test.tsx
โ”‚   โ”‚   โ””โ”€โ”€ index.tsx
โ”‚   โ””โ”€โ”€ users/
โ”‚       โ””โ”€โ”€ queries/
โ”‚           โ””โ”€โ”€ getCurrentUser.ts
โ”œโ”€โ”€ db/
โ”‚   โ”œโ”€โ”€ migrations/
โ”‚   โ”œโ”€โ”€ index.ts
โ”‚   โ”œโ”€โ”€ schema.prisma
โ”‚   โ””โ”€โ”€ seeds.ts
โ”œโ”€โ”€ integrations/
โ”œโ”€โ”€ mailers/
โ”‚   โ””โ”€โ”€ forgotPasswordMailer.ts
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ””โ”€โ”€ logo.png
โ”œโ”€โ”€ test/
โ”‚   โ”œโ”€โ”€ setup.ts
โ”‚   โ””โ”€โ”€ utils.tsx
โ”œโ”€โ”€ .eslintrc.js
โ”œโ”€โ”€ babel.config.js
โ”œโ”€โ”€ blitz.config.ts
โ”œโ”€โ”€ jest.config.ts
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ types.ts

These files are:

  • The app/ folder is a container for most of your project. This is where youโ€™ll put any pages or API routes.

  • db/ is where your database configuration goes. If youโ€™re writing models or checking migrations, this is where to go.

  • public/ is a folder where you will put any static assets. If you have images, files, or videos which you want to use in your app, this is where to put them.

  • integrations/ is a folder to put all third-party integrations like with Stripe, Sentry, etc.

  • test/ is a folder where you can put test utilities and integration tests.

  • package.json contains information about your dependencies and devDependencies. If youโ€™re using a tool like npm or yarn, you wonโ€™t have to worry about this much.

  • tsconfig.json is our recommended setup for TypeScript.

  • .babel.config.js, .eslintrc.js, .env, etc. ("dotfiles") are configuration files for various bits of JavaScript tooling.

  • blitz.config.ts is for advanced custom configuration of Blitz. Here you can learn how to use it.

  • jest.config.js contains config for Jest tests. You can customize it if needed.

You can read more about it in the File Structure section of the documentation.

Tools included

Blitz comes with a set of tools that corrects and formats your code, facilitating its future maintenance. You can modify their options and even uninstall them.

  • ESLint: It lints your code: searches for bad practices and tell you about it. You can customize it via the .eslintrc.js, and you can install (or even write) plugins to have it the way you like it. It already comes with the blitz config, but you can remove it safely. Learn More.
  • Husky: It adds githooks, little pieces of code that get executed when certain Git events are triggerd. For example, pre-commit is triggered just before a commit is created. You can see the current hooks inside .husky/. If are having problems commiting and pushing, check out ther troubleshooting guide. Learn More.
  • Prettier: It formats your code to look the same everywhere. You can configure it via the .prettierrc file. The .prettierignore contains the files that should be ignored by Prettier; useful when you have large files or when you want to keep a custom formatting. Learn More.

Learn more

Read the Blitz.js Documentation to learn more.

The Blitz community is warm, safe, diverse, inclusive, and fun! Feel free to reach out to us in any of our communication channels.