Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Express Server*/
- const express = require('express');
- const app = express();
- const morgan = require('morgan');
- const path = require('path');
- const bodyParser = require('body-parser');
- const { mongoose } = require('./database');
- //settings
- app.set('port', process.env.PORT || 3000);
- //middleware
- app.use(morgan('dev'));
- app.use(bodyParser.urlencoded({ extended: true }));
- app.use(bodyParser.json());
- //routes
- app.use('/api/month',require('./routes/monthly.routes'));
- app.use('/history',require('./routes/history.routes'));
- //static files
- app.use(express.static(path.join(__dirname, 'public')))
- app.get(async (req,res)=>{
- await res.sendFile(path.join(__dirname, '/public/index'), (err)=> {
- if (err) {
- res.status(500).send(err)
- }
- })
- });
- //Start server
- app.listen(app.get('port'), ()=>{
- console.log(`Server listening on ${app.get('port')}`);
- });
- import React, { Component } from 'react';
- import ReactDom from 'react-dom';
- import { BrowserRouter, Route, Switch } from 'react-router-dom';
- import Axios from 'axios';
- import Home from './Home'
- import Latest from './Latest'
- class App extends Component {
- constructor(props) {
- super(props);
- this.state = {
- RecentExpenses: [],
- monthState: null,
- Total: 0,
- Today: null
- }
- };
- render() {
- return (
- <BrowserRouter>
- <Switch>
- <Route exact path='/' render={(props) => <Home {...props} Today={this.state.Today} Total={this.state.Total} RecentExpenses={this.state.RecentExpenses} />} />
- <Route exact path='/history' render={(props) => <Latest {...props} Recent={this.state.RecentExpenses} month={this.state.monthState} />} />
- </Switch>
- </BrowserRouter>
- )
- }
- }
- ReactDom.render(<App/>, document.getElementById('app'));
- (node:8756) UnhandledPromiseRejectionWarning: Error: Cannot find module 'html'
- at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
- at Function.Module._load (internal/modules/cjs/loader.js:497:25)
- at Module.require (internal/modules/cjs/loader.js:626:17)
- at require (internal/modules/cjs/helpers.js:20:18)
Add Comment
Please, Sign In to add comment