Skip to content

Commit

Permalink
Merge pull request #8 from phongoli0/dev
Browse files Browse the repository at this point in the history
build
  • Loading branch information
phongoli0 committed Aug 22, 2019
2 parents 1a171e6 + 51b38aa commit 5d1467e
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions server/index.js
@@ -1,16 +1,30 @@
// const path = require('path');
// const express = require('express');
// const jsonServer = require('json-server');

// const dbPath = path.resolve(__dirname, '../database/db.json');
// const server = jsonServer.create();
// const endpoints = jsonServer.router(dbPath);
// const PORT = process.env.PORT;

// server.use(express.json());
// server.use(express.static(path.join(__dirname, 'public')));
// server.use('/api', endpoints);
// server.listen(PORT, () => {
// // eslint-disable-next-line no-console
// console.log('JSON Server listening on port', PORT);
// });
const path = require('path');
const express = require('express');
const jsonServer = require('json-server');

const dbPath = path.resolve(__dirname, '../database/db.json');
const server = jsonServer.create();
const middleware = jsonServer.defaults();
const endpoints = jsonServer.router(dbPath);
const PORT = process.env.PORT;

server.use(express.json());
server.use(express.static(path.join(__dirname, 'public')));
server.use(middleware);
server.use('/api', endpoints);
server.listen(PORT, () => {
server.listen(3001, () => {
// eslint-disable-next-line no-console
console.log('JSON Server listening on port', PORT);
console.log('JSON Server listening on port 3001\n');
});

0 comments on commit 5d1467e

Please sign in to comment.