serverpreconfigured 2.1.1 → 2.1.3
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/dist/expressServer.d.ts +8 -2
- package/dist/expressServer.js +4 -1
- package/dist/users/users.d.ts +1 -0
- package/dist/users/users.js +20 -1
- package/package.json +1 -1
- package/src/expressServer.ts +8 -2
- package/src/users/users.ts +16 -0
package/dist/expressServer.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import express from "express";
|
|
3
|
+
import { Express } from "express";
|
|
4
|
+
import { Server } from "http";
|
|
1
5
|
export default class ExpressServer {
|
|
2
|
-
app:
|
|
6
|
+
app: Express;
|
|
3
7
|
authBaseUrl: string;
|
|
4
8
|
usePort: number;
|
|
9
|
+
server?: Server;
|
|
5
10
|
wsAuthBaseUrl: string;
|
|
6
11
|
constructor();
|
|
7
12
|
listen(port?: any): void;
|
|
8
13
|
initModules(): void;
|
|
9
14
|
initAuthSystem(baseUrl?: string): void;
|
|
10
15
|
initWSAuthSystem(wsBaseUrl?: string): void;
|
|
11
|
-
getApp():
|
|
16
|
+
getApp(): express.Express;
|
|
17
|
+
getServer(): Server | undefined;
|
|
12
18
|
}
|
package/dist/expressServer.js
CHANGED
|
@@ -21,7 +21,7 @@ class ExpressServer {
|
|
|
21
21
|
listen(port = null) {
|
|
22
22
|
if (port != null)
|
|
23
23
|
this.usePort = parseInt(port);
|
|
24
|
-
this.app.listen(this.usePort);
|
|
24
|
+
this.server = this.app.listen(this.usePort);
|
|
25
25
|
}
|
|
26
26
|
initModules() {
|
|
27
27
|
(0, sessions_1.initSessions)(this.app);
|
|
@@ -39,5 +39,8 @@ class ExpressServer {
|
|
|
39
39
|
getApp() {
|
|
40
40
|
return this.app;
|
|
41
41
|
}
|
|
42
|
+
getServer() {
|
|
43
|
+
return this.server;
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
exports.default = ExpressServer;
|
package/dist/users/users.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export declare function getUserIdByUserEmail(email: string): Promise<number>;
|
|
|
6
6
|
export declare function deleteUserById(id: Number): Promise<any>;
|
|
7
7
|
export declare function isUserExist(email: string): Promise<boolean>;
|
|
8
8
|
export declare function createUser(data: UserCreateInterface): Promise<any>;
|
|
9
|
+
export declare function changeUserPassword(email: string, password: string): Promise<Bluebird<T>>;
|
|
9
10
|
export declare function checkUserPassword(email: string, password_string: string): Promise<boolean>;
|
package/dist/users/users.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.checkUserPassword = exports.createUser = exports.isUserExist = exports.deleteUserById = exports.getUserIdByUserEmail = exports.getUserByEmail = exports.getUserById = exports.getUserSessionData = void 0;
|
|
12
|
+
exports.checkUserPassword = exports.changeUserPassword = exports.createUser = exports.isUserExist = exports.deleteUserById = exports.getUserIdByUserEmail = exports.getUserByEmail = exports.getUserById = exports.getUserSessionData = void 0;
|
|
13
13
|
const database_1 = require("./../database/database");
|
|
14
14
|
const User_1 = require("./../database/models/User");
|
|
15
15
|
const password_1 = require("./password");
|
|
@@ -93,6 +93,25 @@ function createUser(data) {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
exports.createUser = createUser;
|
|
96
|
+
function changeUserPassword(email, password) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
try {
|
|
99
|
+
let user = yield User_1.User.findOne({ where: { email } });
|
|
100
|
+
if (!user)
|
|
101
|
+
throw "Unknwon User";
|
|
102
|
+
let hash = yield (0, password_1.createArgon2Hash)(password);
|
|
103
|
+
if (!hash)
|
|
104
|
+
"Create Hash Error";
|
|
105
|
+
user.password_hash = hash;
|
|
106
|
+
yield user.save();
|
|
107
|
+
return user;
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.changeUserPassword = changeUserPassword;
|
|
96
115
|
function checkUserPassword(email, password_string) {
|
|
97
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
117
|
let user;
|
package/package.json
CHANGED
package/src/expressServer.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
+
import { Express } from "express";
|
|
2
3
|
import { initSessions } from "./modules/sessions";
|
|
3
4
|
import { initPostReader } from "./modules/postreader";
|
|
4
5
|
import { initCors } from "./modules/initcors";
|
|
5
6
|
import ENV from "./settings/env";
|
|
6
7
|
import authRouter from "./routes/users";
|
|
7
8
|
import { router as wsAuthRoter } from "./routes/wsauth";
|
|
9
|
+
import { Server } from "http";
|
|
8
10
|
export default class ExpressServer{
|
|
9
|
-
app:
|
|
11
|
+
app:Express;
|
|
10
12
|
authBaseUrl:string;
|
|
11
13
|
usePort:number;
|
|
14
|
+
server?:Server;
|
|
12
15
|
wsAuthBaseUrl:string;
|
|
13
16
|
constructor(){
|
|
14
17
|
this.authBaseUrl="";
|
|
@@ -20,7 +23,7 @@ export default class ExpressServer{
|
|
|
20
23
|
listen(port:any=null){
|
|
21
24
|
if(port!=null)
|
|
22
25
|
this.usePort=parseInt(port);
|
|
23
|
-
this.app.listen(this.usePort);
|
|
26
|
+
this.server=this.app.listen(this.usePort);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
initModules(){
|
|
@@ -40,4 +43,7 @@ export default class ExpressServer{
|
|
|
40
43
|
getApp(){
|
|
41
44
|
return this.app;
|
|
42
45
|
}
|
|
46
|
+
getServer(){
|
|
47
|
+
return this.server;
|
|
48
|
+
}
|
|
43
49
|
}
|
package/src/users/users.ts
CHANGED
|
@@ -64,6 +64,22 @@ export async function createUser(data:UserCreateInterface):Promise<any>{
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export async function changeUserPassword(email:string,password:string){
|
|
68
|
+
try{
|
|
69
|
+
let user=await User.findOne({where:{email}});
|
|
70
|
+
if(!user)
|
|
71
|
+
throw "Unknwon User";
|
|
72
|
+
let hash=await createArgon2Hash(password);
|
|
73
|
+
if(!hash)
|
|
74
|
+
"Create Hash Error";
|
|
75
|
+
user.password_hash=hash;
|
|
76
|
+
await user.save();
|
|
77
|
+
return user;
|
|
78
|
+
}catch(e){
|
|
79
|
+
throw e;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
67
83
|
export async function checkUserPassword(email:string,password_string:string):Promise<boolean>{
|
|
68
84
|
let user;
|
|
69
85
|
try{
|