-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
48 lines (37 loc) · 1.5 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import express, { Express } from 'express';
import cors from 'cors';
import { initializeApp } from 'firebase/app';
import { CONFIG } from './config';
import { setupProxies } from './src/middlewares/proxy';
import { ROUTES } from './src/globals/routes';
import bodyParser from 'body-parser';
import { RegisterDriver, RegisterPassenger } from './src/controllers/register';
import { LoginUserWithEmailAndPassword, LoginAdministratorWithEmailAndPassword } from './src/controllers/login';
import { Welcome } from './src/controllers/welcome';
console.log(CONFIG.microservices.users.basePath)
const app: Express = express();
const corsOptions = {
origin: '*',
optionsSuccessStatus: 200
};
const firebaseConfig = {
apiKey: CONFIG.firebase.apiKey,
authDomain: CONFIG.firebase.authDomain,
projectId: CONFIG.firebase.projectId,
storageBucket: CONFIG.firebase.storageBucket,
messagingSenderId: CONFIG.firebase.messagingSenderId,
appId: CONFIG.firebase.appId,
measurementId: CONFIG.firebase.measurementId
};
app.use(cors(corsOptions));
initializeApp(firebaseConfig);
setupProxies(app, ROUTES);
app.use(bodyParser.json());
app.post('/api/auth/register-passenger', RegisterPassenger);
app.post('/api/auth/register-driver', RegisterDriver);
app.get('/api/auth/login', LoginUserWithEmailAndPassword);
app.get('/api/auth/administrator/login', LoginAdministratorWithEmailAndPassword);
app.get('/', Welcome);
app.listen(CONFIG.app.port, () => {
console.log(`⚡️[server]: Server is running at port ${CONFIG.app.port}`);
});