create-sip 1.2.1 → 1.3.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/README.md +0 -173
- package/create-sip.js +1 -1
- package/expressapi/.env.example +10 -0
- package/expressapi/.env.test +7 -0
- package/expressapi/README.md +24 -2
- package/expressapi/app/app.js +17 -0
- package/expressapi/app/controllers/authController.js +9 -11
- package/expressapi/app/controllers/userController.js +36 -1
- package/expressapi/app/database/database.js +14 -14
- package/expressapi/app/index.js +4 -18
- package/expressapi/app/{middlewares → middleware}/authjwt.js +3 -4
- package/expressapi/app/routes/api.js +4 -2
- package/expressapi/database/migrations/2025_10_08_075231_user.js +34 -0
- package/expressapi/docs/dev_doc.md +13 -1
- package/expressapi/docs/user_doc.md +157 -13
- package/expressapi/op +86 -54
- package/expressapi/package-lock.json +5698 -0
- package/expressapi/package.json +3 -1
- package/expressapi/test/{test.js → user.spec.js} +10 -10
- package/manager.js +3 -1
- package/package.json +1 -1
- package/expressapi/config/default.json.example +0 -15
package/expressapi/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Express API with simple Sequelize",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "mocha",
|
|
7
|
+
"test": "NODE_ENV=test mocha",
|
|
8
8
|
"dev": "nodemon app --watch app --watch config",
|
|
9
9
|
"start": "node app"
|
|
10
10
|
},
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"author": "your name",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@dotenvx/dotenvx": "^1.51.0",
|
|
18
19
|
"bcryptjs": "^2.4.3",
|
|
19
20
|
"cors": "^2.8.5",
|
|
20
21
|
"express": "^4.18.2",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/bcryptjs": "^2.4.6",
|
|
34
35
|
"fs-extra": "^11.3.0",
|
|
36
|
+
"mocha": "^11.7.4",
|
|
35
37
|
"nodemon": "^2.0.22",
|
|
36
38
|
"supertest": "^6.3.3"
|
|
37
39
|
},
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import supertest from 'supertest'
|
|
2
|
+
import app from '../app/app.js'
|
|
2
3
|
|
|
3
|
-
describe('
|
|
4
|
-
|
|
5
|
-
const host = 'http://localhost:8000/api'
|
|
4
|
+
describe('/api/register and /api/login', () => {
|
|
6
5
|
const restype= 'application/json; charset=utf-8'
|
|
7
6
|
var token = null
|
|
8
7
|
|
|
9
8
|
it('post /register ', function(done) {
|
|
10
|
-
supertest(
|
|
11
|
-
.post('/register')
|
|
9
|
+
supertest(app)
|
|
10
|
+
.post('/api/register')
|
|
12
11
|
.set('Accept', 'application/json')
|
|
13
12
|
.send({
|
|
14
13
|
name: 'mari',
|
|
@@ -18,10 +17,11 @@ describe('GET /api/users', () => {
|
|
|
18
17
|
})
|
|
19
18
|
.expect('Content-Type', restype)
|
|
20
19
|
.expect(201, done)
|
|
20
|
+
|
|
21
21
|
})
|
|
22
22
|
it('post /login ', (done) => {
|
|
23
|
-
supertest(
|
|
24
|
-
.post('/login')
|
|
23
|
+
supertest(app)
|
|
24
|
+
.post('/api/login')
|
|
25
25
|
.set('Accept', 'application/json')
|
|
26
26
|
.send({
|
|
27
27
|
name: 'mari',
|
|
@@ -34,8 +34,8 @@ describe('GET /api/users', () => {
|
|
|
34
34
|
})
|
|
35
35
|
})
|
|
36
36
|
it('get /users ', function(done) {
|
|
37
|
-
supertest(
|
|
38
|
-
.get('/users')
|
|
37
|
+
supertest(app)
|
|
38
|
+
.get('/api/users')
|
|
39
39
|
.set('Accept', 'application/json')
|
|
40
40
|
.set('Authorization', 'Bearer ' + token)
|
|
41
41
|
.expect(200, done)
|
package/manager.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { copyDir, updatePackageName, checkIfDirExists } = require('./utils');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const dir = path.join(__dirname);
|
|
4
|
+
const fse = require('fs-extra');
|
|
4
5
|
|
|
5
6
|
const genWebpage = (target) => {
|
|
6
7
|
checkIfDirExists(target);
|
|
@@ -67,10 +68,11 @@ const genMockApi = (target) => {
|
|
|
67
68
|
console.log(' npm start');
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
const genExpressApi = (target) => {
|
|
71
|
+
const genExpressApi = async (target) => {
|
|
71
72
|
checkIfDirExists(target);
|
|
72
73
|
copyDir(`${dir}/expressapi`, target);
|
|
73
74
|
updatePackageName(`${target}/package.json`, target);
|
|
75
|
+
|
|
74
76
|
console.log('ExpressJS REST API skeleton created');
|
|
75
77
|
console.log('Read docs/user_doc.md');
|
|
76
78
|
console.log('Run next commands:');
|
package/package.json
CHANGED