express-generator-typescript 2.0.7 → 2.0.9

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.
@@ -15,7 +15,7 @@ import { UnauthorizedError } from '@shared/errors';
15
15
  // **** Variables **** //
16
16
 
17
17
  // Misc
18
- const authPath = '/api/auth',
18
+ const authPath = ('/api' + paths.basePath),
19
19
  loginPath = `${authPath}${paths.login}`,
20
20
  logoutPath = `${authPath}${paths.logout}`,
21
21
  { BAD_REQUEST, OK, UNAUTHORIZED } = StatusCodes;
@@ -14,7 +14,7 @@ import { ParamMissingError, UserNotFoundError } from '@shared/errors';
14
14
  // **** Variables **** //
15
15
 
16
16
  // Misc
17
- const usersPath = '/api/users',
17
+ const usersPath = ('/api' + userPaths.basePath),
18
18
  getUsersPath = `${usersPath}${userPaths.get}`,
19
19
  addUsersPath = `${usersPath}${userPaths.add}`,
20
20
  updateUserPath = `${usersPath}${userPaths.update}`,
@@ -1,10 +1,13 @@
1
- // **** Types **** //
1
+ // **** Variables **** //
2
2
 
3
3
  export enum UserRoles {
4
4
  Standard,
5
5
  Admin,
6
6
  }
7
7
 
8
+
9
+ // **** Types **** //
10
+
8
11
  export interface IUser {
9
12
  id: number;
10
13
  name: string;
@@ -1,15 +1,16 @@
1
1
  import { Router } from 'express';
2
2
  import { adminMw } from './middleware';
3
- import authRouter from './auth-router';
4
- import userRouter from './user-router';
3
+
4
+ import authRouter, { p as authPaths } from './auth-router';
5
+ import userRouter, { p as userPaths } from './user-router';
5
6
 
6
7
 
7
8
  // Init
8
9
  const apiRouter = Router();
9
10
 
10
11
  // Add api routes
11
- apiRouter.use('/auth', authRouter);
12
- apiRouter.use('/users', adminMw, userRouter);
12
+ apiRouter.use(authPaths.basePath, authRouter);
13
+ apiRouter.use(userPaths.basePath, adminMw, userRouter);
13
14
 
14
15
 
15
16
  // **** Export default **** //
@@ -24,6 +24,7 @@ const { OK } = StatusCodes;
24
24
 
25
25
  // Paths
26
26
  export const p = {
27
+ basePath: '/auth',
27
28
  login: '/login',
28
29
  logout: '/logout',
29
30
  } as const;
@@ -15,6 +15,7 @@ const router = Router(),
15
15
 
16
16
  // Paths
17
17
  export const p = {
18
+ basePath: '/users',
18
19
  get: '/all',
19
20
  add: '/add',
20
21
  update: '/update',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
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",