express-generator-typescript 2.0.1 → 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/lib/project-files/src/routes/auth-router.ts +1 -1
- package/lib/project-files/src/routes/user-router.ts +1 -1
- package/lib/project-files/src/services/auth-service.ts +1 -1
- package/lib/project-files/src/shared/types.ts +14 -0
- package/lib/project-files/src/types/express/index.d.ts +0 -14
- package/lib/project-files/src/util/jwt-util.ts +2 -2
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import StatusCodes from 'http-status-codes';
|
|
|
4
4
|
import authService from '@services/auth-service';
|
|
5
5
|
import { ParamMissingError } from '@shared/errors';
|
|
6
6
|
import envVars from 'src/shared/env-vars';
|
|
7
|
-
import { IReq } from '
|
|
7
|
+
import { IReq } from '@shared/types';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
// **** Types **** //
|
|
@@ -4,7 +4,7 @@ import { Request, Response, Router } from 'express';
|
|
|
4
4
|
import userService from '@services/user-service';
|
|
5
5
|
import { ParamMissingError } from '@shared/errors';
|
|
6
6
|
import { IUser } from '@models/user-model';
|
|
7
|
-
import { IReq } from '
|
|
7
|
+
import { IReq } from '@shared/types';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
// **** Variables **** //
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as e from 'express';
|
|
2
|
+
import { Query } from 'express-serve-static-core';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// **** Generics for Request Object **** //
|
|
6
|
+
|
|
7
|
+
export interface IReq<T> extends e.Request {
|
|
8
|
+
body: T;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IReqQuery<T extends Query, U = void> extends e.Request {
|
|
12
|
+
query: T;
|
|
13
|
+
body: U;
|
|
14
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import * as e from 'express';
|
|
3
|
-
import { Query } from 'express-serve-static-core';
|
|
4
2
|
|
|
5
3
|
import { ISessionUser } from '@routes/middleware';
|
|
6
4
|
|
|
@@ -20,15 +18,3 @@ declare module 'express' {
|
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// **** Generics for Request Object **** //
|
|
26
|
-
|
|
27
|
-
export interface IReq<T> extends e.Request {
|
|
28
|
-
body: T;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface IReqQuery<T extends Query, U = void> extends e.Request {
|
|
32
|
-
query: T;
|
|
33
|
-
body?: U;
|
|
34
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import jsonwebtoken
|
|
1
|
+
import jsonwebtoken from 'jsonwebtoken';
|
|
2
2
|
import envVars from '../shared/env-vars';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ const options = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Encrypt data and return jwt.
|
|
22
22
|
*/
|
|
23
|
-
function sign(data:
|
|
23
|
+
function sign(data: string | object | Buffer): Promise<string> {
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
jsonwebtoken.sign(data, envVars.jwt.secret, options, (err, token) => {
|
|
26
26
|
return err ? reject(err) : resolve(token || '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Generate new Express applications similar to express-generate which but sets it up to use TypeScript instead",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"express-generator-typescript": "node bin/cli.js",
|