Skip to content

Latest commit

 

History

History
91 lines (60 loc) · 3.67 KB

README.md

File metadata and controls

91 lines (60 loc) · 3.67 KB

node-swc-template

This template provides a foundational structure for creating web applications in Node.js with the Express framework. It leverages essential tools such as swc, TypeScript, ESLint, and Prettier to streamline development, ensuring high performance, adherence to coding standards, and efficient code optimization. The server responds on http://localhost:3000 with a JSON message: { ok: true }, indicating proper functionality.

Updates

This template has undergone substantial improvements to enhance code quality, maintenance, and tooling integration. Key changes include:

  • Dependency Updates: Updated versions of dependencies, including "@swc/cli," "@swc/core," and "@swc-node/register," to their latest releases.

  • ESLint Configuration: Simplified and refined ESLint configurations in the .eslintrc.json file, now extending @guarapi/eslint-config-guarapi while removing specific rules.

  • VSCode Configuration: Adjusted Visual Studio Code settings in the settings.json file, modifying ESLint action to "explicit" on code save.

  • Prettier Configuration: Introduced a specific Prettier configuration in the package.json file, referencing @guarapi/eslint-config-guarapi/prettierrc.js.

  • Updates to npm Scripts: Enhanced npm scripts, including the addition of the "types" script for executing TypeScript and "lint" script for linting.

  • Versions of Development Dependencies: Updated versions of development dependencies, such as ESLint, TypeScript, Prettier, among others. This template now utilizes pnpm as the package manager to manage dependencies more efficiently.

These changes aim to improve code quality, maintenance, and the integration of linting and formatting tools within the "node-swc-template" project.

Project Structure

Tooling

This project depends on the following tooling packages:

  • swc: A high-speed JavaScript and TypeScript compiler written in Rust.
  • eslint + prettier: Static code analysis tools identifying problematic patterns in JavaScript code.
  • rimraf: A package providing a platform-independent way to execute the rm -rf command.
  • nodemon: Tools monitoring project file changes and automatically restarting the server.
  • @swc/register: Compiles TypeScript files on the fly, used in the development task by nodemon.

Installation

To install project dependencies, run the following command:

pnpm install

Start

To initiate the application in production, executing the code in the dist folder, run:

pnpm start

This command launches the application by executing the index.js file in the dist folder.

Development

To run the project in development mode, use:

pnpm run dev

This starts nodemon, monitoring file changes and restarting the server automatically.

Build

To build the project for production, run:

pnpm run build

This uses swc to transpile TypeScript files into JavaScript, placing them in the dist folder.

Clean

To remove artifacts, run:

pnpm run clean

This deletes the dist folder, containing files generated by swc.

Lint

To check if the code adheres to ESLint and Prettier rules, run:

pnpm run lint

This displays potential errors and warnings in the code, along with suggestions for resolution.

Types

To execute TypeScript and check types, run:

pnpm run types

This task ensures type correctness and validates TypeScript files in the project.