-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
49 lines (42 loc) · 1.36 KB
/
main.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
49
import connectFlash from 'connect-flash';
import express from 'express';
import * as Helpers from "./app/base/helpers";
import middlewiare from './app/middleware/middleware';
import apiRouter from './app/routes/api';
import authRouter from './app/routes/auth';
import publicRouter from './app/routes/public';
import config from './config/config';
import filesconfig from './config/filesconfig';
import { User } from './models/User';
// Assigning helpers to the global object
Object.assign(global, Helpers);
const app = express();
//app setup
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(filesconfig.public_path || 'public'))
//set views engine and path
config.view_engine && app.set('view engine', config.view_engine)
config.view_path && app.set('views', config.view_path)
//third party express libraries
// app.use(session(config.session.express));
app.use(connectFlash());
//register routes
app.use(authRouter)
app.use('/api/v1', apiRouter)
app.use(publicRouter)
// main();
console.log('database: ', env('DB_DATABASE'))
async function main() {
const insert = await User.insert({
first_name: 'Saeed',
email: Date.now() + '@gmail.com',
})
console.log(insert)
}
//middleware
app.use(middlewiare)
app.listen(3030, () => {
// console.clear()
console.log('Server url: ', 'http://localhost:3030')
})