create-sip 0.10.7 → 0.10.9

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.
@@ -1,5 +1,6 @@
1
1
  import express from 'express'
2
2
  import morgan from 'morgan'
3
+ import cors from 'cors'
3
4
  import fs from 'fs'
4
5
  import router from './routes/api.js'
5
6
  import config from '../config/default.json' assert { type: 'json' }
@@ -11,7 +12,7 @@ const PORT = config.app.port || 8000
11
12
  const logfile = 'access.log'
12
13
  var accessLogStream = fs.createWriteStream(logfile, { flags: 'a' })
13
14
  app.use(morgan('dev', { stream: accessLogStream }))
14
-
15
+ app.use(cors())
15
16
  app.use(express.json())
16
17
  app.use('/api', router);
17
18
 
@@ -16,6 +16,7 @@
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
18
  "bcryptjs": "^2.4.3",
19
+ "cors": "^2.8.5",
19
20
  "express": "^4.18.2",
20
21
  "generate-api-key": "^1.0.2",
21
22
  "jsonwebtoken": "^9.0.0",
@@ -0,0 +1,12 @@
1
+ import fs from 'fs/promises'
2
+ import path from 'path';
3
+ import url from 'url';
4
+
5
+ const __filename = url.fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ const sourceFileName = path.join(__dirname, '../config/default.json.example');
8
+ const destinationFileName = path.join(__dirname, '../config/default.json');
9
+
10
+ fs.copyFile(sourceFileName, destinationFileName)
11
+ .catch(error => console.log(error));
12
+
@@ -1,7 +1,11 @@
1
1
  import fs from 'fs/promises'
2
2
  import { generateApiKey } from 'generate-api-key'
3
+ import path, { dirname } from 'path';
4
+ import url from 'url';
3
5
 
4
- const fileName = new URL('../config/default.json', import.meta.url).pathname
6
+ const __filename = url.fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ const fileName = path.join(__dirname, '../config/default.json');
5
9
 
6
10
  function generateKey(size = 32, format = 'base64') {
7
11
  const buffer = crypto.randomBytes(size);
package/manager.js CHANGED
@@ -19,8 +19,9 @@ const genNodejs = (target) => {
19
19
  updatePackageName(`${target}/package.json`, target);
20
20
  console.log('Web client created');
21
21
  console.log('Run next commands:');
22
- console.log('npm install');
23
- console.log('npm start');
22
+ console.log(` cd ${target}`);
23
+ console.log(' npm install');
24
+ console.log(' npm start');
24
25
  }
25
26
 
26
27
  const genWebEsbuildJs = (target) => {
@@ -28,11 +29,12 @@ const genWebEsbuildJs = (target) => {
28
29
  updatePackageName(`${target}/package.json`, target);
29
30
  console.log('ESBuild client created with Javascript');
30
31
  console.log('Run next commands:');
31
- console.log('npm install');
32
- console.log('npm run dev');
33
- console.log('npm start');
32
+ console.log(` cd ${target}`);
33
+ console.log(' npm install');
34
+ console.log(' npm run dev');
35
+ console.log(' npm start');
34
36
  console.log('If you want to build, run:');
35
- console.log('npm run build');
37
+ console.log(' npm run build');
36
38
  }
37
39
 
38
40
  const genWebEsbuildTs = (target) => {
@@ -40,11 +42,12 @@ const genWebEsbuildTs = (target) => {
40
42
  updatePackageName(`${target}/package.json`, target);
41
43
  console.log('ESBuild client created with Typescript');
42
44
  console.log('Run next commands:');
43
- console.log('npm install');
44
- console.log('npm run dev');
45
- console.log('npm start');
45
+ console.log(` cd ${target}`);
46
+ console.log(' npm install');
47
+ console.log(' npm run dev');
48
+ console.log(' npm start');
46
49
  console.log('If you want to build, run:');
47
- console.log('npm run build');
50
+ console.log(' npm run build');
48
51
  }
49
52
 
50
53
  const genMockApi = (target) => {
@@ -52,16 +55,22 @@ const genMockApi = (target) => {
52
55
  updatePackageName(`${target}/package.json`, target);
53
56
  console.log('MockAPI with hai-server 0.0.4');
54
57
  console.log('Run next commands:');
55
- console.log('npm install');
56
- console.log('npm start');
58
+ console.log(` cd ${target}`);
59
+ console.log(' npm install');
60
+ console.log(' npm start');
57
61
  }
58
62
 
59
63
  const genExpressApi = (target) => {
60
64
  copyDir(`${dir}/expressapi`, target);
61
65
  updatePackageName(`${target}/package.json`, target);
62
66
  console.log('ExpressJS REST API sablon created');
63
- console.log('Make a config/default.json');
64
67
  console.log('Read docs/user_doc.md');
68
+ console.log('Run next commands:');
69
+ console.log(` cd ${target}`);
70
+ console.log(' npm install');
71
+ console.log(' node tools/genconf.js');
72
+ console.log(' node tools/genkey.js');
73
+ console.log(' npm run dev');
65
74
  }
66
75
 
67
76
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sip",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "create-sip": "create-sip.js"
@@ -14,6 +14,7 @@
14
14
  This is a Node.js project for webpage. Generated by sip.
15
15
  </p>
16
16
  </div>
17
- <script src="app.js"></script>
17
+ <script src="bootstrap.js"></script>
18
+ <script src="app.js"></script>
18
19
  </body>
19
20
  </html>