create-express-dex 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +221 -0
- package/bin/index.js +209 -0
- package/package.json +61 -0
- package/templates/js/package.json +23 -0
- package/templates/js/src/server.js +24 -0
- package/templates/ts/package.json +28 -0
- package/templates/ts/src/server.ts +25 -0
- package/templates/ts/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Viraj
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Dex - Fast Express Backend Scaffolding CLI
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://res.cloudinary.com/dzeuvnjmh/image/upload/v1765869170/dex_xcmsl0.png" alt="Dex Logo" width="200">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>A fast CLI tool to scaffold Express.js backend projects with TypeScript or JavaScript</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white" alt="Node.js">
|
|
13
|
+
<img src="https://img.shields.io/badge/Express-5-000000?logo=express&logoColor=white" alt="Express">
|
|
14
|
+
<img src="https://img.shields.io/badge/TypeScript-5.7-3178C6?logo=typescript&logoColor=white" alt="TypeScript">
|
|
15
|
+
<img src="https://img.shields.io/badge/Package_Managers-npm%20%7C%20pnpm%20%7C%20yarn%20%7C%20bun-CB3837?logo=npm&logoColor=white" alt="Package Managers">
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
### **Instant Project Setup**
|
|
23
|
+
|
|
24
|
+
- Interactive CLI prompts for project configuration
|
|
25
|
+
- Choose between **JavaScript** or **TypeScript**
|
|
26
|
+
- Optional **MongoDB with Mongoose** integration
|
|
27
|
+
- Support for **npm, pnpm, yarn, and bun** package managers
|
|
28
|
+
|
|
29
|
+
### **Smart Configuration**
|
|
30
|
+
|
|
31
|
+
- Pre-configured Express server with best practices
|
|
32
|
+
- CORS and body parsing middleware included
|
|
33
|
+
- Environment variable management with `.env` files
|
|
34
|
+
- Dynamic MongoDB connection strings based on project name
|
|
35
|
+
|
|
36
|
+
### **Production-Ready Structure**
|
|
37
|
+
|
|
38
|
+
- Clean, organized project structure
|
|
39
|
+
- Separate database configuration files
|
|
40
|
+
- Ready-to-use server entry point
|
|
41
|
+
- Proper `.gitignore` configuration
|
|
42
|
+
|
|
43
|
+
### **Developer Experience**
|
|
44
|
+
|
|
45
|
+
- Fast development server with `nodemon` (like Vite for backend!)
|
|
46
|
+
- TypeScript support with proper configuration
|
|
47
|
+
- Automatic dependency installation
|
|
48
|
+
- Clear next-steps instructions after setup
|
|
49
|
+
|
|
50
|
+
### **Not a Framework**
|
|
51
|
+
|
|
52
|
+
Dex is a **scaffolding tool**, not a framework. It generates a clean Express.js project with sensible defaults, giving you full control over your code without any lock-in or abstraction layers.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Prerequisites
|
|
57
|
+
|
|
58
|
+
- **Node.js** 18 or higher
|
|
59
|
+
- **npm**, **pnpm**, **yarn**, or **bun** (your choice!)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm create express-dex
|
|
67
|
+
|
|
68
|
+
or
|
|
69
|
+
|
|
70
|
+
npx create-express-dex
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
That's it! The CLI will guide you through the setup process.
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
When you run `npm create express-dex`, you'll be prompted with the following questions:
|
|
78
|
+
|
|
79
|
+
1. **Project Name**: Enter your project name (default: `my-dex-project`)
|
|
80
|
+
2. **Language**: Choose between `JavaScript` or `TypeScript`
|
|
81
|
+
3. **Package Manager**: Select `npm`, `pnpm`, `yarn`, or `bun`
|
|
82
|
+
4. **MongoDB**: Choose whether to include MongoDB with Mongoose
|
|
83
|
+
|
|
84
|
+
### Example Session
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
$ npm create express-dex
|
|
88
|
+
|
|
89
|
+
Welcome to Dex!
|
|
90
|
+
|
|
91
|
+
██████╗ ███████╗██╗ ██╗
|
|
92
|
+
██╔══██╗██╔════╝╚██╗██╔╝
|
|
93
|
+
██║ ██║█████╗ ╚███╔╝
|
|
94
|
+
██║ ██║██╔══╝ ██╔██╗
|
|
95
|
+
██████╔╝███████╗██╔╝ ██╗
|
|
96
|
+
╚═════╝ ╚══════╝╚═╝ ╚═╝
|
|
97
|
+
|
|
98
|
+
? What is the name of your project? : my-awesome-api
|
|
99
|
+
? Which language do you want to use? TypeScript
|
|
100
|
+
? Which package manager do you want to use? npm
|
|
101
|
+
? Do you want to use MongoDB with Mongoose? Yes
|
|
102
|
+
|
|
103
|
+
Scaffolding project in /path/to/my-awesome-api...
|
|
104
|
+
Setting up MongoDB...
|
|
105
|
+
Installing dependencies...
|
|
106
|
+
|
|
107
|
+
Success! Created my-awesome-api at /path/to/my-awesome-api
|
|
108
|
+
|
|
109
|
+
Inside that directory, you can run:
|
|
110
|
+
|
|
111
|
+
npm run dev
|
|
112
|
+
Starts the development server.
|
|
113
|
+
|
|
114
|
+
We suggest that you begin by typing:
|
|
115
|
+
|
|
116
|
+
cd my-awesome-api
|
|
117
|
+
npm run dev
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Generated Project Structure
|
|
123
|
+
|
|
124
|
+
### JavaScript Project
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
my-project/
|
|
128
|
+
├── src/
|
|
129
|
+
│ ├── db/ # MongoDB connection (if selected)
|
|
130
|
+
│ │ └── index.js
|
|
131
|
+
│ └── server.js # Express server entry point
|
|
132
|
+
├── .env # Environment variables
|
|
133
|
+
├── .gitignore
|
|
134
|
+
├── package.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### TypeScript Project
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
my-project/
|
|
141
|
+
├── src/
|
|
142
|
+
│ ├── db/ # MongoDB connection (if selected)
|
|
143
|
+
│ │ └── index.ts
|
|
144
|
+
│ └── server.ts # Express server entry point
|
|
145
|
+
├── .env # Environment variables
|
|
146
|
+
├── .gitignore
|
|
147
|
+
├── package.json
|
|
148
|
+
└── tsconfig.json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Environment Variables
|
|
154
|
+
|
|
155
|
+
Dex automatically generates a `.env` file with the following variables:
|
|
156
|
+
|
|
157
|
+
### Without MongoDB
|
|
158
|
+
|
|
159
|
+
```env
|
|
160
|
+
PORT=5000
|
|
161
|
+
CORS_ORIGIN=*
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### With MongoDB
|
|
165
|
+
|
|
166
|
+
```env
|
|
167
|
+
PORT=5000
|
|
168
|
+
CORS_ORIGIN=*
|
|
169
|
+
MONGODB_URI=mongodb://localhost:27017/my-project
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Package Manager Support
|
|
175
|
+
|
|
176
|
+
Dex supports all major package managers:
|
|
177
|
+
|
|
178
|
+
| Package Manager | Installation Command | Run Dev Server |
|
|
179
|
+
| --------------- | -------------------- | -------------- |
|
|
180
|
+
| **npm** | `npm install` | `npm run dev` |
|
|
181
|
+
| **pnpm** | `pnpm install` | `pnpm run dev` |
|
|
182
|
+
| **yarn** | `yarn` | `yarn run dev` |
|
|
183
|
+
| **bun** | `bun install` | `bun run dev` |
|
|
184
|
+
|
|
185
|
+
The CLI will automatically use your selected package manager for installation and display the correct commands in the success message.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### Project Structure (CLI Source)
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
dex/
|
|
193
|
+
├── src/
|
|
194
|
+
│ └── index.ts # Main CLI logic
|
|
195
|
+
├── templates/
|
|
196
|
+
│ ├── js/ # JavaScript templates
|
|
197
|
+
│ │ ├── src/
|
|
198
|
+
│ │ ├── package.json
|
|
199
|
+
│ │ └── _gitignore
|
|
200
|
+
│ └── ts/ # TypeScript templates
|
|
201
|
+
│ ├── src/
|
|
202
|
+
│ ├── package.json
|
|
203
|
+
│ ├── tsconfig.json
|
|
204
|
+
│ └── _gitignore
|
|
205
|
+
├── bin/
|
|
206
|
+
│ └── index.js # Compiled output
|
|
207
|
+
├── package.json
|
|
208
|
+
└── tsconfig.json
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Contributing
|
|
214
|
+
|
|
215
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
<p align="center">
|
|
220
|
+
Made with ❤️ by the Viraj :)
|
|
221
|
+
</p>
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
async function init() {
|
|
11
|
+
const logo = `
|
|
12
|
+
██████╗ ███████╗██╗ ██╗
|
|
13
|
+
██╔══██╗██╔════╝╚██╗██╔╝
|
|
14
|
+
██║ ██║█████╗ ╚███╔╝
|
|
15
|
+
██║ ██║██╔══╝ ██╔██╗
|
|
16
|
+
██████╔╝███████╗██╔╝ ██╗
|
|
17
|
+
╚═════╝ ╚══════╝╚═╝ ╚═╝
|
|
18
|
+
`;
|
|
19
|
+
console.log(chalk.bold.cyan("Welcome to Dex!"));
|
|
20
|
+
console.log(chalk.bold.cyan(logo));
|
|
21
|
+
const answers = await inquirer.prompt([
|
|
22
|
+
{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "projectName",
|
|
25
|
+
message: "What is the name of your project? :",
|
|
26
|
+
default: "my-dex-project",
|
|
27
|
+
validate: (input) => {
|
|
28
|
+
if (/^([a-z0-9\-\_\.]+)$/.test(input))
|
|
29
|
+
return true;
|
|
30
|
+
return "Project name may only include lower-case letters, numbers, hashes, dots and underscores.";
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "list",
|
|
35
|
+
name: "language",
|
|
36
|
+
message: "Which language do you want to use?",
|
|
37
|
+
choices: ["JavaScript", "TypeScript"],
|
|
38
|
+
default: "JavaScript",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "list",
|
|
42
|
+
name: "packageManager",
|
|
43
|
+
message: "Which package manager do you want to use?",
|
|
44
|
+
choices: ["npm", "pnpm", "yarn", "bun"],
|
|
45
|
+
default: "npm",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "confirm",
|
|
49
|
+
name: "useMongo",
|
|
50
|
+
message: "Do you want to use MongoDB with Mongoose?",
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
const { projectName, language, useMongo, packageManager } = answers;
|
|
55
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
56
|
+
const templateName = language === "TypeScript" ? "ts" : "js";
|
|
57
|
+
const templateDir = path.join(__dirname, "..", "templates", templateName);
|
|
58
|
+
if (fs.existsSync(targetDir)) {
|
|
59
|
+
console.error(chalk.red(`Directory ${projectName} already exists!`));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
console.log(chalk.blue(`\nScaffolding project in ${targetDir}...`));
|
|
63
|
+
// Copy template
|
|
64
|
+
try {
|
|
65
|
+
await fs.copy(templateDir, targetDir);
|
|
66
|
+
if (await fs.pathExists(path.join(targetDir, "_gitignore"))) {
|
|
67
|
+
await fs.move(path.join(targetDir, "_gitignore"), path.join(targetDir, ".gitignore"));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
console.error(chalk.red("Error copying template files:"), err);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
// Handle MongoDB logic
|
|
75
|
+
if (useMongo) {
|
|
76
|
+
console.log(chalk.blue("Setting up MongoDB..."));
|
|
77
|
+
const dbFileExt = language === "TypeScript" ? "ts" : "js";
|
|
78
|
+
const dbPath = path.join(targetDir, "src", "db", `index.${dbFileExt}`);
|
|
79
|
+
const dbCode = language === "TypeScript"
|
|
80
|
+
? `import mongoose from 'mongoose';
|
|
81
|
+
|
|
82
|
+
const connectDB = async () => {
|
|
83
|
+
try {
|
|
84
|
+
const connectionInstance = await mongoose.connect(\`\${process.env.MONGODB_URI}\`);
|
|
85
|
+
console.log(\`MongoDB connected successfully!\`);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.log("MONGODB connection FAILED ", error);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default connectDB;`
|
|
93
|
+
: `import mongoose from "mongoose";
|
|
94
|
+
|
|
95
|
+
const connectDB = async () => {
|
|
96
|
+
try {
|
|
97
|
+
const connectionInstance = await mongoose.connect(\`\${process.env.MONGODB_URI}\`);
|
|
98
|
+
console.log(\`MongoDB connected successfully!\`);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.log("MONGODB connection FAILED ", error);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default connectDB;`;
|
|
106
|
+
await fs.outputFile(dbPath, dbCode);
|
|
107
|
+
const serverFile = path.join(targetDir, "src", `server.${dbFileExt}`);
|
|
108
|
+
const serverCode = language === "TypeScript"
|
|
109
|
+
? `import express, { Express } from "express";
|
|
110
|
+
import cors from "cors";
|
|
111
|
+
import dotenv from "dotenv";
|
|
112
|
+
import connectDB from "./db/index.js";
|
|
113
|
+
|
|
114
|
+
dotenv.config({
|
|
115
|
+
path: './.env'
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const app: Express = express();
|
|
119
|
+
|
|
120
|
+
app.use(cors({
|
|
121
|
+
origin: process.env.CORS_ORIGIN,
|
|
122
|
+
credentials: true
|
|
123
|
+
}));
|
|
124
|
+
|
|
125
|
+
app.use(express.json({limit: "16kb"}));
|
|
126
|
+
app.use(express.urlencoded({extended: true, limit: "16kb"}));
|
|
127
|
+
|
|
128
|
+
// routes declaration
|
|
129
|
+
|
|
130
|
+
connectDB()
|
|
131
|
+
.then(() => {
|
|
132
|
+
app.listen(process.env.PORT || 5000, () => {
|
|
133
|
+
console.log(\`Server running on port \${process.env.PORT || 5000}\`);
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
.catch((err) => {
|
|
137
|
+
console.log("MONGO db connection failed! ", err);
|
|
138
|
+
});`
|
|
139
|
+
: `import express from "express";
|
|
140
|
+
import cors from "cors";
|
|
141
|
+
import dotenv from "dotenv";
|
|
142
|
+
import connectDB from "./db/index.js";
|
|
143
|
+
|
|
144
|
+
dotenv.config({
|
|
145
|
+
path: './.env'
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const app = express();
|
|
149
|
+
|
|
150
|
+
app.use(cors({
|
|
151
|
+
origin: process.env.CORS_ORIGIN,
|
|
152
|
+
credentials: true
|
|
153
|
+
}));
|
|
154
|
+
|
|
155
|
+
app.use(express.json({limit: "16kb"}));
|
|
156
|
+
app.use(express.urlencoded({extended: true, limit: "16kb"}));
|
|
157
|
+
|
|
158
|
+
// routes declaration
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
connectDB()
|
|
162
|
+
.then(() => {
|
|
163
|
+
app.listen(process.env.PORT || 5000, () => {
|
|
164
|
+
console.log(\`Server running on port \${process.env.PORT || 5000}\`);
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
console.log("MONGO db connection failed !!! ", err);
|
|
169
|
+
});`;
|
|
170
|
+
await fs.outputFile(serverFile, serverCode);
|
|
171
|
+
}
|
|
172
|
+
const pkgJsonPath = path.join(targetDir, "package.json");
|
|
173
|
+
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
174
|
+
pkgJson.name = projectName;
|
|
175
|
+
if (useMongo) {
|
|
176
|
+
console.log(chalk.blue("Adding mongoose..."));
|
|
177
|
+
pkgJson.dependencies = pkgJson.dependencies || {};
|
|
178
|
+
pkgJson.dependencies.mongoose = "^8.0.0";
|
|
179
|
+
}
|
|
180
|
+
await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
181
|
+
// Generate .env file dynamically
|
|
182
|
+
const envContent = [
|
|
183
|
+
"PORT=5000",
|
|
184
|
+
"CORS_ORIGIN=*",
|
|
185
|
+
useMongo ? `MONGODB_URI=mongodb://localhost:27017/${projectName}` : "",
|
|
186
|
+
]
|
|
187
|
+
.filter(Boolean)
|
|
188
|
+
.join("\n");
|
|
189
|
+
await fs.outputFile(path.join(targetDir, ".env"), envContent);
|
|
190
|
+
console.log(chalk.blue("Installing dependencies..."));
|
|
191
|
+
try {
|
|
192
|
+
const installCommand = packageManager === "yarn" ? "yarn" : `${packageManager} install`;
|
|
193
|
+
execSync(installCommand, { stdio: "inherit", cwd: targetDir });
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
console.error(chalk.red("Error installing dependencies."), err);
|
|
197
|
+
}
|
|
198
|
+
console.log(chalk.green(`\nSuccess! Created ${projectName} at ${targetDir}`));
|
|
199
|
+
console.log("\nInside that directory, you can run:");
|
|
200
|
+
console.log(`\n ${chalk.cyan(`${packageManager} run dev`)}`);
|
|
201
|
+
console.log(" Starts the development server.");
|
|
202
|
+
console.log("\nWe suggest that you begin by typing:");
|
|
203
|
+
console.log(`\n ${chalk.cyan("cd")} ${projectName}`);
|
|
204
|
+
console.log(` ${chalk.cyan(`${packageManager} run dev`)}`);
|
|
205
|
+
}
|
|
206
|
+
init().catch((err) => {
|
|
207
|
+
console.error(err);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-express-dex",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "A fast CLI to scaffold Express.js backend projects with TypeScript or JavaScript",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-express-dex": "./bin/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"templates"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"watch": "tsc -w",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cli",
|
|
22
|
+
"express",
|
|
23
|
+
"generator",
|
|
24
|
+
"starter",
|
|
25
|
+
"scaffold",
|
|
26
|
+
"backend",
|
|
27
|
+
"nodejs",
|
|
28
|
+
"typescript",
|
|
29
|
+
"javascript",
|
|
30
|
+
"mongodb",
|
|
31
|
+
"mongoose",
|
|
32
|
+
"create",
|
|
33
|
+
"boilerplate",
|
|
34
|
+
"template"
|
|
35
|
+
],
|
|
36
|
+
"author": "Viraj",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/viraj-ap/dex.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/viraj-ap/dex/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://dex-omega-fawn.vercel.app/",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"chalk": "^5.3.0",
|
|
48
|
+
"fs-extra": "^11.2.0",
|
|
49
|
+
"inquirer": "^9.2.12"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/fs-extra": "^11.0.4",
|
|
53
|
+
"@types/inquirer": "^9.0.7",
|
|
54
|
+
"@types/node": "^22.10.2",
|
|
55
|
+
"tsx": "^4.21.0",
|
|
56
|
+
"typescript": "^5.7.2"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.0.0"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "supernova-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "src/server.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node src/server.js",
|
|
9
|
+
"dev": "nodemon src/server.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"cors": "^2.8.5",
|
|
16
|
+
"dotenv": "^16.4.5",
|
|
17
|
+
"express": "^4.18.2"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"nodemon": "^3.0.3",
|
|
21
|
+
"prettier": "^3.2.5"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import cors from "cors";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
|
|
5
|
+
dotenv.config({
|
|
6
|
+
path: './.env'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const app = express();
|
|
10
|
+
|
|
11
|
+
app.use(cors({
|
|
12
|
+
origin: process.env.CORS_ORIGIN,
|
|
13
|
+
credentials: true
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
app.use(express.json({limit: "16kb"}));
|
|
17
|
+
app.use(express.urlencoded({extended: true, limit: "16kb"}));
|
|
18
|
+
|
|
19
|
+
// routes declaration
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
app.listen(process.env.PORT || 5000, () => {
|
|
23
|
+
console.log(`⚙️ Server is running at port : ${process.env.PORT || 5000}`);
|
|
24
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "supernova-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "src/server.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node dist/server.js",
|
|
9
|
+
"dev": "tsx watch src/server.ts",
|
|
10
|
+
"build": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"cors": "^2.8.5",
|
|
17
|
+
"dotenv": "^16.4.5",
|
|
18
|
+
"express": "^4.18.2"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/cors": "^2.8.17",
|
|
22
|
+
"@types/express": "^4.17.21",
|
|
23
|
+
"@types/node": "^20.10.0",
|
|
24
|
+
"tsx": "^4.7.1",
|
|
25
|
+
"typescript": "^5.3.2",
|
|
26
|
+
"prettier": "^3.2.5"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import express, { Express } from "express";
|
|
2
|
+
import cors from "cors";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
|
|
5
|
+
dotenv.config({
|
|
6
|
+
path: './.env'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const app: Express = express();
|
|
10
|
+
|
|
11
|
+
app.use(cors({
|
|
12
|
+
origin: process.env.CORS_ORIGIN,
|
|
13
|
+
credentials: true
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
app.use(express.json({limit: "16kb"}));
|
|
17
|
+
app.use(express.urlencoded({extended: true, limit: "16kb"}));
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// routes declaration
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
app.listen(process.env.PORT || 5000, () => {
|
|
24
|
+
console.log(`⚙️ Server is running at port : ${process.env.PORT || 5000}`);
|
|
25
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2020",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"baseUrl": "./src",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|