express-generator-typescript 1.10.3 → 2.0.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/README.md +37 -27
- package/bin/cli.js +2 -15
- package/lib/cli.js +1 -15
- package/lib/express-generator-typescript.js +11 -21
- package/lib/project-files/.eslintrc.json +16 -2
- package/lib/project-files/build.ts +2 -2
- package/lib/project-files/package.json +15 -5
- package/lib/project-files/spec/nodemon.json +1 -1
- package/lib/{auth-proj → project-files}/spec/support/login-agent.ts +6 -8
- package/lib/{auth-proj → project-files}/spec/tests/auth.spec.ts +18 -32
- package/lib/project-files/spec/tests/users.spec.ts +31 -22
- package/lib/project-files/spec/types/supertest/index.d.ts +14 -0
- package/lib/project-files/src/models/user-model.ts +18 -3
- package/lib/project-files/src/pre-start/env/development.env +9 -0
- package/lib/project-files/src/pre-start/env/production.env +10 -0
- package/lib/project-files/src/pre-start/env/test.env +9 -0
- package/lib/{auth-proj → project-files}/src/public/scripts/http.js +0 -0
- package/lib/{auth-proj → project-files}/src/public/scripts/login.js +0 -0
- package/lib/{auth-proj → project-files}/src/public/scripts/users.js +0 -0
- package/lib/{auth-proj → project-files}/src/public/stylesheets/login.css +0 -0
- package/lib/{auth-proj → project-files}/src/public/stylesheets/users.css +0 -0
- package/lib/project-files/src/repos/mock-orm.ts +2 -2
- package/lib/project-files/src/repos/user-repo.ts +1 -1
- package/lib/project-files/src/routes/api.ts +9 -6
- package/lib/{socket-io → project-files}/src/routes/auth-router.ts +14 -15
- package/lib/{auth-proj → project-files}/src/routes/middleware.ts +10 -8
- package/lib/project-files/src/routes/user-router.ts +9 -15
- package/lib/project-files/src/server.ts +82 -73
- package/lib/{auth-proj → project-files}/src/services/auth-service.ts +1 -1
- package/lib/project-files/src/services/user-service.ts +9 -9
- package/lib/project-files/src/shared/env-vars.ts +18 -0
- package/lib/project-files/src/shared/errors.ts +11 -0
- package/lib/project-files/src/shared/types.ts +14 -0
- package/lib/project-files/src/types/express/index.d.ts +16 -8
- package/lib/{socket-io → project-files}/src/util/jwt-util.ts +10 -9
- package/lib/{auth-proj → project-files}/src/views/login.html +0 -0
- package/lib/{auth-proj → project-files}/src/views/users.html +0 -0
- package/lib/project-files/tsconfig.json +3 -0
- package/package.json +1 -1
- package/chat-screenshot.png +0 -0
- package/lib/auth-proj/.eslintignore +0 -1
- package/lib/auth-proj/.eslintrc.json +0 -27
- package/lib/auth-proj/build.ts +0 -64
- package/lib/auth-proj/gitignore +0 -3
- package/lib/auth-proj/package.json +0 -73
- package/lib/auth-proj/spec/index.ts +0 -57
- package/lib/auth-proj/spec/loadEnv.ts +0 -10
- package/lib/auth-proj/spec/nodemon.json +0 -6
- package/lib/auth-proj/spec/support/jasmine.json +0 -11
- package/lib/auth-proj/spec/tests/users.spec.ts +0 -283
- package/lib/auth-proj/src/index.ts +0 -14
- package/lib/auth-proj/src/models/user-model.ts +0 -56
- package/lib/auth-proj/src/pre-start/env/development.env +0 -23
- package/lib/auth-proj/src/pre-start/env/production.env +0 -24
- package/lib/auth-proj/src/pre-start/env/test.env +0 -23
- package/lib/auth-proj/src/pre-start/index.ts +0 -28
- package/lib/auth-proj/src/repos/database.json +0 -1
- package/lib/auth-proj/src/repos/mock-orm.ts +0 -41
- package/lib/auth-proj/src/repos/user-repo.ts +0 -88
- package/lib/auth-proj/src/routes/api.ts +0 -17
- package/lib/auth-proj/src/routes/auth-router.ts +0 -63
- package/lib/auth-proj/src/routes/user-router.ts +0 -80
- package/lib/auth-proj/src/server.ts +0 -82
- package/lib/auth-proj/src/services/user-service.ts +0 -52
- package/lib/auth-proj/src/shared/env-vars.ts +0 -20
- package/lib/auth-proj/src/shared/errors.ts +0 -45
- package/lib/auth-proj/src/shared/functions.ts +0 -18
- package/lib/auth-proj/src/types/express/index.d.ts +0 -32
- package/lib/auth-proj/src/util/jwt-util.ts +0 -47
- package/lib/auth-proj/tsconfig.json +0 -100
- package/lib/auth-proj/tsconfig.prod.json +0 -11
- package/lib/project-files/src/public/scripts/index.js +0 -183
- package/lib/project-files/src/public/stylesheets/style.css +0 -33
- package/lib/project-files/src/views/index.html +0 -31
- package/lib/socket-io/.eslintignore +0 -1
- package/lib/socket-io/.eslintrc.json +0 -27
- package/lib/socket-io/build.ts +0 -64
- package/lib/socket-io/gitignore +0 -3
- package/lib/socket-io/package.json +0 -75
- package/lib/socket-io/spec/index.ts +0 -57
- package/lib/socket-io/spec/loadEnv.ts +0 -10
- package/lib/socket-io/spec/nodemon.json +0 -6
- package/lib/socket-io/spec/support/jasmine.json +0 -11
- package/lib/socket-io/spec/support/login-agent.ts +0 -49
- package/lib/socket-io/spec/tests/auth.spec.ts +0 -159
- package/lib/socket-io/spec/tests/chat.spec.ts +0 -150
- package/lib/socket-io/spec/tests/users.spec.ts +0 -283
- package/lib/socket-io/src/index.ts +0 -14
- package/lib/socket-io/src/models/user-model.ts +0 -56
- package/lib/socket-io/src/pre-start/env/development.env +0 -23
- package/lib/socket-io/src/pre-start/env/production.env +0 -24
- package/lib/socket-io/src/pre-start/env/test.env +0 -23
- package/lib/socket-io/src/pre-start/index.ts +0 -28
- package/lib/socket-io/src/public/scripts/chat.js +0 -87
- package/lib/socket-io/src/public/scripts/http.js +0 -24
- package/lib/socket-io/src/public/scripts/index.js +0 -16
- package/lib/socket-io/src/public/scripts/login.js +0 -17
- package/lib/socket-io/src/public/scripts/users.js +0 -148
- package/lib/socket-io/src/public/stylesheets/chat.css +0 -43
- package/lib/socket-io/src/public/stylesheets/index.css +0 -13
- package/lib/socket-io/src/public/stylesheets/login.css +0 -20
- package/lib/socket-io/src/public/stylesheets/users.css +0 -40
- package/lib/socket-io/src/repos/database.json +0 -38
- package/lib/socket-io/src/repos/mock-orm.ts +0 -41
- package/lib/socket-io/src/repos/user-repo.ts +0 -88
- package/lib/socket-io/src/routes/api.ts +0 -19
- package/lib/socket-io/src/routes/chat-router.ts +0 -97
- package/lib/socket-io/src/routes/middleware.ts +0 -55
- package/lib/socket-io/src/routes/user-router.ts +0 -77
- package/lib/socket-io/src/server.ts +0 -100
- package/lib/socket-io/src/services/auth-service.ts +0 -38
- package/lib/socket-io/src/services/user-service.ts +0 -52
- package/lib/socket-io/src/shared/env-vars.ts +0 -20
- package/lib/socket-io/src/shared/errors.ts +0 -56
- package/lib/socket-io/src/shared/functions.ts +0 -18
- package/lib/socket-io/src/types/express/index.d.ts +0 -34
- package/lib/socket-io/src/views/chat.html +0 -51
- package/lib/socket-io/src/views/login.html +0 -35
- package/lib/socket-io/src/views/users.html +0 -47
- package/lib/socket-io/tsconfig.json +0 -100
- package/lib/socket-io/tsconfig.prod.json +0 -11
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
-
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
"outDir": "dist", /* Redirect output structure to the directory. */
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
-
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
|
|
43
|
-
/* Module Resolution Options */
|
|
44
|
-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
-
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
47
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
48
|
-
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
49
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
50
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
51
|
-
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
52
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
53
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
54
|
-
|
|
55
|
-
/* Source Map Options */
|
|
56
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
57
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
58
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
59
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
60
|
-
|
|
61
|
-
/* Experimental Options */
|
|
62
|
-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
63
|
-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
64
|
-
|
|
65
|
-
/* Advanced Options */
|
|
66
|
-
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
67
|
-
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
68
|
-
"paths": {
|
|
69
|
-
"@repos/*": [
|
|
70
|
-
"src/repos/*"
|
|
71
|
-
],
|
|
72
|
-
"@models/*": [
|
|
73
|
-
"src/models/*"
|
|
74
|
-
],
|
|
75
|
-
"@shared/*": [
|
|
76
|
-
"src/shared/*"
|
|
77
|
-
],
|
|
78
|
-
"@server": [
|
|
79
|
-
"src/server"
|
|
80
|
-
],
|
|
81
|
-
"@services/*": [
|
|
82
|
-
"src/services/*"
|
|
83
|
-
],
|
|
84
|
-
"@routes/*": [
|
|
85
|
-
"src/routes/*"
|
|
86
|
-
],
|
|
87
|
-
"@util/*": [
|
|
88
|
-
"src/util/*"
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
"useUnknownInCatchVariables": false
|
|
92
|
-
},
|
|
93
|
-
"include": [
|
|
94
|
-
"src/**/*.ts",
|
|
95
|
-
"spec/**/*.ts"
|
|
96
|
-
],
|
|
97
|
-
"exclude": [
|
|
98
|
-
"src/public/"
|
|
99
|
-
]
|
|
100
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
// ***** Start **** //
|
|
2
|
-
|
|
3
|
-
displayUsers();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// **** Fetch and display users **** //
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Call api
|
|
10
|
-
*/
|
|
11
|
-
function displayUsers() {
|
|
12
|
-
httpGet('/api/users/all')
|
|
13
|
-
.then(resp => resp.json())
|
|
14
|
-
.then((resp) => {
|
|
15
|
-
var allUsers = resp.users;
|
|
16
|
-
// Empty the anchor
|
|
17
|
-
var allUsersAnchor = document.getElementById('all-users-anchor');
|
|
18
|
-
allUsersAnchor.innerHTML = '';
|
|
19
|
-
// Append users to anchor
|
|
20
|
-
allUsers.forEach((user) => {
|
|
21
|
-
allUsersAnchor.innerHTML += getUserDisplayEle(user);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get the user display element
|
|
28
|
-
*/
|
|
29
|
-
function getUserDisplayEle(user) {
|
|
30
|
-
return (
|
|
31
|
-
`<div class="user-display-ele">
|
|
32
|
-
|
|
33
|
-
<div class="normal-view">
|
|
34
|
-
<div>
|
|
35
|
-
Name: ${user.name}
|
|
36
|
-
</div>
|
|
37
|
-
<div>
|
|
38
|
-
Email: ${user.email}
|
|
39
|
-
</div>
|
|
40
|
-
<button class="edit-user-btn" data-user-id="${user.id}">
|
|
41
|
-
Edit
|
|
42
|
-
</button>
|
|
43
|
-
<button class="delete-user-btn" data-user-id="${user.id}">
|
|
44
|
-
Delete
|
|
45
|
-
</button>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<div class="edit-view">
|
|
49
|
-
<div>
|
|
50
|
-
Name: <input class="name-edit-input" value="${user.name}" />
|
|
51
|
-
</div>
|
|
52
|
-
<div>
|
|
53
|
-
Email: <input class="email-edit-input" value="${user.email}" />
|
|
54
|
-
</div>
|
|
55
|
-
<button class="submit-edit-btn" data-user-id="${user.id}">
|
|
56
|
-
Submit
|
|
57
|
-
</button>
|
|
58
|
-
<button class="cancel-edit-btn" data-user-id="${user.id}">
|
|
59
|
-
Cancel
|
|
60
|
-
</button>
|
|
61
|
-
</div>
|
|
62
|
-
</div>`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// **** Add, Edit, and Delete Users **** //
|
|
68
|
-
|
|
69
|
-
// Add event listeners
|
|
70
|
-
document.addEventListener('click', (event) => {
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
var ele = event.target;
|
|
73
|
-
if (ele.matches('#add-user-btn')) {
|
|
74
|
-
addUser();
|
|
75
|
-
} else if (ele.matches('.edit-user-btn')) {
|
|
76
|
-
showEditView(ele.parentNode.parentNode);
|
|
77
|
-
} else if (ele.matches('.cancel-edit-btn')) {
|
|
78
|
-
cancelEdit(ele.parentNode.parentNode);
|
|
79
|
-
} else if (ele.matches('.submit-edit-btn')) {
|
|
80
|
-
submitEdit(ele);
|
|
81
|
-
} else if (ele.matches('.delete-user-btn')) {
|
|
82
|
-
deleteUser(ele);
|
|
83
|
-
}
|
|
84
|
-
}, false);
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Add a new user
|
|
88
|
-
*/
|
|
89
|
-
function addUser() {
|
|
90
|
-
var nameInput = document.getElementById('name-input');
|
|
91
|
-
var emailInput = document.getElementById('email-input');
|
|
92
|
-
var data = {
|
|
93
|
-
user: {
|
|
94
|
-
name: nameInput.value,
|
|
95
|
-
email: emailInput.value,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
httpPost('/api/users/add', data)
|
|
99
|
-
.then(() => displayUsers());
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Show edit view
|
|
104
|
-
*/
|
|
105
|
-
function showEditView(userEle) {
|
|
106
|
-
var normalView = userEle.getElementsByClassName('normal-view')[0];
|
|
107
|
-
var editView = userEle.getElementsByClassName('edit-view')[0];
|
|
108
|
-
normalView.style.display = 'none';
|
|
109
|
-
editView.style.display = 'block';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Cancel edit
|
|
114
|
-
*/
|
|
115
|
-
function cancelEdit(userEle) {
|
|
116
|
-
var normalView = userEle.getElementsByClassName('normal-view')[0];
|
|
117
|
-
var editView = userEle.getElementsByClassName('edit-view')[0];
|
|
118
|
-
normalView.style.display = 'block';
|
|
119
|
-
editView.style.display = 'none';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Submit edit
|
|
124
|
-
*/
|
|
125
|
-
function submitEdit(ele) {
|
|
126
|
-
var userEle = ele.parentNode.parentNode;
|
|
127
|
-
var nameInput = userEle.getElementsByClassName('name-edit-input')[0];
|
|
128
|
-
var emailInput = userEle.getElementsByClassName('email-edit-input')[0];
|
|
129
|
-
var id = ele.getAttribute('data-user-id');
|
|
130
|
-
var data = {
|
|
131
|
-
user: {
|
|
132
|
-
name: nameInput.value,
|
|
133
|
-
email: emailInput.value,
|
|
134
|
-
id: Number(id),
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
// Call api
|
|
138
|
-
httpPut('/api/users/update', data)
|
|
139
|
-
.then(() => displayUsers());
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Delete user.
|
|
144
|
-
*/
|
|
145
|
-
function deleteUser(ele) {
|
|
146
|
-
var id = ele.getAttribute('data-user-id');
|
|
147
|
-
httpDelete('/api/users/delete/' + id)
|
|
148
|
-
.then(() => displayUsers());
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// **** Http options **** //
|
|
153
|
-
|
|
154
|
-
function httpGet(path) {
|
|
155
|
-
return fetch(path, getOptions('GET'))
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function httpPost(path, data) {
|
|
159
|
-
return fetch(path, getOptions('POST', data));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function httpPut(path, data) {
|
|
163
|
-
return fetch(path, getOptions('PUT', data));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function httpDelete(path) {
|
|
167
|
-
return fetch(path, getOptions('DELETE'));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function getOptions(verb, data) {
|
|
171
|
-
var options = {
|
|
172
|
-
dataType: 'json',
|
|
173
|
-
method: verb,
|
|
174
|
-
headers: {
|
|
175
|
-
'Accept': 'application/json',
|
|
176
|
-
'Content-Type': 'application/json',
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
if (data) {
|
|
180
|
-
options.body = JSON.stringify(data);
|
|
181
|
-
}
|
|
182
|
-
return options;
|
|
183
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
padding: 100px;
|
|
3
|
-
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
body .users-column {
|
|
7
|
-
display: inline-block;
|
|
8
|
-
margin-right: 2em;
|
|
9
|
-
vertical-align: top;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
body .users-column .column-header {
|
|
13
|
-
padding-bottom: 5px;
|
|
14
|
-
font-weight: 700;
|
|
15
|
-
font-size: 1.2em;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
body .add-user-col input {
|
|
19
|
-
margin-bottom: 10px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
body .users-column .user-display-ele {
|
|
23
|
-
padding-bottom: 10px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
body .users-column .user-display-ele button {
|
|
27
|
-
margin-top: 2px;
|
|
28
|
-
margin-bottom: 10px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
body .users-column .user-display-ele .edit-view {
|
|
32
|
-
display: none;
|
|
33
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>ExpressGeneratorTypeScriptApp</title>
|
|
6
|
-
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css" />
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
|
|
10
|
-
<!-- Add Users -->
|
|
11
|
-
<div class="users-column add-user-col">
|
|
12
|
-
<div class="column-header">Add User:</div>
|
|
13
|
-
<div>
|
|
14
|
-
<input id="name-input" placeholder="Name">
|
|
15
|
-
</div>
|
|
16
|
-
<div>
|
|
17
|
-
<input id="email-input" placeholder="Email">
|
|
18
|
-
</div>
|
|
19
|
-
<div>
|
|
20
|
-
<button id="add-user-btn">Add</button>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<!-- Display Users -->
|
|
25
|
-
<div class="users-column">
|
|
26
|
-
<div class="column-header">Users:</div>
|
|
27
|
-
<div id="all-users-anchor"></div>
|
|
28
|
-
</div>
|
|
29
|
-
</body>
|
|
30
|
-
<script src="scripts/index.js"></script>
|
|
31
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
src/public/
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parser": "@typescript-eslint/parser",
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@typescript-eslint"
|
|
5
|
-
],
|
|
6
|
-
"extends": [
|
|
7
|
-
"eslint:recommended",
|
|
8
|
-
"plugin:@typescript-eslint/recommended",
|
|
9
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
10
|
-
],
|
|
11
|
-
"parserOptions": {
|
|
12
|
-
"project": "./tsconfig.json"
|
|
13
|
-
},
|
|
14
|
-
"rules": {
|
|
15
|
-
"max-len": [
|
|
16
|
-
"error",
|
|
17
|
-
{
|
|
18
|
-
"code": 100
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"no-console": 1,
|
|
22
|
-
"no-extra-boolean-cast": 0,
|
|
23
|
-
"semi": 1,
|
|
24
|
-
"@typescript-eslint/no-misused-promises": 0,
|
|
25
|
-
"@typescript-eslint/no-floating-promises": 0
|
|
26
|
-
}
|
|
27
|
-
}
|
package/lib/socket-io/build.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remove old files, copy front-end ones.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import fs from 'fs-extra';
|
|
6
|
-
import logger from 'jet-logger';
|
|
7
|
-
import childProcess from 'child_process';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Start
|
|
11
|
-
(async () => {
|
|
12
|
-
try {
|
|
13
|
-
// Remove current build
|
|
14
|
-
await remove('./dist/');
|
|
15
|
-
// Copy front-end files
|
|
16
|
-
await copy('./src/public', './dist/public');
|
|
17
|
-
await copy('./src/views', './dist/views');
|
|
18
|
-
// Copy production env file
|
|
19
|
-
await copy('./src/pre-start/env/production.env', './dist/pre-start/env/production.env');
|
|
20
|
-
// Copy back-end files
|
|
21
|
-
await exec('tsc --build tsconfig.prod.json', './');
|
|
22
|
-
} catch (err) {
|
|
23
|
-
logger.err(err);
|
|
24
|
-
}
|
|
25
|
-
})();
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Remove file
|
|
29
|
-
*/
|
|
30
|
-
function remove(loc: string): Promise<void> {
|
|
31
|
-
return new Promise((res, rej) => {
|
|
32
|
-
return fs.remove(loc, (err) => {
|
|
33
|
-
return (!!err ? rej(err) : res());
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Copy file.
|
|
40
|
-
*/
|
|
41
|
-
function copy(src: string, dest: string): Promise<void> {
|
|
42
|
-
return new Promise((res, rej) => {
|
|
43
|
-
return fs.copy(src, dest, (err) => {
|
|
44
|
-
return (!!err ? rej(err) : res());
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Do command line command.
|
|
51
|
-
*/
|
|
52
|
-
function exec(cmd: string, loc: string): Promise<void> {
|
|
53
|
-
return new Promise((res, rej) => {
|
|
54
|
-
return childProcess.exec(cmd, {cwd: loc}, (err, stdout, stderr) => {
|
|
55
|
-
if (!!stdout) {
|
|
56
|
-
logger.info(stdout);
|
|
57
|
-
}
|
|
58
|
-
if (!!stderr) {
|
|
59
|
-
logger.warn(stderr);
|
|
60
|
-
}
|
|
61
|
-
return (!!err ? rej(err) : res());
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
package/lib/socket-io/gitignore
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "socket-io",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"scripts": {
|
|
5
|
-
"build": "npx ts-node build.ts",
|
|
6
|
-
"lint": "eslint . --ext .ts",
|
|
7
|
-
"start": "node -r module-alias/register ./dist --env=production",
|
|
8
|
-
"dev": "nodemon",
|
|
9
|
-
"test": "nodemon --config ./spec/nodemon.json",
|
|
10
|
-
"test:no-reloading": "npx ts-node --files -r tsconfig-paths/register ./spec"
|
|
11
|
-
},
|
|
12
|
-
"nodemonConfig": {
|
|
13
|
-
"watch": [
|
|
14
|
-
"src"
|
|
15
|
-
],
|
|
16
|
-
"ext": "ts, html",
|
|
17
|
-
"ignore": [
|
|
18
|
-
"src/public"
|
|
19
|
-
],
|
|
20
|
-
"exec": "./node_modules/.bin/ts-node --files -r tsconfig-paths/register ./src"
|
|
21
|
-
},
|
|
22
|
-
"_moduleAliases": {
|
|
23
|
-
"@services": "dist/services",
|
|
24
|
-
"@repos": "dist/repos",
|
|
25
|
-
"@entities": "dist/entities",
|
|
26
|
-
"@shared": "dist/shared",
|
|
27
|
-
"@server": "dist/server",
|
|
28
|
-
"@routes": "dist/routes",
|
|
29
|
-
"@util": "dist/util"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"bcrypt": "^5.0.1",
|
|
33
|
-
"command-line-args": "^5.2.1",
|
|
34
|
-
"cookie-parser": "^1.4.6",
|
|
35
|
-
"dotenv": "^16.0.2",
|
|
36
|
-
"express": "^4.18.1",
|
|
37
|
-
"express-async-errors": "^3.1.1",
|
|
38
|
-
"helmet": "^6.0.0",
|
|
39
|
-
"http-status-codes": "^2.2.0",
|
|
40
|
-
"jet-logger": "^1.2.3",
|
|
41
|
-
"jsonfile": "^6.1.0",
|
|
42
|
-
"jsonwebtoken": "^8.5.1",
|
|
43
|
-
"module-alias": "^2.2.2",
|
|
44
|
-
"morgan": "^1.10.0",
|
|
45
|
-
"randomstring": "^1.2.2",
|
|
46
|
-
"socket.io": "^4.5.1",
|
|
47
|
-
"socket.io-client": "^4.5.1"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@types/bcrypt": "^5.0.0",
|
|
51
|
-
"@types/command-line-args": "^5.2.0",
|
|
52
|
-
"@types/cookie-parser": "^1.4.3",
|
|
53
|
-
"@types/express": "^4.17.13",
|
|
54
|
-
"@types/find": "^0.2.1",
|
|
55
|
-
"@types/fs-extra": "^9.0.13",
|
|
56
|
-
"@types/jasmine": "^4.3.0",
|
|
57
|
-
"@types/jsonfile": "^6.1.0",
|
|
58
|
-
"@types/jsonwebtoken": "^8.5.9",
|
|
59
|
-
"@types/morgan": "^1.9.3",
|
|
60
|
-
"@types/node": "^18.7.14",
|
|
61
|
-
"@types/randomstring": "^1.1.8",
|
|
62
|
-
"@types/supertest": "^2.0.12",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
|
64
|
-
"@typescript-eslint/parser": "^5.36.1",
|
|
65
|
-
"eslint": "^8.23.0",
|
|
66
|
-
"find": "^0.3.0",
|
|
67
|
-
"fs-extra": "^10.1.0",
|
|
68
|
-
"jasmine": "^4.3.0",
|
|
69
|
-
"nodemon": "^2.0.19",
|
|
70
|
-
"supertest": "^6.2.4",
|
|
71
|
-
"ts-node": "^10.9.1",
|
|
72
|
-
"tsconfig-paths": "^4.1.0",
|
|
73
|
-
"typescript": "^4.8.2"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import './loadEnv';
|
|
2
|
-
import find from 'find';
|
|
3
|
-
import Jasmine from 'jasmine';
|
|
4
|
-
import commandLineArgs from 'command-line-args';
|
|
5
|
-
import logger from 'jet-logger';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Setup command line options
|
|
9
|
-
const options = commandLineArgs([
|
|
10
|
-
{
|
|
11
|
-
name: 'testFile',
|
|
12
|
-
alias: 'f',
|
|
13
|
-
type: String,
|
|
14
|
-
},
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
// Init Jasmine
|
|
18
|
-
const jasmine = new Jasmine();
|
|
19
|
-
jasmine.exitOnCompletion = false;
|
|
20
|
-
|
|
21
|
-
// Set location of test files
|
|
22
|
-
jasmine.loadConfig({
|
|
23
|
-
random: true,
|
|
24
|
-
spec_dir: 'spec',
|
|
25
|
-
spec_files: [
|
|
26
|
-
'./tests/**/*.spec.ts',
|
|
27
|
-
],
|
|
28
|
-
stopSpecOnExpectationFailure: false,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Run all or a single unit-test
|
|
32
|
-
let execResp: Promise<jasmine.JasmineDoneInfo> | undefined;
|
|
33
|
-
if (options.testFile) {
|
|
34
|
-
const testFile = options.testFile as string;
|
|
35
|
-
find.file(testFile + '.spec.ts', './spec', (files: string[]) => {
|
|
36
|
-
if (files.length === 1) {
|
|
37
|
-
jasmine.specFiles = [files[0]];
|
|
38
|
-
jasmine.execute();
|
|
39
|
-
} else {
|
|
40
|
-
logger.err('Test file not found!');
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
execResp = jasmine.execute();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Wait for tests to finish
|
|
48
|
-
(async () => {
|
|
49
|
-
if (!!execResp) {
|
|
50
|
-
const info = await execResp;
|
|
51
|
-
if (info.overallStatus === 'passed') {
|
|
52
|
-
logger.info('All tests have passed :)');
|
|
53
|
-
} else {
|
|
54
|
-
logger.err('At least one test has failed :(');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
})();
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import bcrypt from 'bcrypt';
|
|
2
|
-
import { SuperTest, Test } from 'supertest';
|
|
3
|
-
|
|
4
|
-
import User, { UserRoles } from '@models/user-model';
|
|
5
|
-
import userRepo from '@repos/user-repo';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// **** Variables **** //
|
|
9
|
-
|
|
10
|
-
export const pwdSaltRounds = 12;
|
|
11
|
-
|
|
12
|
-
const creds = {
|
|
13
|
-
email: 'jsmith@gmail.com',
|
|
14
|
-
password: 'Password@1',
|
|
15
|
-
name: 'john smith',
|
|
16
|
-
} as const;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// **** Functions **** //
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Login a user
|
|
23
|
-
*/
|
|
24
|
-
function login(beforeAgent: SuperTest<Test>, done: (arg: string) => void) {
|
|
25
|
-
// Setup dummy data
|
|
26
|
-
const role = UserRoles.Admin;
|
|
27
|
-
const pwdHash = bcrypt.hashSync(creds.password, pwdSaltRounds);
|
|
28
|
-
const loginUser = User.new(creds.name, creds.email, role, pwdHash);
|
|
29
|
-
spyOn(userRepo, 'getOne').and.returnValue(Promise.resolve(loginUser));
|
|
30
|
-
// Call Login API
|
|
31
|
-
beforeAgent
|
|
32
|
-
.post('/api/auth/login')
|
|
33
|
-
.type('form')
|
|
34
|
-
.send(creds)
|
|
35
|
-
.end((err: Error, res: any) => {
|
|
36
|
-
if (err) {
|
|
37
|
-
throw err;
|
|
38
|
-
}
|
|
39
|
-
done(res.headers['set-cookie']);
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// **** Export default **** //
|
|
45
|
-
|
|
46
|
-
export default {
|
|
47
|
-
creds,
|
|
48
|
-
login,
|
|
49
|
-
} as const;
|