forked from A2Z-hq/a2z-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 879 Bytes
/
index.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
const express = require('express');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const {mongoose} = require('./config/mongoose');
const CodingResources = require('./models/coding');
const api = require('./routes/api');
// Defining port for server
var port = process.env.PORT || 3001
//Initialise express app
const app = express()
// parser request of content type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended : true}))
app.use(bodyParser.json())
app.use(morgan('dev'));
//Test API
app.get('/test', (req, res)=>{
res.json({ "message" : "API is working"});
});
app.get('/', (req, res)=>{
res.json({ "message" : "Welcome to A2Z Resources backend"})
});
//Initialise the routes
app.use('/', api);
// start the server
app.listen(port, () => {
console.log("Server is listening on port: " + port)
});