Coder Social home page Coder Social logo

inodaf / pwa-kit Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 1.6 MB

๐Ÿ”ญ A Production-Ready Frontend Development Kit with Next.js + TypeScript.

License: MIT License

TypeScript 75.83% JavaScript 16.85% CSS 0.62% Makefile 6.70%
jest eslint prettier tailwindcss react-query github-actions

pwa-kit's Introduction

an icon with tones of purple background and 4 lines representing a fast motion.
PWA Kit ยท Enterprise Apps

Starting a new Web App needs to be easy. PWA Kit provides a fully featured environment with Next.js + TypeScript and let you focus on code delivery without compromising best practices.

The Stack

Base

  • โšก๏ธ Next.js with TypeScript + Paths
  • ๐Ÿ“ฑ First Class PWA Support
  • ๐Ÿƒ Application Properties for Production, Staging and Development
  • ๐Ÿ‘ฉโ€๐ŸŽค CSS Styling with TailwindCSS or CSS Modules
  • โš›๏ธ Support for React Query
  • ๐Ÿ”’ Automatic local HTTPS with Caddy

Quality

  • ๐Ÿง‘โ€๐Ÿ”ฌ Testing with Jest + swc + @testing-library + Coverage Reports
  • ๐Ÿž Linting with TypeScript ESLint
  • ๐Ÿ“ Code Format with Prettier
  • ๐Ÿฅธ GraphQL and REST API mocking with MSW
  • ๐ŸŒฒ E2E Tests with Playwright

Security

  • ๐Ÿ‘ฎโ€โ™‚๏ธ Support for Content-Security-Policy
  • ๐Ÿ” CI Sec Inspection with Mozilla Observatory soon

Accessibility

Performance

  • ๐Ÿ“Š Core Web Vitals Report
  • ๐Ÿšฅ Lighthouse CI + Bundlesize soon

CI + Deployment

  • ๐Ÿ“ GitHub Actions for Test, Lint and Format
  • ๐Ÿš€ Deployment + Branch Preview soon

Getting Started

Base commands for develop, test and build.

Requirements

  • Node.js Toolchain Manager: Volta
  • Package Manager: pnpm
  • HTTP(S) Web Server: Caddy *optional

Prepare Development

A Makefile is used to orchestrate the installation of required tooling and dependencies. Open your Terminal app and run the command bellow, then you are able to get started. Make sure to install Caddy to enable HTTPS on Dev.

make

Note

In case of failure, head to the Troubleshooting section below for alternatives.

Development Server

The next command will spawn the Dev Server and load the environment variables from .env.

pnpm dev        # spawns the Dev Server at http://localhost:3000
pnpm dev:secure # spawns Caddy and the Dev Server at https://localhost:3000

Testing

There are Integration, Unit and E2E tests available and the matching test environment variables (.env.test) are automatically loaded. With the exception of E2E tests, these commands are also used for CI environments.

# Unit & Integration Tests
pnpm test     # run tests without watch
pnpm test:w   # run tests with watch
pnpm test:c   # run tests with coverage
pnpm t        # alias for `pnpm test`
# E2E Tests
pnpm test:e2e # runs with **dev server** as Base URL

Linting & Code Formatting

We split the process into Check and Fix commands.

# Linting
pnpm lint:check # checks linting without fixing (useful for CI)
pnpm lint       # checks linting and fixes issues
# Code Formatting
pnpm fmt:check # checks formatting without fixing (useful for CI)
pnpm fmt       # checks formatting and fixes issues

Environment Variables

Sensitive and secret data can be defined using Environment Variables. An .env file at the root directory can be used for storing these data. As per security .env files cannot be tracked through version control systems.

Application Properties

Application properties let you define environment-specific, static configuration for your system. Unlike Environment Variables, Properties cannot include sensitive values.

There are the base, dev, production and staging properties but it's possible to add many others, as they are named based on the value of APP_ENV and NEXT_PUBLIC_APP_ENV environment variable. Also they are separated by client and server.

The properties from base holds all the default configuration that applies for all environments. Overriding these values is made possible by using the environment specific property file, like dev.

In short, when APP_ENV and NEXT_PUBLIC_APP_ENV is set to production, base and production property files will be loaded and merged. Then they can be accessed through the application as bellow:

import { serverProperties } from "@/config/properties/server";
import { clientProperties } from "@/config/properties/client";

Building

Builds are separated by environments: Production and Staging. For both environments the NODE_ENV is set to production.

Production

pnpm build:prod # build with production bindings
pnpm start:prod # start the built app with production bindings

Staging

pnpm build:stag # build with staging bindings
pnpm start:stag # start the built app with staging bindings

Cleanup

Whenever you need a fresh start in case something is going wrong, you can leverage handy cleanup commands.

pnpm cleanup      # remove caches and temp files
pnpm cleanup:hard # same as above but also remove `node_modules`

Troubleshooting

Fail while using the make command: Behind the scenes this command depends on cURL for downloading Volta and pnpm binaries. Try installing cURL then run the command again. Also, the commands from Makefile are not supported on Windows machines so the alternative is to manually installing the required dependencies.


License

Although this template is MIT licensed, if needed, you must change the license after creating your project.

pwa-kit's People

Contributors

inodaf avatar dependabot[bot] avatar

Stargazers

Roman avatar Kim Silva avatar Aleida Olvera avatar Marcelo Silva avatar Gustavo Henrique Jobstraibizer avatar Alan Gomes avatar

Watchers

 avatar

pwa-kit's Issues

To Dos

Performance

  • Bundlesize
  • Performance Budget
  • Lighthouse CI

CI + Deployment

  • Deployment + Preview with Netlify

Observability and Tracking

  • Analytics with Google Analytics - Optional
  • Observability with New Relic - Optional

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.