Skip to content

Commit d29a2e6

Browse files
committed
🏷️ Global and request types extension
1 parent 9f9b1ac commit d29a2e6

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
import { Document, Model } from 'mongoose';
3+
import { IUser } from '../../interfaces/IUser';
4+
declare global {
5+
namespace Express {
6+
export interface Request {
7+
currentUser: IUser & Document;
8+
token: string;
9+
}
10+
}
11+
12+
namespace Models {
13+
export type UserModel = Model<IUser & Document>;
14+
}
15+
}

apps/api/src/app/types/global.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare namespace NodeJS {
2+
interface Global {
3+
__basedir: string;
4+
}
5+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
import * as dotenv from 'dotenv';
2+
const envFound = dotenv.config();
3+
if (envFound.error) {
4+
throw new Error(envFound.error.toString())
5+
}
6+
17
export const environment = {
28
production: true,
9+
port: parseInt(process.env.PORT, 10),
10+
databaseURL: process.env.MONGODB_URI,
11+
appSecret: process.env.SECRET,
12+
api: {
13+
prefix_v1: '/api/v1',
14+
},
15+
OAuth2: {
16+
clientId: process.env.CLIENT_ID,
17+
clientSecret: process.env.CLIENT_SECRET,
18+
},
19+
logs: {
20+
level: process.env.LOG_LEVEL || 'silly',
21+
},
22+
/**
23+
* Agenda.js stuff
24+
*/
25+
agenda: {
26+
dbCollection: process.env.AGENDA_DB_COLLECTION,
27+
pooltime: process.env.AGENDA_POOL_TIME,
28+
concurrency: parseInt(process.env.AGENDA_CONCURRENCY, 10),
29+
},
30+
agendash: {
31+
user: 'admin',
32+
password: 'admin',
33+
},
334
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
import * as dotenv from 'dotenv';
2+
const envFound = dotenv.config();
3+
if(envFound.error) {
4+
throw new Error(envFound.error.toString())
5+
}
6+
17
export const environment = {
28
production: false,
9+
port: parseInt(process.env.PORT, 10),
10+
databaseURL: process.env.MONGODB_URI,
11+
appSecret: process.env.SECRET,
12+
api: {
13+
prefix_v1: '/api/v1',
14+
},
15+
OAuth2: {
16+
clientId: process.env.CLIENT_ID,
17+
clientSecret: process.env.CLIENT_SECRET,
18+
},
19+
logs: {
20+
level: process.env.LOG_LEVEL || 'silly',
21+
},
22+
/**
23+
* Agenda.js stuff
24+
*/
25+
agenda: {
26+
dbCollection: process.env.AGENDA_DB_COLLECTION,
27+
pooltime: process.env.AGENDA_POOL_TIME,
28+
concurrency: parseInt(process.env.AGENDA_CONCURRENCY, 10),
29+
},
30+
agendash: {
31+
user: 'admin',
32+
password: 'admin',
33+
},
334
};

0 commit comments

Comments
 (0)