forked from opencodeiiita/SaveMyForm-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
50 lines (41 loc) · 1.35 KB
/
app.js
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
50
import express from 'express';
import morgan from 'morgan';
import bodyParser from 'body-parser';
import * as dotenv from 'dotenv';
import cors from 'cors';
import prismaDB from './config/sql.config.js';
dotenv.config();
const app = express();
app.use(cors());
// supporting content types json, urlencoded for now
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
import db from './config/db.config.js';
db();
prismaDB();
app.use(
morgan(
process.env['ENV'] === 'dev'
? '[:date[clf]] ":method :url :status" :res[content-length] - :response-time ms'
: ':remote-addr - [:date[clf]] ":method :url :status" :res[content-length] - :response-time ms',
),
);
import authRoutes from './routes/auth.routes.js';
app.use('/', authRoutes);
import formRoutes from './routes/form.routes.js';
app.use('/form', formRoutes);
import projectRoutes from './routes/project.routes.js';
app.use('/project', projectRoutes);
import userRoutes from './routes/user.routes.js';
app.use('/user', userRoutes);
import formSubmissionRoutes from './routes/formSubmission.routes.js';
app.use('/main', formSubmissionRoutes);
app.listen(
process.env.PORT ? process.env.PORT : 8080,
process.env.HOST ? process.env.HOST : '127.0.0.1',
console.log(
`listening on http://localhost:${
process.env.PORT ? process.env.PORT : 8080
}/`,
),
);