-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (27 loc) · 990 Bytes
/
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
//import express from 'express';
const express = require('express');
//import bodyParser from 'body-parser';
const bodyParser = require('body-parser');
//import todoRouter from './src/routes/toDoRoutes.js';
const todoRouter = require('./src/routes/toDoRoutes.js');
//Access-Control-Allow-Origin: http://localhost:3000;
/**
*when importing use filename.js otherwise wont work
*/
// Set up the express app
const app = express();
// Parse incoming requests data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
//router is middleware. to use it follows
app.get('/', function(req, res) {
// const customers=[
// {id:1, firstName:'John', lastName:'Doe'},
// {id:2, firstName:'Jo', lastName:'Do'}
// ];
// res.json(customers);
res.send({'name':'jayamoathi'});
});
app.use(todoRouter);
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`url-shortener listening on port ${port}!`));