How PEST.js Works
Framework execution process and file generation
Note:
PEST.js generates Node.js projects through a simple CLI interface and modular file generators.
Framework Execution
1
CLI Entry
Framework starts with:
./pestjs
Validates environment and collects user input
2
User Input
Prompts for project details:
- Project name (default: pestjs-app)
- GitHub username (default: your-username)
3
File Generation
Creates project files:
- package.json with dependencies
- tsconfig.json for TypeScript
- .eslintrc.json for linting
- src/app.ts for Express app
- .env files for environment
4
Git Setup
Initializes repository:
git init
git add .
git commit -m "Initial commit: PEST.js project"
Framework Components
coreadd
cliadd
generatorsadd
utilsadd
Note:
Each component has specific responsibilities:
- CLI: User interaction and project setup
- Generators: Create essential project files
- Utils: Helper functions and utilities
Generated Files
package.json
{
"name": "your-project",
"scripts": {
"start": "node dist/app.js",
"dev": "nodemon --exec ts-node src/app.ts",
"build": "tsc",
"test": "jest",
"lint": "eslint . --ext .ts"
},
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5",
"helmet": "^7.1.0",
"dotenv": "^16.4.1"
}
}
src/app.ts
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
const app = express();
app.use(helmet());
app.use(cors());
app.use(express.json());
app.get('/', (_, res) => {
res.json({
message: 'Welcome to your-project API',
version: '1.0.0'
});
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});