@dgreegman/nets
v1.2.0
Published
[](https://www.npmjs.com/package/@dgreegman/nets) [](https://github.com/DGreegman/nets/blob/main/LICENSE)
Readme
NETS - Node.js Express TypeScript/JavaScript Scaffolder
A simple, interactive CLI tool to quickly scaffold a new Node.js project using the Express framework. Get a production-ready setup for either TypeScript or JavaScript in seconds.
Features
- Interactive Setup: Guides you through the project creation process.
- Language Choice: Supports both TypeScript and standard JavaScript.
- Database Integration: Choose between Mongoose, Sequelize, Prisma, or no database at all.
- Testing Framework: Optionally include Jest for testing.
- API Documentation: Optionally include Swagger for API documentation.
- Modern Project Structure: Creates a logical and scalable directory structure (controllers, services, routes, etc.).
- Optimized Tooling: Comes with ESLint, Prettier, and an optimized
tsconfig.jsonfor TypeScript projects. - Faster Installation: Automatically detects and uses
pnpmoryarnif available, resulting in a faster and more efficient setup. - Essential Scripts:
package.jsonis pre-configured withdev,start,build, andtestscripts. - Automatic
.gitignoreand.env: Generates essential.gitignoreand.envfiles from the start. - User-Friendly Feedback: Displays a loading spinner during dependency installation.
API Documentation with Swagger
NETS can automatically set up Swagger for your project, providing you with interactive API documentation out of the box. When you enable this feature, the following will be configured:
- Swagger UI: A beautiful, interactive API documentation UI will be available at
/api-docs. - Swagger JSDoc: The project will be configured to use
swagger-jsdocto generate the OpenAPI specification from JSDoc comments in your code. - Sample Documentation: A sample route will be documented to show you how to get started.
Usage
To create a new project, run the following command in your terminal:
Using npx (Recommended for trying it out)
npx @dgreegman/netsGlobal Installation (Recommended for frequent use)
# Install once
npm install -g @dgreegman/nets
# Use anywhere
netsWhy Global Installation?
- ⚡ Faster (no download each time)
- 🎯 Simpler command (
netsinstead ofnpx @dgreegman/nets) - 📦 Available offline after first install The tool will then prompt you for the following information:
- Project Name: The name of your new application (e.g.,
my-api). - Language: Your choice of either
TypeScriptorJavaScript. - Database: Your choice of database integration:
Mongoose,Sequelize,Prisma, orNone. - Jest: Whether to include Jest for testing.
- Swagger: Whether to include Swagger for API documentation.
That's it! The tool will create a new directory with your project name and install all the necessary dependencies.
✔ Dependencies installed with pnpm.
✔ Project my-api is set up and ready to go!Generated Project Structure
NETS will generate the following directory structure for your new project:
my-api/
├── .env
├── .eslintrc.json
├── .gitignore
├── .prettierrc.json
├── jest.config.js (if Jest is included)
├── package.json
├── prisma/ (if Prisma is selected)
│ └── schema.prisma
├── src/
│ ├── config/
│ │ └── db.ts (or .js)
│ ├── controllers/
│ ├── email/
│ ├── errors/
│ ├── index.ts (or .js)
│ ├── interfaces/
│ ├── middlewares/
│ ├── models/
│ ├── routes/
│ ├── services/
│ └── utils/
└── tsconfig.json (if TypeScript)Database Integration
NETS supports the following database integrations:
- Mongoose: A popular ODM for MongoDB.
- Sequelize: A promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.
- Prisma: A next-generation ORM for Node.js and TypeScript.
When you select a database, NETS will install the required dependencies and create a configuration file in src/config/db.ts (or .js). You will need to update this file with your database connection details.
Testing with Jest
If you choose to include Jest, NETS will install the required dependencies and create a jest.config.js file in the root of your project. You can then create your test files in a __tests__ directory or with a .test.ts (or .js) extension.
To run your tests, use the following command:
npm testEnvironment Variables
NETS uses the dotenv package to load environment variables from a .env file in the root of your project. You can add your environment variables to this file, and they will be available in your application via process.env.
Collaborators
Thanks to all the amazing contributors to this project ❤️
License
This project is licensed under the ISC License. See the LICENSE file for details.
