create-rifad-backend 1.0.0

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/bin/index.js ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs-extra';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { execa } from 'execa';
7
+ import pc from 'picocolors';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ async function init() {
13
+ const targetDir = process.argv[2] || '.';
14
+ const root = path.resolve(process.cwd(), targetDir);
15
+
16
+ console.log(pc.cyan(`\n🚀 Creating a new Rifad backend in ${pc.bold(root)}...\n`));
17
+
18
+ if (!fs.existsSync(root)) {
19
+ fs.mkdirSync(root, { recursive: true });
20
+ }
21
+
22
+ const templateDir = path.resolve(__dirname, '../template');
23
+
24
+ // Copy template files
25
+ try {
26
+ await fs.copy(templateDir, root);
27
+ console.log(pc.green('✔ Template files copied successfully!'));
28
+ } catch (err) {
29
+ console.error(pc.red('✖ Error copying template files:'), err);
30
+ process.exit(1);
31
+ }
32
+
33
+ // Run npm install
34
+ console.log(pc.yellow('\n📦 Installing dependencies...'));
35
+ try {
36
+ await execa('npm', ['install'], {
37
+ cwd: root,
38
+ stdio: 'inherit',
39
+ });
40
+ console.log(pc.green('\n✔ Dependencies installed successfully!'));
41
+ } catch (err) {
42
+ console.error(pc.red('\n✖ Error installing dependencies:'), err);
43
+ process.exit(1);
44
+ }
45
+
46
+ // Final instructions
47
+ console.log(pc.cyan(`\n✨ Project ready! ✨\n`));
48
+ console.log(pc.white('To get started:'));
49
+ if (targetDir !== '.') {
50
+ console.log(pc.magenta(` cd ${targetDir}`));
51
+ }
52
+ console.log(pc.magenta(' npm run dev\n'));
53
+ }
54
+
55
+ init().catch((err) => {
56
+ console.error(pc.red('Error:'), err);
57
+ process.exit(1);
58
+ });
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "create-rifad-backend",
3
+ "version": "1.0.0",
4
+ "description": "Scaffolding tool for Node.js + Express backend",
5
+ "type": "module",
6
+ "main": "bin/index.js",
7
+ "bin": {
8
+ "create-rifad-backend": "bin/index.js"
9
+ },
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "keywords": [
14
+ "cli",
15
+ "scaffold",
16
+ "express",
17
+ "node",
18
+ "template"
19
+ ],
20
+ "author": "Rifad",
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "fs-extra": "^11.2.0",
24
+ "execa": "^9.5.1",
25
+ "picocolors": "^1.1.1"
26
+ }
27
+ }
package/template/.env ADDED
@@ -0,0 +1 @@
1
+ PORT=3000
@@ -0,0 +1,27 @@
1
+ # Rifad Backend
2
+
3
+ This is a ready-to-run Node.js + Express backend generated by `create-rifad-backend`.
4
+
5
+ ## Getting Started
6
+
7
+ 1. **Install dependencies:**
8
+ ```bash
9
+ npm install
10
+ ```
11
+
12
+ 2. **Set up environment variables:**
13
+ Create a `.env` file (one has been pre-generated for you) and add your environment variables.
14
+
15
+ 3. **Run in development mode:**
16
+ ```bash
17
+ npm run dev
18
+ ```
19
+
20
+ 4. **Run in production mode:**
21
+ ```bash
22
+ npm start
23
+ ```
24
+
25
+ ## API Endpoints
26
+
27
+ - `GET /`: Returns the status of the backend.
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "rifad-backend",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "nodemon src/index.js",
7
+ "start": "node src/index.js"
8
+ },
9
+ "dependencies": {
10
+ "express": "^4.18.2",
11
+ "dotenv": "^16.3.1"
12
+ },
13
+ "devDependencies": {
14
+ "nodemon": "^3.0.1"
15
+ }
16
+ }
@@ -0,0 +1,15 @@
1
+ import express from 'express';
2
+ import dotenv from 'dotenv';
3
+
4
+ dotenv.config();
5
+
6
+ const app = express();
7
+ const PORT = process.env.PORT || 3000;
8
+
9
+ app.get('/', (req, res) => {
10
+ res.json({ status: "Backend running" });
11
+ });
12
+
13
+ app.listen(PORT, () => {
14
+ console.log(`\n🚀 Server is running on http://localhost:${PORT}`);
15
+ });