-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Any idea why it couldn't find node-persist and breaks unless I comment out requiring node-persist? Or are there any debugging steps I could take next?
const express = require('express');
const path = require('path');
const randomId = require('random-id');
//const storage = require('../node_modules/node-persist');
const storage = require('node-persist');
const app = express(),
bodyParser = require("body-parser");
port = 3080;
// place holder for the data
const forms = [];
//https://github.com/simonlast/node-persist/blob/master/examples/counter/counter.js
const forms2 = [];
app.use(bodyParser.json());
app.use(express.static(process.cwd()+ '/my-app/build'));
app.get('/api/forms', (req, res) => {
console.log('api/forms called!!!!!!!');
/* if (forms == []){
(async () => {
await storage.init({logging: true, ttl: ttl});
forms2 = await storage.getItem('forms');
if (! forms2) {
await storage.setItem('forms', forms);
}
forms = await storage.getItem('forms');
console.log('forms is ' + forms);
})();
} */
res.json(forms);
});
app.post('/api/form', (req, res) => {
const form = req.body.form;
form.id = randomId(10);
console.log('Adding use:::::::::::', form);
forms.push(form);
res.json("form addedd");
});
app.get('/', (req,res) => {
res.sendFile(process.cwd()+ '/my-app/build/index.html');
});
app.listen(port, () => {
console.log(Server listening on the port::${port});
});

