soul-cli 0.2.1 → 0.2.2
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/Chinook_Sqlite.sqlite +0 -0
- package/Chinook_Sqlite.sqlite-shm +0 -0
- package/Chinook_Sqlite.sqlite-wal +0 -0
- package/_extensions/api.js +3 -53
- package/package.json +12 -12
- package/src/cli.js +6 -0
- package/src/config/index.js +5 -1
- package/src/swagger/swagger.json +1 -1
package/Chinook_Sqlite.sqlite
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/_extensions/api.js
CHANGED
|
@@ -2,62 +2,12 @@ const hello = {
|
|
|
2
2
|
method: 'GET',
|
|
3
3
|
path: '/api/hello-soul',
|
|
4
4
|
handler: (req, res, db) => {
|
|
5
|
-
res.status(200).json({
|
|
6
|
-
|
|
5
|
+
res.status(200).json({
|
|
6
|
+
message: 'Hello Soul!'
|
|
7
7
|
});
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const timestamp = {
|
|
12
|
-
method: 'GET',
|
|
13
|
-
path: '/api/timestamp',
|
|
14
|
-
handler: (req, res, db) => {
|
|
15
|
-
res.status(200).json({
|
|
16
|
-
timestamp: Date.now(),
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const greetings = {
|
|
22
|
-
method: 'POST',
|
|
23
|
-
path: '/api/greetings/:name',
|
|
24
|
-
handler: (req, res, db) => {
|
|
25
|
-
const { name } = req.params;
|
|
26
|
-
const { greeting } = req.body;
|
|
27
|
-
res.status(200).json({
|
|
28
|
-
message: `${greeting} ${name}!`,
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const searchTables = {
|
|
34
|
-
method: 'GET',
|
|
35
|
-
path: '/api/search-tables',
|
|
36
|
-
handler: (req, res, db) => {
|
|
37
|
-
const { q } = req.query;
|
|
38
|
-
const sql = `
|
|
39
|
-
SELECT name FROM sqlite_master
|
|
40
|
-
WHERE type='table'
|
|
41
|
-
AND name LIKE $searchQuery
|
|
42
|
-
`;
|
|
43
|
-
try {
|
|
44
|
-
const tables = db.prepare(sql).all({
|
|
45
|
-
searchQuery: `%${q}%`,
|
|
46
|
-
});
|
|
47
|
-
res.status(200).json({
|
|
48
|
-
tables,
|
|
49
|
-
});
|
|
50
|
-
} catch (error) {
|
|
51
|
-
res.status(500).json({
|
|
52
|
-
error: error.message,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
11
|
module.exports = {
|
|
59
12
|
hello,
|
|
60
|
-
|
|
61
|
-
greetings,
|
|
62
|
-
searchTables,
|
|
63
|
-
};
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soul-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A SQLite REST and Realtime server",
|
|
5
5
|
"main": "src/server.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/thevahidal/soul#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"better-sqlite3": "^
|
|
28
|
-
"body-parser": "^1.20.
|
|
27
|
+
"better-sqlite3": "^8.1.0",
|
|
28
|
+
"body-parser": "^1.20.2",
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
30
|
"dotenv": "^16.0.3",
|
|
31
|
-
"express": "^4.18.
|
|
32
|
-
"express-rate-limit": "^6.
|
|
31
|
+
"express": "^4.18.2",
|
|
32
|
+
"express-rate-limit": "^6.7.0",
|
|
33
33
|
"express-winston": "^4.2.0",
|
|
34
|
-
"joi": "^17.
|
|
35
|
-
"swagger-ui-express": "^4.
|
|
34
|
+
"joi": "^17.8.3",
|
|
35
|
+
"swagger-ui-express": "^4.6.1",
|
|
36
36
|
"winston": "^3.8.2",
|
|
37
|
-
"ws": "^8.
|
|
38
|
-
"yargs": "^17.
|
|
37
|
+
"ws": "^8.12.1",
|
|
38
|
+
"yargs": "^17.7.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"cross-env": "^7.0.3",
|
|
42
|
-
"jest": "^29.
|
|
42
|
+
"jest": "^29.4.3",
|
|
43
43
|
"nodemon": "^2.0.20",
|
|
44
|
-
"supertest": "^6.3.
|
|
45
|
-
"swagger-autogen": "^2.
|
|
44
|
+
"supertest": "^6.3.3",
|
|
45
|
+
"swagger-autogen": "^2.23.1"
|
|
46
46
|
},
|
|
47
47
|
"jest": {
|
|
48
48
|
"testEnvironment": "node",
|
package/src/cli.js
CHANGED
|
@@ -27,6 +27,12 @@ if (process.env.NO_CLI !== 'true') {
|
|
|
27
27
|
type: 'boolean',
|
|
28
28
|
demandOption: false,
|
|
29
29
|
})
|
|
30
|
+
.option('c', {
|
|
31
|
+
alias: 'cors',
|
|
32
|
+
describe: 'CORS whitelist origins',
|
|
33
|
+
type: 'string',
|
|
34
|
+
demandOption: false,
|
|
35
|
+
})
|
|
30
36
|
.option('V', {
|
|
31
37
|
alias: 'verbose',
|
|
32
38
|
describe: 'Enable verbose logging',
|
package/src/config/index.js
CHANGED
|
@@ -45,6 +45,10 @@ if (argv.database) {
|
|
|
45
45
|
env.DB = argv.database;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
if (argv.cors) {
|
|
49
|
+
env.CORS_ORIGIN_WHITELIST = argv.cors;
|
|
50
|
+
}
|
|
51
|
+
|
|
48
52
|
if (argv['rate-limit-enabled']) {
|
|
49
53
|
env.RATE_LIMIT_ENABLED = argv['rate-limit-enabled'];
|
|
50
54
|
}
|
|
@@ -71,7 +75,7 @@ module.exports = {
|
|
|
71
75
|
filename: argv.database || envVars.DB || ':memory:',
|
|
72
76
|
},
|
|
73
77
|
cors: {
|
|
74
|
-
origin: envVars.CORS_ORIGIN_WHITELIST.split(','),
|
|
78
|
+
origin: argv.cors.split(',') || envVars.CORS_ORIGIN_WHITELIST.split(','),
|
|
75
79
|
},
|
|
76
80
|
rateLimit: {
|
|
77
81
|
enabled: argv['rate-limit-enabled'] || envVars.RATE_LIMIT_ENABLED,
|