create-sipere 0.9.5 → 0.9.7
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/README.md
CHANGED
package/lib/generator.js
CHANGED
|
@@ -5,6 +5,22 @@ const installDependencies = require('./utils');
|
|
|
5
5
|
const TARGET_DIR = process.cwd();
|
|
6
6
|
|
|
7
7
|
module.exports = async function createProject(projectName, options, CURRENT_DIR) {
|
|
8
|
+
const envContent = `APP_PORT=8000
|
|
9
|
+
APP_KEY=
|
|
10
|
+
APP_LOG=console.log
|
|
11
|
+
|
|
12
|
+
DB_DIALECT=sqlite
|
|
13
|
+
DB_HOST=127.0.0.1
|
|
14
|
+
DB_NAME=
|
|
15
|
+
DB_USER=
|
|
16
|
+
DB_PASS=
|
|
17
|
+
DB_STORAGE=database.sqlite
|
|
18
|
+
`
|
|
19
|
+
const gitignoreContent = `/node_modules
|
|
20
|
+
/access.log
|
|
21
|
+
/.env
|
|
22
|
+
/database.sqlite
|
|
23
|
+
`
|
|
8
24
|
const isTypeScript = options.typescript;
|
|
9
25
|
|
|
10
26
|
const templatePath = path.join(
|
|
@@ -23,6 +39,8 @@ module.exports = async function createProject(projectName, options, CURRENT_DIR)
|
|
|
23
39
|
fs.mkdirSync(targetPath);
|
|
24
40
|
console.log('copying files...');
|
|
25
41
|
await fs.copy(templatePath, targetPath);
|
|
42
|
+
await fs.writeFile(path.join(targetPath, '.env'), envContent);
|
|
43
|
+
await fs.writeFile(path.join(targetPath, '.gitignore'), gitignoreContent);
|
|
26
44
|
await updatePackageJson(targetPath, projectName);
|
|
27
45
|
console.log('installing dependencies...');
|
|
28
46
|
await installDependencies(targetPath);
|
|
@@ -48,12 +66,13 @@ Sipere REST API skeleton created
|
|
|
48
66
|
Read docs/user_doc.md
|
|
49
67
|
Run next commands:
|
|
50
68
|
cd ${name}
|
|
51
|
-
node op conf:generate
|
|
52
69
|
node op key:generate
|
|
53
70
|
npm run dev
|
|
54
71
|
Usable commands:
|
|
55
72
|
node op make:model thing
|
|
56
73
|
node op make:controller thing
|
|
74
|
+
node op make:migration thing
|
|
75
|
+
node op make:seeder thing
|
|
57
76
|
The model and controller names must be
|
|
58
77
|
given in the singular. More info:
|
|
59
78
|
node op help
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import multer from 'multer';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
const storage = multer.diskStorage({
|
|
5
|
+
destination: function (req, file, cb) {
|
|
6
|
+
cb(null, 'public/uploads');
|
|
7
|
+
},
|
|
8
|
+
filename: function (req, file, cb) {
|
|
9
|
+
cb(null, Date.now() + path.extname(file.originalname));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const upload = multer({
|
|
14
|
+
storage: storage,
|
|
15
|
+
limits: { fileSize: 1024 * 1024 * 5 }, // 5MB
|
|
16
|
+
fileFilter: function (req, file, cb) {
|
|
17
|
+
const ext = path.extname(file.originalname);
|
|
18
|
+
if (ext !== '.png' && ext !== '.jpg' && ext !== '.jpeg') {
|
|
19
|
+
return cb(new Error('Only images are allowed'));
|
|
20
|
+
}
|
|
21
|
+
cb(null, true);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"author": "your name",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sipere/op-cli": "^0.9.
|
|
18
|
+
"@sipere/op-cli": "^0.9.4",
|
|
19
19
|
"bcryptjs": "^2.4.3",
|
|
20
20
|
"cors": "^2.8.5",
|
|
21
21
|
"dotenv-flow": "^4.1.0",
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"jsonwebtoken": "^9.0.0",
|
|
24
24
|
"mariadb": "^3.1.2",
|
|
25
25
|
"morgan": "^1.10.0",
|
|
26
|
+
"multer": "^2.0.2",
|
|
26
27
|
"sequelize": "^6.32.0",
|
|
27
|
-
"sqlite3": "^5.1.6"
|
|
28
|
+
"sqlite3": "^5.1.6"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/bcryptjs": "^2.4.6",
|