arcaptcha-fastify-template
v1.0.0
Published
ArcCaptcha Fastify template - Scaffold for Fastify backend apps (Fastify + ESLint + Prettier)
Maintainers
Readme
arcaptcha-fastify-template
A CLI tool to quickly scaffold a Node.js Fastify backend project with ESLint and Prettier configured out of the box.
Overview
This project provides a template generator that can be used globally via npx:
npx arcaptcha-fastify-template my-appIt will create a ready-to-run backend project using:
- Fastify
- ESLint (flat config) for consistent linting
- Prettier for code formatting
- Predefined folder structure (
src/,routes/, etc.)
How This Template Was Created
Initialized a Node project
mkdir arcaptcha-fastify-template cd arcaptcha-fastify-template npm init -yCreated folders
bin/ template/Added a CLI entry point
The root
package.jsonincludes:{ "bin": { "arcaptcha-fastify-template": "bin/index.js" }, "files": ["bin", "template"] }Created the CLI logic (
bin/index.js)This script:
- Takes a project name (e.g.
my-app) - Copies everything from the
template/folder - Installs dependencies
- Prints the next steps for the user
- Takes a project name (e.g.
#!/usr/bin/env node
import fs from "fs";
import path from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const targetDir = process.argv[2];
if (!targetDir) {
console.error("❌ Please provide a project name");
process.exit(1);
}
const destPath = path.join(process.cwd(), targetDir);
const templatePath = path.join(__dirname, "../template");
if (fs.existsSync(destPath)) {
console.error("❌ Directory already exists.");
process.exit(1);
}
fs.cpSync(templatePath, destPath, { recursive: true });
console.log("✅ Project files copied.");
console.log("📦 Installing dependencies...");
execSync("npm install", { cwd: destPath, stdio: "inherit" });
console.log("\n🎉 All done!");
console.log(`➡️ cd ${targetDir}`);
console.log("➡️ npm run dev");Template Structure
All template files live under template/. These files are copied into the new project when the CLI runs.
template/
├── src/
│ ├── server.js
│ └── routes/
│ └── index.js
├── eslint.config.js
├── .prettierrc
├── .prettierignore
└── package.jsonHighlights:
src/server.js: Minimal Fastify server setup.eslint.config.js: Flat ESLint config for Node.js environment..prettierrc&.prettierignore: Code formatting rules.package.json: Includes Fastify, scripts (npm run dev,npm run lint, etc.).
Development and Publishing
1. Test Locally
node bin/index.js demo-app
cd demo-app
npm run dev2. Create a tarball (for inspection)
npm pack3. Publish to npm
npm publish --access public4. Verify
npm info arcaptcha-fastify-template5. Test the generated project
npx arcaptcha-fastify-template my-new-apiCheck that .prettierrc and .prettierignore exist in the new project.
Updating the Template
Make changes inside
template/Bump version:
- Patch:
npm version patch - Minor:
npm version minor - Major:
npm version major
- Patch:
Publish again:
npm publish --access publicVerify:
npm info arcaptcha-fastify-template
Local Development Shortcut
npm link
arcaptcha-fastify-template test-app
npm unlink -g arcaptcha-fastify-templateCommands Summary
| Command | Description |
| ----------------------------------- | -------------------------------------- |
| npx arcaptcha-fastify-template my-app | Scaffold a new Fastify backend project |
| npm run dev | Start the development server |
| npm run lint | Run ESLint |
| npm run format | Format files with Prettier |
License
MIT © 2025 — Melika Bagheri
